0% found this document useful (0 votes)
70 views34 pages

Data Structure Mcqs

The document contains multiple-choice questions (MCQs) related to data structures, specifically focusing on concepts of arrays, stacks, queues, and linked lists. It covers definitions, properties, operations, and applications of these data structures, along with their characteristics such as memory allocation and traversal methods. Each question is followed by the correct answer, providing a comprehensive overview of fundamental data structure concepts.

Uploaded by

swetharkv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views34 pages

Data Structure Mcqs

The document contains multiple-choice questions (MCQs) related to data structures, specifically focusing on concepts of arrays, stacks, queues, and linked lists. It covers definitions, properties, operations, and applications of these data structures, along with their characteristics such as memory allocation and traversal methods. Each question is followed by the correct answer, providing a comprehensive overview of fundamental data structure concepts.

Uploaded by

swetharkv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 34

UNIT 1

Data Structures – Concepts, Arrays, and Stacks MCQs

(1) What is a data structure? A) A way to store and organize data B) A type of database C) A
data transmission protocol D) A computer network Answer: A

(2) Which of the following is a linear data structure? A) Tree B) Graph C) Array D) Hash table
Answer: C

(3) Which data structure uses LIFO principle? A) Queue B) Stack C) Array D) Linked List
Answer: B

(4) In which data structure are elements stored in contiguous memory locations? A) Stack B)
Array C) Linked List D) Tree Answer: B

(5) Which of the following is an example of a non-linear data structure? A) Stack B) Queue C)
Tree D) Array Answer: C

(6) What is the index of the first element in an array? A) -1 B) 1 C) 0 D) Depends on language
Answer: C

(7) Which of the following is a dynamic data structure? A) Array B) Stack C) Linked List D)
Matrix Answer: C

(8) How many dimensions can an array have? A) One B) Two C) Any number D) Three only
Answer: C

(9) Which data structure is best suited for arithmetic expression evaluation? A) Queue B) Graph
C) Stack D) Tree Answer: C

(10) Which of the following allows random access? A) Linked List B) Stack C) Queue D) Array
Answer: D

(11) What is a sparse matrix? A) A matrix with all elements B) A matrix with no zero elements
C) A matrix with majority elements as zero D) A matrix with only diagonal elements Answer: C

(12) Which operation inserts an element at the top of a stack? A) Pop B) Insert C) Push D) Add
Answer: C

(13) Which operation removes the top element from a stack? A) Delete B) Remove C) Pull D)
Pop Answer: D

(14) Which notation is used for postfix expression? A) Operator before operand B) Operator
between operands C) Operand before operator D) None Answer: C
(15) Which is NOT a valid stack operation? A) Push B) Peek C) Insert at bottom D) Pop
Answer: C

(16) Recursion uses which data structure internally? A) Queue B) Stack C) Heap D) Tree
Answer: B

(17) Which of the following is used to convert infix to postfix? A) Queue B) Stack C) Tree D)
Graph Answer: B

(18) What does the peek operation do? A) Inserts element B) Deletes element C) Returns top
element without removing it D) Empties stack Answer: C

(19) What is the maximum number of elements a stack can hold if the size is defined as 10? A) 9
B) 10 C) 11 D) Depends on system Answer: B

(20) Which algorithm is used to solve Tower of Hanoi? A) Recursion B) Iteration C) Searching
D) Backtracking Answer: A

(21) Which of the following is not a data structure operation? A) Traversal B) Insertion C)
Compiling D) Deletion Answer: C

(22) Which of these supports FIFO? A) Stack B) Array C) Queue D) Tree Answer: C

(23) In array implementation of stack, overflow occurs when: A) Stack is empty B) Stack is full
C) Stack has one element D) Stack pointer is at zero Answer: B

(24) What happens when a stack underflows? A) It adds data automatically B) It performs peek
C) It accesses invalid memory D) It resets itself Answer: C

(25) Two-dimensional arrays are best suited to represent: A) Trees B) Graphs C) Matrices D)
Queues Answer: C

(26) Which of these supports dynamic memory allocation? A) Array B) Stack C) Linked List D)
Matrix Answer: C

(27) In a stack, top is initially: A) -1 B) 0 C) 1 D) NULL Answer: A

(28) Which stack operation checks the top without removing it? A) Push B) Pop C) Peek D)
Empty Answer: C

(29) Which notation requires no parenthesis? A) Infix B) Prefix C) Postfix D) Both B and C
Answer: D

(30) What is the time complexity of push operation in stack? A) O(log n) B) O(n) C) O(1) D)
O(n log n) Answer: C
(31) Which structure uses nodes and pointers? A) Stack B) Array C) Linked List D) Queue
Answer: C

(32) The array index must be of type: A) float B) double C) integer D) char Answer: C

(33) Which of the following is not true for stack? A) Stack can be implemented using array B)
Stack can be implemented using linked list C) Stack can have multiple tops D) Stack is LIFO
Answer: C

(34) What does 'n-dimensional array' refer to? A) 1D array B) Array with two indices C) Array
with more than 2 dimensions D) Sparse matrix Answer: C

(35) Which of these is not a valid operation on arrays? A) Traversing B) Insertion at random
position C) Deletion D) Reversal Answer: B

(36) Which expression type needs conversion before evaluation? A) Postfix B) Infix C) Prefix D)
Mixed Answer: B

(37) Which is the base case in Tower of Hanoi problem? A) Move 1 disk B) Move 2 disks C)
Move all disks D) None Answer: A

(38) Which of the following cannot be used with stacks? A) Expression conversion B)
Expression evaluation C) Tree traversal D) Binary search Answer: D

