Data Structures Important Questions Answers
Data Structures Important Questions Answers
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
Operations:
- Push: Add element
- Pop: Remove element
- Peek/Top: View top element
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).
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
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
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)