Font size
WorksheetsData Structures Full
Total questions: 90
Worksheet time: 45mins
Which data structure follows the First-In-First-Out (FIFO) principle?
Stack
Queue
Tree
Graph
In a stack, which operation adds an element to the top?
push
pop
peek
enqueue
What is the time complexity of accessing an element in a linked list?
O(1)
O(log n)
O(n)
O(n^2)
How many dimensions does a 2D array have?
1
2
3
4
Which tree traversal visits the root node last?
Preorder
Inorder
Postorder
Level order
What is the maximum number of edges in a simple graph with n vertices?
n
n-1
n(n-1)/2
2^n
Dijkstra's algorithm is used to find:
Minimum spanning tree
Shortest path
Longest path
Euler circuit
Which graph traversal uses a stack?
Breadth-First Search
Depth-First Search
Both
Neither
What is the time complexity of inserting an element at the end of a singly linked list?
O(1)
O(log n)
O(n)
O(n^2)
In a binary tree, what is the maximum number of children a node can have?
1
2
3
Unlimited
Which data structure is typically used to implement a breadth-first search?
Stack
Queue
Linked List
Array
What is the space complexity of storing a graph using an adjacency matrix?
O(V)
O(E)
O(V + E)
O(V^2)
In a min-heap, which element is always at the root?
Largest element
Smallest element
Middle element
Random element
What is the time complexity of accessing an element in a 2D array given its indices?
O(1)
O(n)
O(log n)
O(n^2)
What is the time complexity of accessing an element in an array?
O(1)
O(log n)
O(n)
O(n^2)
Which of the following is not a valid operation on a queue?
Enqueue
Dequeue
Peek
Push
In a doubly linked list, each node contains:
Only data
Data and one pointer
Data and two pointers
Only pointers
What is the time complexity of inserting an element into a binary search tree?
O(1)
O(log n)
O(n)
O(n^2)
Which graph traversal visits all vertices at the same level before moving to the next level?
Depth-First Search
Breadth-First Search
Preorder Traversal
Postorder Traversal
What is the primary advantage of using a linked list over an array?
Constant-time access to elements
Better cache locality
Dynamic size
Less memory usage
In Dijkstra's algorithm, what data structure is commonly used to select the next vertex?
Stack
Queue
Priority Queue
Linked List
What is the time complexity of the best-case scenario for bubble sort?
O(n)
O(n log n)
O(n^2)
O(1)
Which of the following is not a type of binary tree?
Full binary tree
Complete binary tree
Perfect binary tree
Circular binary tree
What is the maximum number of nodes in a binary tree of height h?
2^h
2^(h+1) - 1
h^2
2h
In a stack, which operation removes an element from the top?
push
pop
peek
enqueue
What is the time complexity of searching for an element in an unsorted linked list?
O(1)
O(log n)
O(n)
O(n^2)
Which of the following is not a property of a binary search tree?
The left subtree of a node contains only nodes with keys less than the node's key
The right subtree of a node contains only nodes with keys greater than the node's key
Both the left and right subtrees must be binary search trees
The tree must be balanced
What is the time complexity of inserting an element at the beginning of a singly linked list?
O(1)
O(log n)
O(n)
O(n^2)
In a 2D array, how are elements typically accessed?
array[column][row]
array[row][column]
array(row, column)
array.get(row, column)
Which of the following is not a valid graph representation?
Adjacency Matrix
Adjacency List
Edge List
Node Array
What is the time complexity of Dijkstra's algorithm using a binary heap?
O(V^2)
O(E log V)
O(V + E)
O(E + V log V)
In a binary tree, what is the relationship between the number of nodes (n) and the number of edges (e)?
e = n
e = n - 1
e = n + 1
Which of the following data structures can be used to check for balanced parentheses?
Queue
Stack
Linked List
Binary Tree
What is the time complexity of accessing the middle element in a singly linked list?
O(1)
O(log n)
O(n)
O(n^2)
In a graph, what is a vertex with no incoming edges called?
Leaf
Root
Source
Sink
Which of the following is not a property of a queue?
FIFO principle
Enqueue operation
Dequeue operation
LIFO principle
What is the space complexity of a singly linked list with n nodes?
O(1)
O(log n)
O(n)
O(n^2)
In a binary search tree, where is the smallest element located?
Root
Leftmost leaf
Rightmost leaf
Middle node
What is the time complexity of finding the degree of a vertex in a graph represented by an adjacency matrix?
O(1)
O(log V)
O(V)
O(E)
Which of the following is not a type of graph traversal?
Depth-First Search
Breadth-First Search
Binary Search
Topological Sort
What is the maximum number of edges in a tree with n nodes?
n
n - 1
n + 1
2n
Which data structure is most suitable for implementing an undo feature in a text editor?
Queue
Stack
Linked List
Binary Tree
What is the time complexity of inserting an element into a queue?
O(1)
O(log n)
O(n)
O(n^2)
In a 2D array, what does array[i][j] represent?
The element in the i-th column and j-th row
The element in the i-th row and j-th column
The sum of elements in row i and column j
The product of elements in row i and column j
Which of the following is not a balanced binary tree?
AVL tree
Red-Black tree
B-tree
Binary Search Tree
What is the time complexity of finding the shortest path between all pairs of vertices in a graph using Floyd-Warshall algorithm?
O(V^2)
O(V^3)
O(E log V)
O(V E)
In a linked list, what is the node that points to null called?
Head node
Tail node
Middle node
Sentinel node
Which of the following is true about a stack?
It follows FIFO principle
Elements are added at the rear
Elements are removed from the front
It follows LIFO principle
What is the time complexity of deleting an element from the middle of a doubly linked list?
O(1)
O(log n)
O(n)
O(n^2)
In a binary tree, a node with no children is called:
Root node
Leaf node
Internal node
Parent node
Which of the following is not a property of a minimum spanning tree?
It connects all vertices
It has no cycles
It has the minimum total edge weight
It always has a unique solution
What is the time complexity of finding an element in a binary search tree?
O(1)
O(log n)
O(n)
O(n^2)
In a graph, what is a vertex with no outgoing edges called?
Leaf
Root
Source
Sink
Which of the following data structures is most suitable for implementing a priority queue?
Array
Linked List
Heap
Stack
What is the time complexity of accessing an element in a circular queue?
O(1)
O(log n)
O(n)
O(n^2)
In a 2D array, how many elements are there in total if the array has m rows and n columns?
m + n
m * n
2(m + n)
m^n
Which of the following is not a valid operation on a binary search tree?
Insertion
Deletion
Search
Rotation
What is the primary advantage of using an adjacency list over an adjacency matrix for graph representation?
Faster edge weight updates
Constant-time edge existence check
Less memory usage for sparse graphs
Easier implementation
In Dijkstra's algorithm, what is used to keep track of the shortest known distance to each vertex?
Queue
Stack
Array
Hash table
What is the time complexity of reversing a singly linked list?
O(1)
O(log n)
O(n)
O(n^2)
Which of the following is true about a complete binary tree?
All levels are completely filled
All nodes have exactly two children
All levels except possibly the last are completely filled
It is always balanced
What is the maximum number of edges in a directed acyclic graph (DAG) with n vertices?
n
n - 1
n(n-1)/2
n(n-1)
Which of the following data structures is most suitable for implementing a cache with a "least recently used" (LRU) eviction policy?
Array
Stack
Queue
HashMap
What is the time complexity of finding the height of a binary tree?
O(1)
O(log n)
O(n)
O(n^2)
In a graph, what is a path that visits each vertex exactly once called?
Euler path
Hamilton path
Shortest path
Spanning tree
Which of the following is not a property of a red-black tree?
Every node is either red or black
The root is always black
Every leaf (NIL) is black
Red nodes always have two black children
What is the time complexity of the peek operation in a stack?
O(1)
O(log n)
O(n)
O(n^2)
In a binary tree, what is the maximum number of nodes at level i?
i
2^i
i^2
2i
Which of the following is not a valid way to implement a queue?
Array
Linked List
Stack
Circular Buffer
What is the time complexity of finding the in-degree of a vertex in a graph represented by an adjacency list?
O(1)
O(V)
O(E)
O(V + E)
In a min-heap, which of the following is always true?
The root is the largest element
The leaves are the smallest elements
Each node is smaller than its children
The tree is always balanced
What is the space complexity of Dijkstra's algorithm?
O(V)
O(E)
O(V^2)
O(V + E)
Which of the following data structures is most suitable for implementing a spell checker?
Array
Linked List
Trie
Stack
What is the time complexity of inserting an element at a given position in an array?
O(1)
O(log n)
O(n)
O(n^2)
In a graph, what is a cycle that visits each edge exactly once called?
Euler circuit
Hamilton circuit
Shortest cycle
Spanning cycle
Which of the following is not a property of a B-tree?
All leaves are at the same level
A node can have a maximum of 2 children
It is balanced
It is used in databases and file systems
What is the time complexity of the best case for quicksort?
O(n)
O(n log n)
O(n^2)
O(log n)
In a 2D array, what does array.shape represent in Python (assuming NumPy is used)?
The total number of elements
The number of rows
The number of columns
A tuple of (number of rows, number of columns)
Which of the following is true about a doubly linked list?
It uses less memory than a singly linked list
It allows for easier backward traversal
It has faster insertion at the beginning
It has constant time access to elements
What is the primary purpose of a hash table?
To sort elements
To provide fast insertion and lookup
To maintain a balanced tree structure
To implement graph algorithms
What is the time complexity of the union-find operation with path compression and union by rank?
O(1)
O(log n)
O(α(n)), where α is the inverse Ackermann function
O(n)
Which of the following is not a valid tree traversal method?
Preorder
Inorder
Postorder
Middleorder
What is the primary advantage of using a circular queue over a simple queue?
It uses less memory
It allows for faster enqueue operations
It prevents queue overflow by wrapping around
It provides constant time access to all elements
In graph theory, what is a tree?
A connected graph with no cycles
A disconnected graph with cycles
A connected graph with exactly one cycle
A graph with multiple roots
What is the time complexity of finding the kth smallest element in a binary search tree?
O(1)
O(log n)
O(k)
O(n)
Which of the following is true about a stack implemented using an array?
It can never overflow
It has a fixed maximum size
It allows random access to elements
It uses less memory than a linked list implementation
What is the primary purpose of a sentinel node in a linked list?
To mark the beginning of the list
To simplify boundary conditions in algorithms
To increase the speed of traversal
To reduce memory usage
In a max-heap, what is the relationship between a node at index i and its children?
The node is smaller than its children
The node is larger than its children
The node is equal to its children
There is no specific relationship
What is the time complexity of finding all connected components in an undirected graph?
O(V)
O(E)
O(V + E)
O(V * E)
Which of the following data structures is most suitable for implementing a filesystem directory structure?
Array
Linked list
Tree
Stack