(39) Which of the following is used to implement recursion? A) Stack B) Queue C) Linked List
D) Array Answer: A

(40) Stack overflow means: A) More memory allocated B) Stack full C) Stack empty D)
Operation successful Answer: B

(41) Which matrix has mostly zero elements? A) Dense B) Sparse C) Regular D) Uniform
Answer: B

(42) In recursion, base case is: A) Termination point B) Function call C) Stack top D) Starting
point Answer: A

(43) What data structure is used in depth-first traversal? A) Queue B) Stack C) Graph D) Array
Answer: B

(44) A stack can be implemented using: A) Array only B) Linked List only C) Array or Linked
List D) Matrix Answer: C

(45) If you remove an element from an empty stack: A) Stack resets B) Error or underflow
occurs C) Value becomes 0 D) Nothing happens Answer: B
(46) What is the use of stack in backtracking? A) Stores visited path B) Stores parent node C)
Tracks solution D) All of the above Answer: D

(47) Which of these supports random insertion? A) Stack B) Array C) Queue D) Linked List
Answer: D

(48) Stack memory is: A) RAM B) Cache C) ROM D) Disk Answer: A

(49) In tower of Hanoi with 3 disks, how many moves are required? A) 7 B) 5 C) 6 D) 9
Answer: A

(50) How many stacks are required to evaluate postfix? A) 1 B) 2 C) 3 D) 4 Answer: A

(51) The push operation adds element: A) Anywhere B) Bottom of stack C) Top of stack D)
Middle Answer: C

(52) What does a two-dimensional array look like? A) Line B) Matrix C) Tree D) List Answer:
B

(53) A stack is said to be empty when: A) Top = -1 B) Top = 0 C) Top = size D) Stack has no
memory Answer: A

(54) What is postfix of A + B * C? A) ABC*+ B) AB+C* C) A+BC* D) *+ABC Answer: A

(55) Which is not an application of stack? A) Undo feature B) Parenthesis checker C) Binary
search D) Expression evaluator Answer: C

(56) Maximum size of an array is determined at: A) Compile time B) Run time C) Link time D)
Depends on system Answer: A

(57) Which structure has no limit on data size? A) Stack B) Queue C) Linked List D) Array
Answer: C

(58) Which function solves Tower of Hanoi? A) Recursive() B) hanoi() C) TOH() D) All of the
above Answer: D

(59) What kind of array has variable number of elements in each row? A) Rectangular B) Jagged
C) Sparse D) Multidimensional Answer: B

(60) Stack pointer keeps track of: A) Bottom element B) All elements C) Top element D) Middle
element Answer: C

(61) Postfix expression evaluation is: A) Left to right B) Right to left C) Top to bottom D) Based
on priority Answer: A

(62) Infix notation of AB+C* is: A) A+(BC) B) A+BC C) (A+B)C D) A(B+C) Answer: B
(63) What is 2D array? A) Collection of strings B) Matrix with rows and columns C) Linear
array D) None Answer: B

(64) N-dimensional arrays are represented using: A) Stack B) Pointers C) Nested arrays D) All
of the above Answer: D

(65) Which operation is invalid on a full stack? A) Push B) Pop C) Peek D) Display Answer: A

(66) How is a sparse matrix stored efficiently? A) 2D array B) Linked list C) Triplet or array of
structures D) Tree Answer: C

(67) Which of these is NOT a stack application? A) Expression balancing B) Recursion C)


Sorting D) Undo system Answer: C

(68) Which stack operation takes constant time? A) Push B) Pop C) Peek D) All of the above
Answer: D

(69) Recursive functions must have: A) Loop B) Base case C) Stack D) Queue Answer: B

(70) Array is best when: A) Insertion is frequent B) Memory is limited C) Random access is
needed D) Size is dynamic Answer: C

(71) What is needed to convert infix to postfix? A) Stack B) Queue C) Tree D) Loop Answer: A

(72) What is time complexity for evaluating postfix? A) O(n^2) B) O(log n) C) O(n) D) O(1)
Answer: C

(73) Which is better for recursive functions? A) Iteration B) Stack C) Array D) Queue Answer:
B

(74) What happens when recursion depth exceeds? A) Memory leak B) Stack overflow C) Core
dump D) Program exits Answer: B

(75) Stacks are used in: A) Operating systems B) Compiler design C) Expression parsing D) All
of the above Answer: D

(76) Which case terminates a recursive call? A) Infinite loop B) Base condition met C) Stack full
D) Memory exhausted Answer: B

(77) What is the result of prefix +AB? A) A+B B) B+A C) A*B D) Error Answer: A

(78) What is the stack size after 3 push and 1 pop? A) 2 B) 3 C) 4 D) 1 Answer: A

(79) A three-dimensional array needs: A) 3 indices B) 2 indices C) 1 index D) 4 indices Answer:


A
(80) What does post-order traversal use? A) Queue B) Stack C) Tree D) Graph Answer: B

(81) Which problem uses recursion effectively? A) Tower of Hanoi B) Linear search C) Binary
search D) Hashing Answer: A

(82) Which is not part of stack operations? A) Push B) Peek C) Enqueue D) Pop Answer: C

(83) Stacks are preferred when: A) First inserted item needed B) Last inserted item needed C)
Any element needed D) None Answer: B

(84) Stack can be used for: A) Function calls B) Parsing C) Backtracking D) All of the above
Answer: D

(85) Which is not a type of array? A) Single dimensional B) Circular C) Multi-dimensional D)


Sparse Answer: B

(86) What determines efficiency of recursion? A) Base case B) Stack usage C) Memory usage D)
All of the above Answer: D

