Top 50 C & Data Structures Interview Questions You Must Prepare 26.May.2022

A linked list is a set of linear elements where each element has an index or a pointer that indicates the next element. An element of a linked list is referred to as a node. A node will store data as well as a pointer/index about the next node in the set. There are different types of linked lists. For example, a circular linked list is a list where the last element of the list points to the first element of the list, forming an unbroken chain of data. A double linked list is a list in which every node stores the index of the node on either side of it.

Open addressing (closed hashing), The methods used include: Overflow block.
Closed addressing (open hashing), The methods used include: Linked list, Binary tree.

Basically, the key difference is the memory area that is being accessed. When dealing with the structure that resides the main memory of the computer system, this is referred to as storage structure. When dealing with an auxiliary structure, we refer to it as file structure.


It happens when a high level of paging activity. Thrashing is caused by under allocation of minimum number of pages required by a process, forcing it to continuously page fault. 

When using Call by Value, you are sending the value of a variable as parameter to a function, whereas Call by Reference sends the address of the variable. Also, under Call by Value, the value in the parameter is not affected by whatever operation that takes place, while in the case of Call by Reference, values can be affected by the process within the function.

  • Straight merging.
  • Natural merging.
  • Polyphase sort.
  • Distribution of Initial runs.

Syntax errors are associated with mistakes in the use of a programming language. It maybe a command that was misspelled or a command that must was entered in lowercase mode but was instead entered with an upper case character. A misplaced symbol, or lack of symbol, somewhere within a line of code can also lead to syntax error.

There are actually two ways you can do this. One is to use the increment operator ++ and decrement operator –. For example, the statement “x++” me to increment the value of x by @Likewise, the statement “x –” me to decrement the value of x by @Another way of writing increment statements is to use the conventional + plus sign or – minus sign. In the case of “x++”, another way to write it is “x = x +1”.

Spaghetti programming refers to codes that tend to get tangled and overlapped throughout the program. This unstructured approach to coding is usually attributed to lack of experience on the part of the programmer. Spaghetti programing makes a program complex and analyzing the codes difficult, and so must be avoided as much as possible.

It actually depends on where you intend to apply linked lists. If you based it on storage, a linked list is considered non-linear. On the other hand, if you based it on access strategies, then a linked list is considered linear.

The modulus operator outputs the remainder of a division. It makes use of the percentage (%) symbol. For example: 10 % 3 = 1, meaning when you divide 10 by 3, the remainder is 1.

Variables and constants may at first look similar in a sense that both are identifiers made up of one character or more characters (letters, numbers and a few allowable symbols). Both will also hold a particular value.  Values held by a variable can be altered throughout the program, and can be used in most operations and computations. Constants are given values at one time only, placed at the beginning of a program. This value is not altered in the program. For example, you can assigned a constant named PI and give it a value 3.1415  .  You can then use it as PI in the program, instead of having to write 3.1415 each time you need it. 

A queue is a collection of data that follows the FIFO (First in First Out) principle. It is a type of a linear data structure. Elements in a queue are removed only from the front, while new elements are added only at the back of a queue. Imagine a queue of people in front of movie theater for tickets. People can’t skip to the front for tickets – they have to join the back of the queue. People leave the queue only after they get their tickets, from the front. This is a great example of a queue in data structures. The two operations performed on a queue are enqueue (adding data elements) and dequeue(removing data elements).
A priority queue is a queue in which every element in the queue is assigned a priority and operations are performed on it according to this priority.

  • The manipulation of Arithmetic expression.
  • Symbol Table construction.
  • Syntax analysis.

A null pointer is a special pointer value that is known not to point anywhere. It me that no other valid pointer, to any other variable or array cell or anything else, will ever compare equal to a null pointer.

A stack is one form of a data structure. Data is stored in stacks using the FILO (First In Last Out) approach. At any particular instance, only the top of the stack is accessible, which me that in order to retrieve data that is stored inside the stack, those on the upper part should be extracted first. Storing data in a stack is also referred to as a PUSH, while data retrieval is referred to as a POP.

It is best applied to search a list when the elements are already in order or sorted.
The list here is searched starting in the middle. If that middle value is not the correct one, the lower or the upper half is searched in the similar way.

Multidimensional arrays make use of multiple indexes to store data. It is useful when storing data that cannot be represented using a single dimensional indexing, such as data representation in a board game, tables with data stored in more than one column.

Header files are also known as library files. They contain two essential things: the definitions and prototypes of functions being used in a program. Simply put, commands that you use in C programming are actually functions that are defined from within each header files. Each header file contains a set of functions. For example: stdio.h is a header file that contains definition and prototypes of commands like printf and scanf. 

Aside from being able to store simple structured data types, dynamic memory allocation can combine separately allocated structured blocks to form composite structures that expand and contract as needed.

The process of allocating memory at the time of execution is called dynamic memory allocation. The allocation and release of this memory space can be done with the help of some built in functions whose prototypes are found in alloc.h and stdlib.h.
int *p, n, i;
printf( “Enter the number of integers to be entered.”);
scanf(“%d”, &n);
p=(int *)malloc(n*sizeof(int));
printf(“Memory not available”);
printf(“Enter an integer”);
scanf(“%d”, p+1);
printf(“%d”, *(p+i));
return 0;


  • Compiler Design.
  • Operating System.
  • Database Management System.
  • Statistical analysis package.
  • Numerical Analysis.
  • Graphics.
  • Artificial Intelligence.
  • Simulation.

While curly brackets are mainly used to group several lines of codes, it will still work without error if you used it for a single line. Some programmers prefer this method as a way of organizing codes to make it look clearer, especially in conditional statements.

  • The data structure used for recursion is Stack.
  • Its LIFO property helps it remembers its 'caller'. This helps it know the data which is to be returned when the function has to return.
  • System stack is used for storing the return addresses of the function calls.

The char keyword can only hold 1 character value at a time. By creating an array of characters, you can store string values in it. Example: “char MyName[50]; ” declares a string variable named MyName that can hold a maximum of 50 characters.

This refers to the process wherein a variable is assigned an initial value before it is used in the program. Without initialization, a variable would have an unknown value, which can lead to unpredictable outputs when used in computations or other operations.


A spanning tree is a tree associated with a network. All the nodes of the graph appear on the tree once. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized.

No. The Minimal spanning tree assures that the total weight of the tree is kept at its minimum. But it doesn't mean that the distance between any two nodes involved in the minimum-spanning tree is minimum.

Compilers and interpreters often deal with how program codes are executed. Interpreters execute program codes one line at a time, while compilers take the program as a whole and convert it into object code, before executing it. The key difference here is that in the case of interpreters, a program may encounter syntax errors in the middle of execution, and will stop from there. On the other hand, compilers check the syntax of the entire program and will only proceed to execution when no syntax errors are found.

There are two basic types of data structures:

  • linear.
  • nonlinear. 

Linear data structures : Linear data structures are organized in a way similar to the way computer memory is organized. Linear data structures store elements one after the other, in a linear fashion. Only one element of the data can be traversed at a time. Imagine a stack of books placed on a shelf. A book will be placed between two other books, but not three books- a book will only have a relationship to two other books at the most at one time. Linear data elements are stored in a similar way.
Non linear data structures : Non linear data structures are stored in a sequential way. The data elements in the non linear data structures may have relationships with one or more elements at the same time. Manipulating non linear data structures is more difficult than manipulating linear data structures.

Source codes are codes that were written by the programmer. It is made up of the commands and other English-like keywords that are supposed to instruct the computer what to do. However, computers would not be able to understand source codes. Therefore, source codes are compiled using a compiler. The resulting outputs are object codes, which are in a format that can be understood by the computer processor. In C programming, source codes are saved with the file extension .C, while object codes are saved with the file extension .OBJ

No, it doesn’t.It assures that the total weight of the tree is kept to minimum.It doesn't imply that the distance between any two nodes involved in the minimum-spanning tree is minimum.

B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching easier. This corresponds to the records that shall be stored in leaf nodes.

A block of memory may be allocated using the function malloc. The malloc function reserves a block of memory of specified size and returns a pointer of type void. This me we can assign the base address of the block to any type of pointer.
  Syntax –     P = (cast type*)malloc(byte size);
Calloc is also a memory allocation function which is generally used to allocate memory for array and structure .malloc is used to allocate a single block of storage space, calloc allocates multiple blocks of storage, each of same size and initializes them with zero.
  Syntax -     P = (cast type*)calloc(n,array size);

 RDBMS, Network data model and Hierarchical data model.

  • RDBMS = Array (i.e. Array of structures)
  • Network data model = Graph
  • Hierarchical data model = Trees

Two. One queue is used for actual storing of data and another for storing priorities.

C is a programming language used to write a program. Programs are the set of instructions given by a programmer to the computer in high level language. C uses a compiler to trlate the high level program into machine code before executing any instruction.

Sorting is not possible in Deletion. Using insertion we can perform insertion sort, using selection we can perform selection sort, using exchange we can perform the bubble sort (and other similar sorting methods). But no sorting method can be done just using deletion.

LIFO is short for Last In First Out, and refers to how data is accessed, stored and retrieved. Using this scheme, data that was stored last , should be the one to be extracted first. This also me that in order to gain access to the first data, all the other data that was stored before this first data must first be retrieved and extracted.

The = symbol is often used in mathematical operations. It is used to assign a value to a given variable. On the other hand, the == symbol, also known as “equal to” or “equivalent to”, is a relational operator that is used to compare two values.

Actually macro and function are used for different purposes. A macro replaces its expression code physically in the code at the time of preprocessing. But in case of function the control goes to the function while executing the code. So when the code is small then it is better to use macro. But when code is large then function should be used.

Placing comment symbols /* */ around a code, also referred to as “commenting out”, is a way of isolating some codes that you think maybe causing errors in the program, without deleting the code. The idea is that if the code is in fact correct, you simply remove the comment symbols and continue on. It also saves you time and effort on having to retype the codes if you have deleted it in the first place.


  • Data structure is a group of data elements grouped together under one name.
  • These data elements are called members. They can have different types and different lengths.
  • Some of them store the data of same type while others store different types of data.

The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type.

Pushing and popping refers to the way data is stored into and retrieved from a stack.
PUSH – Data being pushed/ added to the stack.
POP - Data being retrieved from the stack, particularly the topmost data.

Static variable is available to a C application, throughout the life time. At the time of starting the program execution, static variables allocations takes place first. In a scenario where one variable is to be used by all the functions (which is accessed by main () function), then the variable need to be declared as static in a C program.

You can use the #undef preprocessor directive to undefined (override) a previously defined macro.