Data Structure Interview Questions and Answers (C Language)
1. What is a data structure?
A data structure is a way of organizing and storing data in a computer so that it can be accessed and
modified efficiently. Common data structures include arrays, linked lists, stacks, queues, trees, and graphs.
2. What is the difference between an array and a linked list?
Array:
- Contiguous memory
- Fixed size
- Random access (O(1))
Linked List:
- Dynamic memory
- Easy insertion/deletion
- Sequential access (O(n))
3. How is a stack implemented in C?
Using an array:
#define SIZE 100
int stack[SIZE];
int top = -1;
void push(int value) {
if(top == SIZE - 1) printf("Stack Overflow\n");
else stack[++top] = value;
Data Structure Interview Questions and Answers (C Language)
int pop() {
if(top == -1) {
printf("Stack Underflow\n");
return -1;
return stack[top--];
4. What is a queue? How is it different from a stack?
A queue is a linear data structure that follows FIFO (First In First Out), whereas a stack follows LIFO (Last In
First Out).
5. What are the types of linked lists?
1. Singly Linked List
2. Doubly Linked List
3. Circular Linked List
4. Circular Doubly Linked List
6. What is a binary tree?
A binary tree is a tree data structure where each node has at most two children, referred to as the left child
and the right child.
7. Write a simple C structure for a node in a singly linked list.
Data Structure Interview Questions and Answers (C Language)
struct Node {
int data;
struct Node* next;
};
8. What is recursion? Give an example.
Recursion is a function calling itself. Example:
int factorial(int n) {
if(n == 0) return 1;
return n * factorial(n - 1);
9. What is the time complexity of searching in a binary search tree (BST)?
Best case: O(log n) (balanced tree)
Worst case: O(n) (skewed tree)
10. What is a hash table?
A hash table is a data structure that stores data in an associative manner using a hash function to compute
an index into an array of buckets.