(87) Array elements are stored: A) Randomly B) Sequentially C) Scattered D) Virtually Answer:
B

(88) What structure is used in undo/redo? A) Stack B) Array C) Tree D) Queue Answer: A

(89) What makes sparse matrix useful? A) Fast access B) Less memory C) More zeros D)
Multiple types Answer: B

(90) Expression (A+B)(C-D) in postfix is: A) AB+CD- B) ABCD+-* C) A+B*C-D D) AB+*CD-


Answer: A

(91) Tower of Hanoi uses how many rods? A) 2 B) 3 C) 4 D) 5 Answer: B

(92) Function call in recursion is stored in: A) Stack frame B) Heap C) Tree D) Table Answer:
A

(93) 2D array in memory is represented as: A) Row-major/column-major B) Linked list C) Tree


D) Queue Answer: A

(94) In sparse matrix, non-zero elements are stored: A) Only in arrays B) As triplets C) In linked
lists D) In matrices Answer: B

(95) Expression evaluator uses: A) Queue B) Array C) Stack D) Graph Answer: C

(96) Stack implemented by array is: A) Static B) Dynamic C) Hybrid D) Circular Answer: A

(97) Top pointer after one push on empty stack: A) 0 B) -1 C) 1 D) Depends Answer: A
(98) Which algorithm uses stack? A) Depth-first search B) Breadth-first search C) Linear search
D) Hashing Answer: A

(99) What is reverse Polish notation? A) Prefix B) Infix C) Postfix D) None Answer: C

(100) Which structure tracks function calls? A) Tree B) Stack C) Queue D) Array Answer: B

UNIT 2
Queues and Linked Lists – MCQs

(1) What is a queue? A) A data structure following LIFO B) A linear data structure following
FIFO C) A circular structure D) A random structure Answer: B

(2) Which operation inserts an element in a queue? A) Pop B) Peek C) Enqueue D) Delete
Answer: C

(3) Which operation removes an element from a queue? A) Insert B) Enqueue C) Dequeue D)
Add Answer: C

(4) Which of the following is a circular queue? A) Queue with a fixed size B) Queue
implemented with linked list C) Queue where rear connects to front D) Queue used in trees
Answer: C

(5) What is a deque? A) Queue with one end B) Stack + Queue C) Double-ended queue D) Non-
linear structure Answer: C

(6) What is a priority queue? A) Normal queue B) Queue with random insertion C) Queue where
elements are dequeued based on priority D) Queue used in recursion Answer: C

(7) Which is NOT a queue application? A) CPU scheduling B) Disk scheduling C) Simulation
D) Arithmetic evaluation Answer: D

(8) Which algorithm uses queues in CPU scheduling? A) Tower of Hanoi B) Round Robin C)
Merge Sort D) Recursion Answer: B

(9) What happens in round robin scheduling? A) Each process gets fixed time B) One process
runs forever C) One queue for all D) Recursive execution Answer: A

(10) In simulation, queues are used to: A) Sort elements B) Reverse input C) Model waiting lines
D) Solve equations Answer: C

(11) Which data structure is used in breadth-first search? A) Stack B) Queue C) Tree D) Graph
Answer: B
(12) What is a linked list? A) Array of integers B) List with contiguous elements C) Collection
of nodes linked together D) File system Answer: C

(13) What is the first node in a linked list called? A) Start B) Begin C) Head D) Entry Answer:
C

(14) What does a node contain in a single linked list? A) Data only B) Data and pointer to next
C) Data and pointer to previous D) Key and value Answer: B

(15) What is circular linked list? A) List with repeated data B) Last node points to head C) List
with no head D) List with tail only Answer: B

(16) What is a doubly linked list? A) List with two data fields B) List where nodes point in one
direction C) List with previous and next pointers D) List sorted by key Answer: C

(17) What is the difference in circular doubly linked list? A) Tail points to head and vice versa
B) List without NULL pointers C) List with two heads D) List only for stack Answer: A

(18) Which linked list type uses most memory? A) Single B) Circular C) Doubly D) Circular
doubly Answer: D

(19) Which of the following allows traversal in both directions? A) Stack B) Queue C) Doubly
linked list D) Single linked list Answer: C

(20) Which is not a valid operation on a linked list? A) Insert B) Search C) Pop D) Delete
Answer: C

(21) What is the application of linked list in mathematics? A) Polynomial representation B)


Equation solving C) Matrix transformation D) None Answer: A

(22) What does a polynomial term consist of? A) Only coefficients B) Degree only C)
Coefficient and exponent D) Array index Answer: C

(23) In linked list polynomial, each node represents: A) One equation B) One constant C) One
term D) All variables Answer: C

(24) How are polynomial terms stored in a list? A) Randomly B) Sorted by exponent C) Sorted
by coefficient D) Grouped by variable Answer: B

(25) Which data structure is best for polynomial operations? A) Array B) Stack C) Linked List
D) Queue Answer: C

(26) What is the main disadvantage of linked lists over arrays? A) Fixed size B) Extra memory
for pointers C) Slow access time D) Both B and C Answer: D
(27) Which of the following queue types is most useful for scheduling tasks by importance? A)
Circular queue B) Deque C) Priority queue D) FIFO queue Answer: C

(28) Which of these linked lists provides the fastest insertion at both ends? A) Single linked list
B) Circular linked list C) Doubly linked list D) Circular doubly linked list Answer: D

(29) Which pointer is NOT present in a singly linked list? A) Prev B) Next C) NULL D) Head
Answer: A

(30) Which queue structure is used in BFS? A) Stack B) Priority Queue C) Circular Queue D)
Linear Queue Answer: D

(31) What is the time complexity of enqueue operation in a queue? A) O(1) B) O(n) C) O(log n)
D) O(n log n) Answer: A

(32) What is the primary benefit of circular queues over linear queues? A) Simpler
implementation B) Better memory utilization C) Faster processing D) Easier traversal Answer:
B

(33) In a circular queue, when is the queue full? A) rear == size - 1 B) rear == front C) (rear + 1)
% size == front D) rear == NULL Answer: C

(34) Which of the following data structures is most appropriate for implementing a printer
spooler? A) Stack B) Queue C) Linked list D) Tree Answer: B

(35) How is polynomial addition implemented using linked lists? A) Multiply coefficients B)
Add matching exponents C) Merge two sorted lists D) Both B and C Answer: D

(36) What is the time complexity to search an element in a singly linked list? A) O(1) B) O(n) C)
O(log n) D) O(n log n) Answer: B

(37) What is the drawback of singly linked list over doubly linked list? A) Cannot traverse
backward B) Extra memory for pointers C) Cannot insert at front D) Cannot delete Answer: A

(38) Which pointer is updated when inserting a node at the beginning of a singly linked list? A)
Tail B) Rear C) Head D) Next Answer: C

(39) What is the time complexity for inserting a node at the end of a singly linked list (with tail
pointer)? A) O(n) B) O(1) C) O(log n) D) O(n log n) Answer: B

(40) Which of these is not true for doubly linked lists? A) Each node points to the previous node
B) It requires more memory C) It allows backward traversal D) It's faster than singly linked list
for all operations Answer: D

(41) Which of these is used to implement undo operations? A) Queue B) Stack C) Linked List D)
Tree Answer: B
(42) Which of the following is true for a circular linked list? A) First node points to null B) Last
node points to null C) Last node points to head D) No node points to another Answer: C

(43) In which scenario is a circular queue more efficient than a linear queue? A) When elements
need to be reversed B) When front and rear meet C) When queue is implemented using array D)
When queue operations are frequent and fixed-size Answer: D

(44) Which data structure allows insertion and deletion at both ends? A) Queue B) Deque C)
Stack D) Circular linked list Answer: B

(45) Which data structure is most suited for representing polynomials dynamically? A) Array B)
Linked List C) Stack D) Tree Answer: B

(46) What is the primary advantage of linked list over arrays? A) Fixed memory usage B) Easy
to reverse C) Dynamic memory allocation D) Faster sorting Answer: C

(47) In a doubly linked list, the last node contains: A) Null in both pointers B) Pointer to next
only C) Null in next and pointer to previous D) Pointer to previous and next Answer: C

(48) Which of the following is used to remove elements from both ends? A) Deque B) Priority
Queue C) Stack D) Circular Queue Answer: A

(49) How many pointers are needed in a node of a doubly linked list? A) 1 B) 2 C) 3 D) 4
Answer: B

(50) What is the result of enqueue followed by dequeue in a queue? A) Queue is empty B) One
element added C) One element removed D) Queue unchanged Answer: A

(51) Which pointer indicates the end of a singly linked list? A) prev B) head C) NULL D) last
Answer: C

(52) In linked list insertion, where can a node be added? A) Beginning B) End C) Middle D) All
of the above Answer: D

(53) A circular queue eliminates the problem of: A) Memory allocation B) Overflow C) Wasted
memory D) None Answer: C

(54) What is the time complexity of deleting a node from a linked list given its pointer? A) O(n)
B) O(1) C) O(log n) D) O(n log n) Answer: B

(55) In a priority queue, which element is removed first? A) Most recently added B) Highest
value C) Lowest value D) Element with highest priority Answer: D

(56) What does each node of a circular doubly linked list contain? A) Data, next B) Data, next,
previous C) Only data D) Data and index Answer: B
(57) What is the output if the queue is empty and dequeue is performed? A) Underflow error B)
Overflow error C) Memory leak D) Nothing Answer: A

(58) The time complexity to traverse a linked list of size n is: A) O(1) B) O(n) C) O(n²) D) O(log
n) Answer: B

(59) In a linked list, which node contains NULL? A) First B) Middle C) Last D) None Answer:
C

(60) A deque allows insertions and deletions from: A) Front only B) Rear only C) Both ends D)
Middle only Answer: C

(61) A node in a singly linked list has: A) Two pointers B) Data and one pointer C) Only data D)
Previous and next Answer: B

(62) What is the role of the front pointer in a queue? A) Indicates rear B) Indicates first element
C) Points to last node D) Resets memory Answer: B

(63) Which structure can implement polynomial multiplication efficiently? A) Stack B) Queue
C) Array D) Linked list Answer: D

(64) What is the drawback of arrays compared to linked lists? A) Cannot resize B) Easier
insertion C) Easy deletion D) Faster access Answer: A

(65) In a doubly linked list, what happens when a node is deleted? A) Nothing B) Memory is
retained C) Pointers must be adjusted D) Only data is removed Answer: C

(66) Circular linked lists are efficient for: A) Stack operations B) Repeating tasks in loops C)
Random access D) Sorting Answer: B

(67) Which queue is used in level order traversal of binary tree? A) Deque B) Priority Queue C)
Linear Queue D) Circular Queue Answer: C

(68) Which of the following allows insertion at one end and deletion at the other? A) Stack B)
Queue C) Tree D) Graph Answer: B

(69) In linked lists, data is stored: A) Contiguously B) Randomly in memory C) Sorted by


default D) In registers Answer: B

(70) In a priority queue, which data structure is commonly used? A) Heap B) Linked list C)
Stack D) Binary Tree Answer: A

(71) What is the time complexity to insert a node at the beginning of a linked list? A) O(n) B)
O(1) C) O(log n) D) O(n²) Answer: B
(72) Which operation is not allowed in queue? A) Insert at rear B) Delete from front C) Peek
front D) Insert at front Answer: D

(73) What is the use of a NULL pointer in linked lists? A) Acts as terminator B) Points to last C)
Helps find start D) Indicates overflow Answer: A

(74) What is the best data structure for a playlist where next and previous songs must be
accessible? A) Array B) Stack C) Doubly linked list D) Queue Answer: C

(75) Which queue is used in scheduling disk access? A) Priority queue B) Deque C) Stack D)
Simple queue Answer: A

(76) In a singly linked list, which node does not have a next pointer? A) First B) Last C) Second
D) Middle Answer: B

(77) To represent sparse matrix efficiently, use: A) Array B) Stack C) Triplet linked list D)
Queue Answer: C

(78) What is the default direction of insertion in a queue? A) Front B) Rear C) Middle D)
Random Answer: B

(79) What does a linked list require more of compared to array? A) Time B) Memory C) Pointers
D) None Answer: B

(80) A node is: A) Data only B) Memory cell C) Structure containing data and link D) None
Answer: C

(81) What is front == rear condition in circular queue used to detect? A) Underflow B) Overflow
C) Empty Queue D) Null pointer Answer: B

(82) What is a sentinel node? A) Node used for data B) Dummy node marking end/start C) First
node D) Last node Answer: B

(83) A doubly linked list with one node has: A) NULL in both links B) Self-reference C) One
pointer only D) Cyclic link Answer: A

(84) In linked lists, nodes are created using: A) Arrays B) Structs/Objects C) Classes only D)
None Answer: B

(85) What is necessary to remove an element from a linked list? A) Index B) Key C) Pointer to
previous node D) None Answer: C

(86) A queue implemented using an array has maximum size: A) n+1 B) Fixed at runtime C)
Depends on memory D) Depends on front Answer: B
(87) When rear = front in a circular queue: A) Queue is full B) Queue is empty C) One element
exists D) Error Answer: A

(88) Which linked list type is ideal for games with undo/redo? A) Single B) Circular C) Doubly
D) Random Answer: C

(89) Polynomial expressions are represented using: A) Array B) Stack C) Linked list D) Graph
Answer: C

(90) What operation is common in both stack and queue? A) Push B) Insert C) Delete D) None
Answer: C

(91) In linked list, each element is called: A) Value B) Pointer C) Node D) Data Answer: C

(92) How to reverse a singly linked list? A) Use loop B) Change head C) Update next pointers
D) Delete and insert Answer: C

(93) How to know end of linked list? A) By size B) By NULL C) By memory address D) By
element count Answer: B

(94) What structure manages free memory in dynamic allocation? A) Queue B) Stack C) Free list
D) Array Answer: C

(95) A circular queue is implemented using: A) Stack B) Linked list or array C) Tree D) Graph
Answer: B

(96) What is rear pointer in a queue used for? A) Point to front B) Point to first element C) Insert
new element D) Remove element Answer: C

(97) Which queue gives highest priority to important tasks? A) Simple queue B) Deque C)
Circular queue D) Priority queue Answer: D

(98) What is best data structure for implementing LRU cache? A) Tree B) Linked list + hash C)
Stack D) Array Answer: B

(99) Which linked list type doesn’t use NULL? A) Singly B) Doubly C) Circular D) Multilevel
Answer: C

(100) A dynamic list grows by: A) Looping B) User input C) Allocation on demand D) Fixed
blocks Answer: C

UNIT 3

I. Basic Terminologies (1–20)


1. Which of the following is true about a binary tree?
o A) It has at most two children
o B) It can have multiple roots
o C) Each node can have up to three children
o D) It is always balanced
Answer: A
2. The topmost node of a binary tree is called:
o A) Leaf
o B) Root
o C) Subtree
o D) Parent
Answer: B
3. A node with no children is called:
o A) Root
o B) Leaf
o C) Internal node
o D) Sibling
Answer: B
4. Which of the following is not a part of tree terminology?
o A) Root
o B) Degree
o C) Graph
o D) Leaf
Answer: C
5. The number of edges from the root to the node is called:
o A) Degree
o B) Height
o C) Depth
o D) Weight
Answer: C
6. Which node has both parent and child?
o A) Leaf
o B) Root
o C) Internal
o D) Sibling
Answer: C
7. A node’s immediate predecessor is called:
o A) Sibling
o B) Parent
o C) Leaf
o D) Subtree
Answer: B
8. The height of a single-node tree is:
o A) 0
o B) 1
o C) 2
o D) Undefined
Answer: A
9. Which of the following is an ordered tree?
o A) Binary tree
o B) AVL tree
o C) B-tree
o D) Ternary tree
Answer: A
10. The maximum number of nodes at level ‘l’ of a binary tree is:
o A) l
o B) 2^(l-1)
o C) 2l
o D) l^2
Answer: B
11. In a binary tree of height h, the maximum number of nodes is:
o A) 2^h
o B) 2^(h+1) - 1
o C) h^2
o D) 2h
Answer: B
12. The minimum number of nodes in a binary tree of height h is:
o A) h
o B) h+1
o C) h-1
o D) log h
Answer: A
13. In a binary tree, if the left and right subtree of every node differs in height by at most one,
it is:
o A) Complete tree
o B) Full tree
o C) Balanced tree
o D) Skewed tree
Answer: C
14. A binary tree is said to be full if:
o A) Every node has two children or no child
o B) Every level is completely filled
o C) Each node has one child
o D) None of the above
Answer: A
15. The number of null links in a binary tree with n nodes is:
o A) n-1
o B) n
o C) n+1
o D) 2n
Answer: C
16. A tree with no nodes is called:
o A) Empty tree
o B) Null tree
o C) Void tree
o D) None of these
Answer: A
17. The degree of a node in a binary tree can be:
o A) 0 to 2
o B) 1 to 3
o C) 2 to 3
o D) 0 to 1
Answer: A
18. The ancestor of a node is:
o A) Any node on the path from the node to the root
o B) Only the parent node
o C) The leaf node
o D) The sibling
Answer: A
19. A binary tree of n nodes has exactly:
o A) n-1 edges
o B) n+1 edges
o C) n edges
o D) log n edges
Answer: A
20. Sibling nodes share the same:
o A) Parent
o B) Height
o C) Data
o D) Depth
Answer: A

