Data Structures: Arrays, Linked Lists, Stacks & Queues MCQs with Answers
What is the time complexity of accessing an element in an array by index?
a) O(n)
b) O(log n)
c) O(1)
d) O(n²)
Which of the following data structures allows insertion and deletion at both ends?
a) Queue
b) Stack
c) Deque
d) Linked List
In a linked list, what is the time complexity for inserting an element at the beginning?
a) O(1)
b) O(n)
c) O(log n)
d) O(n²)
What is the primary disadvantage of using an array over a linked list?
a) Fixed size
b) Slow access time
c) Complexity in deletion
d) Complexity in insertion
Which of the following data structures is based on the LIFO (Last In First Out) principle?
a) Queue
b) Stack
c) Linked List
d) Array
Which operation has a time complexity of O(1) in both stack and queue?
a) Insertion
b) Deletion
c) Search
d) Access
In a doubly linked list, how many references does each node have?
a) One
b) Two
c) Three
d) Four
What is the space complexity of an array of size n?
a) O(1)
b) O(log n)
c) O(n)
d) O(n²)
In which data structure is the front element removed and a new element is added at the rear?
a) Stack
b) Queue
c) Linked List
d) Array
Which of the following is a characteristic of a singly linked list?
a) Nodes contain two references: one to the next node and one to the previous node
b) Nodes are only connected in one direction
c) Nodes are not connected in any order
d) Nodes are arranged in contiguous memory blocks
What is the main advantage of a linked list over an array?
a) Faster search times
b) Easier to implement
c) Dynamic memory allocation
d) Less memory usage
In a stack, which operation removes the element from the top of the stack?
a) Pop
b) Push
c) Peek
d) Enqueue
Which data structure is used for implementing recursion?
a) Queue
b) Stack
c) Linked List
d) Array
In a queue, where does the insertion of elements occur?
a) Front
b) Rear
c) Both front and rear
d) Any position
Which of the following data structures uses a “FIFO” (First In First Out) strategy?
a) Stack
b) Queue
c) Linked List
d) Array
What is the time complexity of accessing an element in a linked list?
a) O(1)
b) O(log n)
c) O(n)
d) O(n²)
What is the advantage of a circular linked list over a singly linked list?
a) Faster access
b) No null pointer at the end
c) Better memory utilization
d) Easier insertion and deletion
In a stack, what does the peek operation do?
a) Pushes an element onto the stack
b) Removes the top element
c) Returns the top element without removing it
d) Clears the stack
What is the primary disadvantage of using a queue?
a) Elements are stored in contiguous memory locations
b) Limited access to elements
c) It can only be used for small datasets
d) It has a high overhead for dynamic resizing
Which of the following is true about a doubly linked list?
a) Each node has a reference to the next node only
b) Each node has references to both the next and previous nodes
c) Each node is connected in a circular manner
d) It is slower than a singly linked list in all operations
Which operation in a queue has a time complexity of O(1)?
a) Enqueue
b) Dequeue
c) Peek
d) Access
What is the worst-case time complexity of inserting an element at the beginning of a singly linked list?
a) O(1)
b) O(n)
c) O(log n)
d) O(n²)
What is the space complexity of a singly linked list with n nodes?
a) O(1)
b) O(log n)
c) O(n)
d) O(n²)
Which of the following is a disadvantage of using an array as a data structure?
a) Fixed size
b) Efficient memory utilization
c) Easy insertion and deletion
d) Random access to elements
Which of the following is an example of an operation performed by a stack?
a) Add an element at the front
b) Remove an element from the rear
c) Insert an element at the rear
d) Push an element onto the stack
What is the time complexity of deleting an element from the front of a queue implemented using a linked list?
a) O(1)
b) O(n)
c) O(log n)
d) O(n²)
Which of the following operations is performed in O(1) time for a stack implemented using an array?
a) Insertion
b) Deletion
c) Peek
d) Insertion and Deletion
Which data structure is often used to implement function calls in recursion?
a) Queue
b) Linked List
c) Stack
d) Array