Computer

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²)

Answer
c) O(1)

Which of the following data structures allows insertion and deletion at both ends?
a) Queue
b) Stack
c) Deque
d) Linked List

Answer
c) Deque

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²)

Answer
a) O(1)

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

Answer
a) Fixed size

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

Answer
b) Stack

Which operation has a time complexity of O(1) in both stack and queue?
a) Insertion
b) Deletion
c) Search
d) Access

Answer
b) Deletion

In a doubly linked list, how many references does each node have?
a) One
b) Two
c) Three
d) Four

Answer
b) Two

What is the space complexity of an array of size n?
a) O(1)
b) O(log n)
c) O(n)
d) O(n²)

Answer
c) 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

Answer
b) Queue

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

Answer
b) Nodes are only connected in one direction

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

Answer
c) Dynamic memory allocation

In a stack, which operation removes the element from the top of the stack?
a) Pop
b) Push
c) Peek
d) Enqueue

Answer
a) Pop

Which data structure is used for implementing recursion?
a) Queue
b) Stack
c) Linked List
d) Array

Answer
b) Stack

In a queue, where does the insertion of elements occur?
a) Front
b) Rear
c) Both front and rear
d) Any position

Answer
b) Rear

Which of the following data structures uses a “FIFO” (First In First Out) strategy?
a) Stack
b) Queue
c) Linked List
d) Array

Answer
b) Queue

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²)

Answer
c) 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

Answer
b) No null pointer at the end

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

Answer
c) Returns the top element without removing it

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

Answer
b) Limited access to elements

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

Answer
b) Each node has references to both the next and previous nodes

Which operation in a queue has a time complexity of O(1)?
a) Enqueue
b) Dequeue
c) Peek
d) Access

Answer
b) Dequeue

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²)

Answer
a) O(1)

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²)

Answer
c) 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

Answer
a) Fixed size

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

Answer
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²)

Answer
a) O(1)

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

Answer
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

Answer
c) Stack

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button