II. Binary Tree Representation (21–40)

21. The linear representation of binary trees is best suited for:

 A) Complete binary trees


 B) Skewed trees
 C) Balanced trees
 D) Random trees
Answer: A

22. Which data structure is used in linear representation of binary trees?

 A) Stack
 B) Queue
 C) Array
 D) Linked List
Answer: C

23. In array representation, the left child of a node at index i is at:

 A) 2i
 B) 2i + 1
 C) i/2
 D) 2i - 1
Answer: A

24. In array representation, the right child of node i is at:

 A) 2i
 B) 2i + 1
 C) i/2
 D) i - 1
Answer: B

25. In array representation, the parent of a node at index i is:

 A) i/2
 B) floor(i/2)
 C) 2i
 D) i+1
Answer: B

26. What is the main disadvantage of linear representation?

 A) Difficult to implement
 B) Inefficient for sparse trees
 C) Takes too much time
 D) Not human readable
Answer: B

27. Which structure is ideal for linked representation?

 A) Array
 B) Stack
 C) Node with pointers
 D) Queue
Answer: C

28. In linked representation, each node contains:


 A) Data only
 B) One pointer only
 C) Data and two pointers
 D) Only pointers
Answer: C

29. Which traversal technique is used to implement deletion in a binary tree?

 A) In-order
 B) Level-order
 C) Post-order
 D) Pre-order
Answer: B

30. Which of these trees is best stored using linked representation?

 A) Complete
 B) Sparse
 C) Balanced
 D) AVL
Answer: B

Binary Tree Representation (31–40)

31. What is the main disadvantage of linear representation?

 A) Difficult to implement
 B) Inefficient for sparse trees
 C) Takes too much time
 D) Not human readable
Answer: B

32. Which structure is ideal for linked representation?

 A) Array
 B) Stack
 C) Node with pointers
 D) Queue
Answer: C

33. In linked representation, each node contains:

 A) Data only
 B) One pointer only
 C) Data and two pointers
 D) Only pointers
Answer: C

34. Which traversal technique is used to implement deletion in a binary tree?

 A) In-order
 B) Level-order
 C) Post-order
 D) Pre-order
Answer: B

35. Which of these trees is best stored using linked representation?

 A) Complete
 B) Sparse
 C) Balanced
 D) AVL
Answer: B

36. Linked representation of binary trees is useful when:

 A) Nodes have fixed positions


 B) Trees are large and sparse
 C) Trees are full
 D) Array size is small
Answer: B

37. The memory usage in linked representation is:

 A) Fixed
 B) Dynamic
 C) Limited
 D) Compact
Answer: B

38. In linked representation, null pointers are used to:

 A) Mark root nodes


 B) Identify parent nodes
 C) Indicate absent children
 D) Point to the next node
Answer: C

39. The array representation of a tree with missing nodes leads to:

 A) Better efficiency
 B) Memory waste
 C) Faster traversal
 D) Compact storage
Answer: B

40. A node at index i in an array representation has its parent at:

 A) i/2
 B) floor(i/2)
 C) 2i
 D) i-1
Answer: B

III. Traversal Operations (41–60)

41. In which traversal is the root visited before its subtrees?

 A) In-order
 B) Pre-order
 C) Post-order
 D) Level-order
Answer: B

42. In which traversal is the root visited after both left and right subtrees?

 A) In-order
 B) Pre-order
 C) Post-order
 D) Level-order
Answer: C

43. In-order traversal of a binary search tree results in:

 A) Random order
 B) Sorted order
 C) Reverse order
 D) Post-order
Answer: B

44. Which traversal uses a queue?

 A) Pre-order
 B) Post-order
 C) In-order
 D) Level-order
Answer: D

45. What is the in-order traversal of a tree with root A, left child B, and right child C?

 A) A B C
 B) B A C
 C) C A B
 D) B C A
Answer: B

46. Which traversal technique is ideal for copying a tree?

 A) Pre-order
 B) In-order
 C) Post-order
 D) Level-order
Answer: A

47. Which traversal is best for deleting the tree?

 A) In-order
 B) Pre-order
 C) Post-order
 D) Level-order
Answer: C

48. Which traversal of an expression tree gives the prefix expression?

 A) Post-order
 B) In-order
 C) Pre-order
 D) Level-order
Answer: C

49. Which traversal of an expression tree gives the postfix expression?

 A) In-order
 B) Post-order
 C) Pre-order
 D) Reverse in-order
Answer: B

50. To print nodes level by level, which traversal is used?


 A) Pre-order
 B) In-order
 C) Post-order
 D) Level-order
Answer: D

51. The order of visiting nodes in post-order is:

 A) Left, Right, Root


 B) Right, Root, Left
 C) Root, Left, Right
 D) Left, Root, Right
Answer: A

