T

@thang_nguyen

Live Coding Challenge (Data Structures) We need create a telephone book

C
3 years ago
/* * Create a telephone book. The book will have the telephone number * and the person’s first and last name in a data structure. Write * the code to achieve all of these: * 1. We need to create a new telephone book. * [dev] use link list array. For simple phone number is just an unsigned int * 2. Add a few people to the telephone book. * [dev] API to add new one * 3. Do a lookup by first or else last name. * [dev] API to look up with input first or last or both name

Live Coding Challenge (C) - Write code for a simple I2C driver (Tesla)

C
3 years ago
/* * Simple I2C driver: * 1. Assume you have multiple masters and slave devices using the bus. * [dev] Two cases need to check: * a. Must check bus busy before any transfer because another master may take bus * b. Must check each transfer status to make sure this master not lost arbitration * (2 master may start same time, and which master send more 0 will take bus) * --> re-init the transfer if bus not busy * * 2. It should have 3 basic functions – Dete

Find all palindrome substrings

C
3 years ago
/* Include lib */ #include <stdio.h> #include <assert.h> #include <string.h> /* Define */ #define STR_MAX 4 char str[STR_MAX] = "aaa"; /* Size = Number of chars + 1 for \0 */

Mirror binary tree nodes

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; } #if 0 /* Sample code */ void mirror_tree(BinaryTreeNode* root) {

Determine if two binary trees are identical

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; } #if 0 /* sample code */ bool are_identical(

Merge two sorted linked lists

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; } #if 0 /* sample code */ typedef LinkedListNode* NodePtr; NodePtr merge_sorted(NodePtr head1, NodePtr head2) {

Clone a Directed Graph

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; } #if 0 /* sample code */ Node* clone(Node* root) {

Merge overlapping intervals

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; } #if 0 /* Sample code 8/ class Pair{

Use two threads to print numbers from 1 to n.

C
3 years ago
/* Include lib */ #include <stdio.h> #include <pthread.h> /* Define */ #define MAX_NUM 40 volatile int cnt = 0; /* API */

Find the mode of all the elements stored in an integer array.

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

Collapse a binary search tree into a sorted list.

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

Detect if there’s a circular loop present in a linked list.

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

Find the maximum sum of a subarray.

C
3 years ago
/* Include lib */ #include <stdio.h> #include <string.h> /* Define */ #define ARRAY_MAX 9 #define ARRAY_INPUT { -2, 1, -3, 4, -1, 2, 1, -5, 4 } int array_input[ARRAY_MAX] = ARRAY_INPUT;

Implement AND and OR using 2:1 mux

C
3 years ago
2:1 MUX s a b o 0 x x a 1 x x b AND: c d out 0 0 0 0 1 0 1 0 0

There are three arrays of size 0 to N. Write a program in C

C
3 years ago
/* Include lib */ #include <stdio.h> /* Define */ #define ARRAY_MAX1 6 #define ARRAY_MAX2 8 #define ARRAY_MAX3 10 int array1[ARRAY_MAX1] = { 0, 1, 2, 3, 4, 5 }; int array2[ARRAY_MAX2] = { 9, 10, 2, 6, 7, 15, 2, 1 };

There is a memory with address locations in the range 0 to N

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

1 unit with 9ns delay vs 3 units with delays 2ns, 4ns, 3ns. Which has better throughput and how much

C
3 years ago
https://www.geeksforgeeks.org/computer-organization-and-architecture-pipelining-set-1-execution-stages-and-throughput/ https://cseweb.ucsd.edu/classes/sp13/cse141-a/solutions/assignment4_solutions.pdf Without pipelining = 9/3 minutes = 3m I F S | | | | | | | | | I F S | | | | | | | | | I F S (9 minutes) With pipelining = 5/3 minutes = 1.67m

different methods for floating point multiplication.

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

2D array containing image data, how will you rotate the matrix to rotate the image by 90 degrees clo

C
3 years ago
/* Include lib */ #include <stdio.h> /* Define */ #if 0 #define ARRAY2D_ROW 2 #define ARRAY2D_COL 3 int array_input[ARRAY2D_ROW][ARRAY2D_COL] = { /* row 0 */ 1, 2, 3,

finding minimum gates required for a given truth table

C
3 years ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }