Interview Questions
Interview Questions
Write a program to add two numbers which are represented as linked lists
list A: 1->0->2->3
list B: 3->5
Result: 1->0->3->8
Need recursion logic
4. When do you use threads and when do you use processes (fork())
2. Write an algorithm/program to calculate product of two numbers without using '*' operator
3. Write an algorithm/program to make anagrams of given word.
1. Write a program to find the predecessor and successor of a node in Binary Tree
Result: "aebgcgdhijk"
1. What is a Semaphore and What is a Mutex. Differences between them.
2. Write the pseudo code for different operations on semaphore (P & V operations)
3. What is Virtual Memory. Limit of virtual memory on 32 bit and 64 bit
4. What is Thrashing
5. Write the code for function 'myStr' to get the below desired output
... myStr(....)
{
/* Write code */
}
int main()
{
char *str = "this is a string";
myStr(....);
printf("string = ... ", ....);
return 0;
}
39 = 1, 3, 13, 39
Sum = 52
char c = 128;
printf("%d", c);
6. Size of below structure:
struct sample {
char a;
char b;
char c;
short int d;
};
7. Explain structure padding and packing. What needs to be done for less memory allocation and efficent usage of structures.
8. Explain how and where OcNOS/ZebOS is deployed on your hardware/processor. (Something related to platform)
9. How do you detect a loop in a linked list, how do you find the length of the loop and how do you break the loop.
10. What is a RAW socket. How it works
11. What are different IPC mechanisms.
12. Given a set of 20 numbers which lie between 0 and 1000. Fastest way to search whether a particular number is present in given set or not.
13. Write a sample program to find the size of a datatype on a given architecture.
14. Write a function which takes rows and columns as parameters to allocate dynamic memory to a 2D array, return the right data type/pointer and use it in main() function.
15. What is the time taken in worst case to search an element in a BST. What can be done to minimize the search time.
17. What are your strengths. Give an example for each of your strengths mentioned
for (i=0;i<2;i++)
fork() ;
3. char *ptr ="ABCDE" ;
Where the value ABCDE is stored in C program's memory layout.
4. What is Structure Padding. What is the size of below structure:
struct sample {
int a; Size of int is 4 bytes
double b; Size of double is 8 bytes
char c; Size of char is 1 byte
};
5. char *ptr =malloc(10)
What does ptr store? When free() is called, how it knows how many bytes has to be freed?
6. Difference between a MACRO and Inline function
7. What is the difference between exit(), abort(), assert()
8. How a system call works. What are the steps involved in it.
9. When fork() is used to create a child process, what are shared between parent and child processes?
10. How bit fields are used in a structure? What are the issues faced while using bit fields?
What precautions has to be taken while using bit fields.
11. Write a program to find max width of a Binary Tree
12. What are different IPC mechanisms.
13. Why only message queues are selected to exchange route messages in your product
14. Differences between Linux and FreeBSD
15. What are blocking and non-blocking system calls.
16. Swap two two bits in an integer.
17. Swap two nibbles in an integer.
18. Find second frequent repetitive character in a string
19. Write a program to reverse words in a sentence
Solution: https://www.geeksforgeeks.org/reverse-words-in-a-given-string/
20. Find middle location of a linked list.
21. How do you deallocate memory without using free() function.
22. How do you analyze memory corruptions
23. Using GDB to analyze Assembly code instructions
24. What are AVL trees.
25. Explain how Patricia insertion or how Patricia trie works
26. What is paging.
1. Which sorting technique you use to sort below array and why?
{1, 0, 1, 1, 0, 0, 1, 0, 0, 1}
2. How to calculate max sum in below array
{1, 2 -3, 10, -4, 6, 7, -8}
3. Write a program to find whether given Binary Tree is Binary Search Tree or not.
4. Program to identify whether a given string is Palindrome or not.
1. Toggle a bit
2. Program to sort a given linked list (possibly with O(N) time complexity
1. What are the things you observe in output of 'top' command
2. What is Swap memory
3. Write a program or explain how do you implement priority queues using message passing between two asynchronous process
4. In IP header, checksum field is calculated for what all fields?
5. Write a python program on how to make a dictionary using two different lists without using for loop (you can use lists, map, lambda etc)
6. What is a map in Python
7. How do you implement Exception Handling in C. Write a macro and a function to handle division by '0' case.
8. Explain BGP state machine. What are different BGP packets
9. What is Binary Semaphore. Differences between Binary Semaphore and Mutex
HostA-------RTR1-------------RTR2-----------HostB
7. How does a MAC table look like. What are the fields and contents present in it.
8. Why and how do you use GDB to debug processes. How do you analyze a crash if debug logs are not available.