52. Which traversal follows Root, Left, Right?

 A) Post-order
 B) In-order
 C) Pre-order
 D) Level-order
Answer: C

53. Which traversal of a BST is used to display sorted data?

 A) Post-order
 B) Pre-order
 C) In-order
 D) Level-order
Answer: C

54. What is the time complexity of all tree traversals?

 A) O(log n)
 B) O(n log n)
 C) O(n)
 D) O(n²)
Answer: C

55. Which traversal technique requires a queue?

 A) Level-order
 B) In-order
 C) Pre-order
 D) Post-order
Answer: A
56. Level-order traversal is a type of:

 A) Depth First Traversal


 B) Breadth First Traversal
 C) Post-order Traversal
 D) Reverse Traversal
Answer: B

57. In-order traversal of the tree below gives what result?

A
/
BC

 A) A B C
 B) B A C
 C) C B A
 D) B C A
Answer: B

58. The number of traversals required to reconstruct a binary tree uniquely is:

 A) 1
 B) 2
 C) 3
 D) 0
Answer: B

59. Which two traversals are sufficient to reconstruct a binary tree?

 A) In-order and Post-order


 B) Pre-order and Post-order
 C) In-order and Pre-order
 D) Both A and C
Answer: D

60. Which traversal method is commonly used in evaluating expressions?

 A) Pre-order
 B) In-order
 C) Post-order
 D) Level-order
Answer: C
IV. Types of Binary Trees (61–100)

A. Expression Tree (61–70)

61. Expression trees are used to represent:

 A) Arithmetic expressions
 B) Boolean expressions
 C) Logical expressions
 D) All of the above
Answer: D

62. Leaf nodes in an expression tree represent:

 A) Operators
 B) Operands
 C) Expressions
 D) Functions
Answer: B

63. Internal nodes in an expression tree represent:

 A) Operands
 B) Leaf nodes
 C) Operators
 D) Values
Answer: C

64. An expression tree’s in-order traversal gives:

 A) Infix expression
 B) Prefix expression
 C) Postfix expression
 D) None
Answer: A

65. Expression trees are typically:

 A) Full binary trees


 B) Skewed trees
 C) Complete binary trees
 D) AVL trees
Answer: A

66. Which of the following expressions is represented in postfix form?


 A) A + B
 B) +AB
 C) AB+
 D) A B + C
Answer: C

67. To evaluate an expression tree, we use:

 A) Pre-order
 B) In-order
 C) Post-order
 D) Level-order
Answer: C

68. What does the root of an expression tree contain?

 A) Operand
 B) Operator
 C) Variable
 D) Constant
Answer: B

69. Expression trees can be used in:

 A) Compiler design
 B) Operating system
 C) Databases only
 D) Networking
Answer: A

70. Expression trees follow which traversal for infix conversion?

 A) Pre-order
 B) Post-order
 C) In-order
 D) Level-order
Answer: C

B. Binary Search Tree (BST) (71–85)

71. In a BST, left child node contains:

 A) Larger value
 B) Equal value
 C) Smaller value
 D) Random value
Answer: C

72. In a BST, right child node contains:

 A) Larger or equal value


 B) Smaller value
 C) Unordered value
 D) None of the above
Answer: A

73. Inserting values 10, 5, 15, 3, 7 into a BST results in:

 A) Balanced tree
 B) Sorted list
 C) Tree with root 10 and left child 5
 D) Unordered structure
Answer: C

74. BST ensures:

 A) O(1) search
 B) O(n) search
 C) Logarithmic search in average case
 D) Constant time deletion
Answer: C

75. Inserting into a BST takes:

 A) O(1)
 B) O(log n) on average
 C) O(n²)
 D) O(n log n)
Answer: B

76. Searching for an element in a skewed BST is:

 A) O(log n)
 B) O(1)
 C) O(n)
 D) O(n log n)
Answer: C

77. Deleting a node with two children in a BST requires:

 A) Replacing it with its inorder successor or predecessor


 B) Deleting the whole tree
 C) Random deletion
 D) None of the above
Answer: A

78. BST is efficient when it is:

 A) Skewed
 B) Balanced
 C) Linear
 D) Full
Answer: B

79. Which traversal lists BST values in descending order?

 A) Pre-order
 B) Post-order
 C) Reverse in-order
 D) Level-order
Answer: C

80. The maximum height of a skewed BST with n nodes is:

 A) log n
 B) n
 C) n/2
 D) n²
Answer: B

Binary Search Tree (BST) – Questions 81 to 85

81. Which of the following causes a Binary Search Tree to degenerate into a linked list?

 A) Inserting sorted data


 B) Inserting random data
 C) Performing in-order traversal
 D) Using pre-order insertion
Answer: A

82. In a BST, the node with the smallest value is located at:

 A) The root
 B) The rightmost node
 C) The leftmost node
 D) The last inserted node
Answer: C
83. Deletion of a node with one child in a BST requires:

 A) Removing the node and connecting its child to its parent


 B) Only removing the node
 C) Deleting the entire subtree
 D) Performing rotations
Answer: A

84. Which traversal would result in a sorted descending order for a BST?

 A) In-order
 B) Pre-order
 C) Post-order
 D) Reverse in-order
Answer: D

85. Which one of the following BST operations takes O(log n) time in the best case?

 A) Insertion
 B) Search
 C) Deletion
 D) All of the above
Answer: D

V. Splay Trees (86–95)

86. A splay tree is a type of:

 A) Binary Heap
 B) AVL Tree
 C) Self-adjusting Binary Search Tree
 D) Threaded Tree
Answer: C

87. What is the main goal of a splay tree?

 A) Always balance the tree


 B) Reduce search time for recently accessed elements
 C) Store duplicate values
 D) Convert to AVL tree
