Data Structures MCQs - Linked List, Stack and Queue (Set 1)

Data Structures MCQs - Linked List, Stack and Queue (Set 1) - CodingHumans

Practise the three linear data structures that show up in almost every coding interview and university exam: linked lists, stacks and queues. Each question checks one idea - time complexity, pointer updates, or which structure fits a problem.

How to practise: read each question and tap the option you think is correct. You will see right away whether you got it, along with a short explanation, and your score is tracked at the bottom of the screen. This set has 16 questions.

Q1. What is the time complexity of inserting a new node at the head of a singly linked list?

a) O(1)

b) O(log n)

c) O(n)

d) O(n log n)

Q2. In a singly linked list with only a head pointer, deleting the last node takes:

a) O(1)

b) O(n)

c) O(log n)

d) O(n^2)

Q3. Which operation is faster in a doubly linked list than in a singly linked list, given a pointer to the node?

a) Searching for a value

b) Deleting that node

c) Inserting at the head

d) Counting the nodes

Q4. Floyd's cycle detection algorithm uses:

a) A hash set of visited nodes

b) Two pointers moving at different speeds

c) Recursion with a stack

d) Sorting the node addresses

Q5. What does the following function return for the list 1 -> 2 -> 3 -> 4 -> 5?

Node f(Node head) {
    Node slow = head, fast = head;
    while (fast != null && fast.next != null) {
        slow = slow.next;
        fast = fast.next.next;
    }
    return slow;
}

a) Node 2

b) Node 3

c) Node 4

d) Node 5

Q6. In a circular singly linked list, the next pointer of the last node points to:

a) NULL

b) Itself

c) The first node

d) The second-last node

Q7. A stack follows which order?

a) FIFO

b) LIFO

c) Priority order

d) Random order

Q8. Starting with an empty stack, the operations push(1), push(2), pop(), push(3), push(4), pop(), pop() are performed. What is left on the stack?

a) 1

b) 1, 3

c) 3

d) Empty stack

Q9. What is the postfix form of the infix expression A + B * C?

a) A B C * +

b) A B + C *

c) + A * B C

d) A B C + *

Q10. Evaluate the postfix expression 6 2 3 + * 4 -

a) 26

b) 16

c) 30

d) 11

Q11. Which data structure does the system use to manage function calls and recursion?

a) Queue

b) Heap

c) Stack

d) Hash table

Q12. A queue is implemented with an array of size N as a circular queue using front and rear indexes. The rear index after an insertion is updated as:

a) rear = rear + 1

b) rear = (rear + 1) % N

c) rear = (rear - 1) % N

d) rear = front + 1

Q13. Which data structure is the natural choice for Breadth-First Search (BFS) of a graph?

a) Stack

b) Queue

c) Priority queue

d) Linked list sorted by value

Q14. How many stacks are needed, at minimum, to implement a queue?

a) 1

b) 2

c) 3

d) A queue cannot be built from stacks

Q15. A deque (double-ended queue) allows:

a) Insertion and deletion only at the rear

b) Insertion at the rear and deletion at the front only

c) Insertion and deletion at both ends

d) Access only to the middle element

Q16. What is the worst-case time to search for a value in an unsorted singly linked list of n nodes?

a) O(1)

b) O(log n)

c) O(n)

d) O(n^2)

Recommended MCQs

More Data Structures posts on CodingHumans

All MCQ sets

MCQ Practice hub - every subject in one place

Comments

Answered 0/0Correct 0