Important Questions with Answers
(Data and File Structures)
Q-1: What do you mean by data structure? Explain the types of data structure.
Data Structure is a way of organizing, managing, and storing data efficiently for easy access
and modification.
Types of Data Structures:
1. Linear Data Structures: Elements are arranged sequentially. (e.g., Arrays, Linked Lists,
Stacks, Queues)
2. Non-Linear Data Structures: Elements are arranged hierarchically. (e.g., Trees, Graphs)
Q-2: Explain the categories of Data Structure.
1. Primitive Data Structures: Basic structures like int, float, char.
2. Non-Primitive Data Structures:
- Linear: Arrays, Stacks, Queues, Linked Lists
- Non-Linear: Trees, Graphs
- File Structures: Data stored in files on disk
Q-3: What do you mean by the term Array? Discuss the advantages and
disadvantages of Array.
An Array is a collection of elements stored at contiguous memory locations.
Advantages:
- Easy to access via index
- Efficient memory usage for fixed size
Disadvantages:
- Fixed size
- Insertion and deletion are costly
- Wastage of memory if array is not full
Q-4: Differentiate between One-Dimensional Arrays and Multi-Dimensional
Arrays.
1D Array: Single row/column, accessed using arr[i].
Multi-Dimensional Array: Multiple rows/columns (like matrices), accessed using arr[i][j] or
more.
Q-5: Define Stack. Explain the operations of Stack in brief. Explain Stack
Overflow and Underflow.
Stack is a linear data structure that follows LIFO (Last In First Out).
Operations:
- Push: Add element
- Pop: Remove element
- Peek/Top: View top element
Stack Overflow: Push on full stack
Stack Underflow: Pop on empty stack
Q-6: What do you mean by Polish Notations? Explain Prefix, Infix and Postfix
notations with example.
Polish Notation refers to expression formats used in arithmetic.
- Infix: A + B
- Prefix: + A B
- Postfix: A B +
Q-7: What is Queue? Explain the concept of Circular Queue and Priority Queue
in Detail.
Queue is a linear structure that follows FIFO (First In First Out).
- Circular Queue: Last position is connected to first to reuse space.
- Priority Queue: Elements are dequeued based on priority.
Q-8: Explain the Applications of Queues.
- Task scheduling
- Print queue handling
- CPU scheduling
- Call center systems
- BFS in graph
Q-9: Compare Linked List with Array in respect to both advantages and
disadvantages.
Array:
- Fixed size
- Fast index access
- Costly insertion/deletion
Linked List:
- Dynamic size
- Sequential access
- Easy insertion/deletion
- Extra memory for pointers
Q-10: Define Binary Tree. Explain the properties of Binary Tree.
Binary Tree is a tree where each node has at most two children.
Properties:
- Max nodes at level l: 2^l
- Total nodes in perfect binary tree: 2^(h+1) - 1
- Max height for n nodes: n-1
Q-11: Explain doubly linked list in detail.
Doubly Linked List: Each node has two pointers (next and previous).
Advantages:
- Bidirectional traversal
- Easier deletion
Disadvantages:
- Extra memory for pointers
- Slightly complex implementation
Q-12: Explain the difference between Linear Search and Binary Search.
Linear Search:
- Works on any array
- Time Complexity: O(n)
Binary Search:
- Works only on sorted arrays
- Time Complexity: O(log n)