Answer: B

88. Which operation causes restructuring in a splay tree?


 A) Insertion only
 B) Search only
 C) Any access (insert, delete, search)
 D) Only deletion
Answer: C

89. What technique is used in splay trees for restructuring?

 A) Rotation
 B) Swapping
 C) Mirroring
 D) Hashing
Answer: A

90. When a node is accessed in a splay tree, what happens?

 A) It is deleted
 B) It is moved to the root
 C) It is stored at the leaf
 D) It is ignored
Answer: B

91. Which rotation does zig-zig represent in splay trees?

 A) Single left rotation


 B) Single right rotation
 C) Double rotation in same direction
 D) Rotation in opposite direction
Answer: C

92. Splay trees maintain the amortized complexity of operations as:

 A) O(n)
 B) O(n log n)
 C) O(log n)
 D) O(1)
Answer: C

93. The average time complexity of search in a splay tree is:

 A) O(n)
 B) O(1)
 C) O(log n)
 D) O(n²)
Answer: C
94. A splay tree is efficient when:

 A) Data is accessed randomly


 B) Frequently accessed items are accessed repeatedly
 C) Used in stacks only
 D) Used for hash tables
Answer: B

95. What is the splaying operation in a splay tree?

 A) Deleting a node
 B) Rotating a node to the root
 C) Splitting the tree
 D) Rebalancing using height
Answer: B

VI. Mixed Applications & Conceptual (96–100)

96. Binary trees are used in:

 A) Compilers
 B) Databases
 C) File Systems
 D) All of the above
Answer: D

97. Which binary tree type is ideal for searching with minimal time?

 A) Skewed tree
 B) Splay tree
 C) Balanced BST
 D) AVL tree
Answer: D

98. Which of the following trees always remain balanced?

 A) Binary search tree


 B) AVL tree
 C) Expression tree
 D) Splay tree
Answer: B

99. Which tree is best when recent accesses are more likely to be repeated?
 A) AVL tree
 B) Binary search tree
 C) Splay tree
 D) B-tree
Answer: C

100. If the in-order traversal of a tree is A B C D and the pre-order is D B A C, what is


the root?

 A) A
 B) B
 C) C
 D) D
Answer: D

UNIT 4

Bubble Sort (1–10)

1. What is the average-case time complexity of bubble sort?


o A) O(n)
o B) O(n log n)
o C) O(n²)
o D) O(log n)
Answer: C
2. Bubble sort compares:
o A) Adjacent elements
o B) Every pair of elements
o C) First and last elements
o D) Middle elements
Answer: A
3. The worst-case time complexity of bubble sort is:
o A) O(n)
o B) O(n²)
o C) O(n log n)
o D) O(1)
Answer: B
4. The best case for bubble sort occurs when:
o A) Array is sorted in reverse
o B) Array is partially sorted
o C) Array is already sorted
o D) Array has duplicate elements
Answer: C
5. In bubble sort, how many passes are needed to sort an array of n elements in the worst
case?
o A) n
o B) n - 1
o C) log n
o D) 2n
Answer: B
6. Bubble sort is considered:
o A) Stable and adaptive
o B) Unstable and adaptive
o C) Stable and non-adaptive
o D) Unstable and non-adaptive
Answer: A
7. After the first pass of bubble sort, the largest element is:
o A) At the first position
o B) At the middle
o C) At the last position
o D) Not moved
Answer: C
8. Which of the following is true for optimized bubble sort?
o A) Uses recursion
o B) Uses a flag to detect no swaps
o C) Requires extra space
o D) Sorts in descending order only
Answer: B
9. Bubble sort is not suitable for:
o A) Small arrays
o B) Large datasets
o C) Sorted arrays
o D) Simple comparisons
Answer: B
10. Bubble sort is an example of:
o A) Divide and conquer algorithm
o B) Greedy algorithm
o C) Brute-force algorithm
o D) Comparison-based algorithm
Answer: D

Insertion Sort (11–20)

11. What is the average-case time complexity of insertion sort?

 A) O(n)
 B) O(n log n)
 C) O(n²)
 D) O(log n)
Answer: C
12. Insertion sort is best suited for:

 A) Large unsorted arrays


 B) Sorted or nearly sorted arrays
 C) Arrays with all elements equal
 D) Arrays with duplicates only
Answer: B

13. The worst-case time complexity of insertion sort is:

 A) O(n)
 B) O(n²)
 C) O(n log n)
 D) O(n³)
Answer: B

14. In insertion sort, the element is compared with:

 A) Next elements
 B) All elements
 C) Previous sorted elements
 D) Last element only
Answer: C

15. Which of the following is true about insertion sort?

 A) It is not stable
 B) It requires additional memory
 C) It is adaptive
 D) It is recursive
Answer: C

16. What is the best-case time complexity of insertion sort?

 A) O(n)
 B) O(n²)
 C) O(log n)
 D) O(n log n)
Answer: A

17. Insertion sort performs better than bubble sort for:

 A) Large datasets
 B) Small or nearly sorted datasets
 C) Random data
 D) Reversely sorted arrays
Answer: B

18. In insertion sort, the sorted section grows:

 A) From right to left


 B) From middle outwards
 C) From left to right
 D) In reverse order
Answer: C

19. In insertion sort, the number of comparisons in the worst case is:

 A) O(n)
 B) O(n log n)
 C) O(n²)
 D) O(log n)
Answer: C

20. Which of the following is a disadvantage of insertion sort?

 A) Not suitable for large datasets


 B) Complex implementation
 C) Requires a queue
 D) Unstable sort
Answer: A

You might also like