Question : What is the time complexity of searching for an element in an unsorted array using linear search?
O(1)
O(log n)
O(n)
O(n^2)
Correct Answer : O(n)
Question : Which of the following is true about arrays in most programming languages?
Arrays can store elements of different data types.
Arrays can automatically resize themselves when elements are added or removed.
Elements in an array must be of the same data type.
Arrays are immutable.
Correct Answer : Elements in an array must be of the same data type.
Question : What is the time complexity of inserting an element at the end of an array (assuming enough space is available)?
O(1)
O(log n)
O(n)
O(n^2)
Correct Answer : O(1)
Question : In a 2D array with dimensions m x n, what is the formula to calculate the index of an element at position (i, j)?
i * n + j
i + j
i * m + j
i * j
Correct Answer : i * n + j
Question : Which of the following operations on arrays can be performed in constant time?
Accessing an element by index
Removing an element from the middle
Finding the maximum element
Reversing the array
Correct Answer : Accessing an element by index
Question : What is the time complexity of sorting an array using the bubble sort algorithm?
O(1)
O(log n)
O(n)
O(n^2)
Correct Answer : O(n^2)
Question : Which data structure is typically used to implement arrays with dynamic resizing in many programming languages?
Linked List
Hash Table
Stack
Heap
Correct Answer : Linked List
Question : What is the space complexity of an array with n elements?
O(1)
O(n)
O(log n)
O(n^2)
Correct Answer : O(n)
Question : Which of the following statements is true about arrays?
Arrays can shrink in size dynamically.
Inserting an element at the beginning of an array is always efficient.
Arrays are a primitive data type in most programming languages.
Arrays can only store a fixed number of elements.
Correct Answer : Arrays can only store a fixed number of elements.
Question : What is the time complexity of removing an element from the middle of an array (assuming no resizing is required)?
O(1)
O(log n)
O(n)
O(n^2)
Correct Answer : O(n)
Question : Which of the following operations in a singly linked list requires traversal of the entire list?
Inserting an element at the beginning
Deleting an element from the end
Accessing an element by index
Inserting an element at the end
Correct Answer : Accessing an element by index
Question : In a doubly linked list, each node contains how many pointers/references?
One
Two
Three
Four
Correct Answer : Two
Question : Which of the following is true about a circular linked list?
It cannot contain a NULL reference.
It contains a loop within its structure.
It is always a doubly linked list.
It has a fixed size.
Correct Answer : It cannot contain a NULL reference.
Question : Which operation in a linked list requires the most time, assuming a singly linked list without a tail pointer?
Inserting an element at the beginning
Deleting an element from the end
Accessing an element by index
Traversing the entire list
Correct Answer : Deleting an element from the end
Question : 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)
Correct Answer : O(1)
Question : In a doubly linked list, what operation can be performed in constant time compared to a singly linked list?
Inserting an element at the end
Deleting an element from the middle
Accessing an element by index
Traversing the list from beginning to end
Correct Answer : Deleting an element from the middle
Question : Which of the following statements is true about a singly linked list?
It allows traversal in both directions.
It requires less memory than a doubly linked list.
It always contains a tail pointer.
It allows constant-time access to any element by index.
Correct Answer : It requires less memory than a doubly linked list.
Question : What is the space complexity of a linked list with n elements?
O(1)
O(log n)
O(n)
O(n^2)
Correct Answer : O(n)
Question : Which of the following operations can be performed in constant time in both singly and doubly linked lists?
Inserting an element at the end
Deleting an element from the beginning
Accessing an element by index
Traversing the list from beginning to end
Correct Answer : Deleting an element from the beginning
Question : In a singly linked list, what is the time complexity of deleting an element from the middle, given a pointer to the element to be deleted?
O(1)
O(log n)
O(n)
O(n^2)
Correct Answer : O(1)
Question : Which of the following data structures follows the Last In, First Out (LIFO) principle?
Queue
Stack
Linked List
Binary Tree
Correct Answer : Stack
Question : What is the time complexity of the push operation in a stack implemented using an array?
O(1)
O(log n)
O(n)
O(n^2)
Correct Answer : O(1)
Question : Which of the following operations is not typically associated with stacks?
Push
Pop
Enqueue
Peek
Correct Answer : Enqueue
Question : In stack terminology, what is the term used for removing an element from the stack?
Pop
Push
Peek
Dequeue
Correct Answer : Pop
Question : Which of the following is an example of a real-world application of stacks?
Managing a playlist in a music player
Sorting algorithms
Hash tables
Breadth-first search
Correct Answer : Managing a playlist in a music player
Question : What happens when you try to pop an element from an empty stack?
Stack becomes full
Program crashes
NULL value is returned
Stack remains unchanged
Correct Answer : Program crashes
Question : Which of the following stack operations retrieves the top element without removing it?
Pop
Push
Peek
Empty
Correct Answer : Peek
Question : Which data structure can be used to implement a stack efficiently?
Array
Linked List
Binary Tree
Hash Table
Correct Answer : Linked List
Question : What is the space complexity of a stack with n elements?
O(1)
O(log n)
O(n)
O(n^2)
Correct Answer : O(n)
Question : In stack terminology, what is the term used for checking if the stack is empty?
Empty
Full
Peek
Pop
Correct Answer : Empty
Question : Which of the following data structures follows the First In, First Out (FIFO) principle?
Stack
Queue
Linked List
Binary Tree
Correct Answer : Queue
Question : What is the time complexity of the enqueue operation in a queue implemented using an array?
O(1)
O(log n)
O(n)
O(n^2)
Correct Answer : O(1)
Question : Which of the following operations is not typically associated with queues?
Enqueue
Dequeue
Pop
Peek
Correct Answer : Pop
Question : In queue terminology, what is the term used for removing an element from the queue?
Pop
Push
Dequeue
Peek
Correct Answer : Dequeue
Question : Which of the following is an example of a real-world application of queues?
Undo functionality in text editors
Sorting algorithms
Binary search trees
Depth-first search
Correct Answer : Undo functionality in text editors
Question : What happens when you try to dequeue an element from an empty queue?
Queue becomes full
Program crashes
NULL value is returned
Queue remains unchanged
Correct Answer : Program crashes
Question : Which of the following queue operations retrieves the front element without removing it?
Dequeue
Enqueue
Peek
Empty
Correct Answer : Peek
Question : Which data structure can be used to implement a queue efficiently?
Array
Linked List
Binary Tree
Hash Table
Correct Answer : Linked List
Question : What is the space complexity of a queue with n elements?
O(1)
O(log n)
O(n)
O(n^2)
Correct Answer : O(n)
Question : In queue terminology, what is the term used for checking if the queue is empty?
Empty
Full
Peek
Dequeue
Correct Answer : Empty
Question : In a binary tree, what is the maximum number of children that a node can have?
0
1
2
Unlimited
Correct Answer : 2
Question : Which of the following trees guarantees balanced height, ensuring efficient search, insert, and delete operations?
AVL Tree
Binary Search Tree (BST)
B-Tree
Trie
Correct Answer : AVL Tree
Question : What is the height of a tree with only one node?
0
1
2
Undefined
Correct Answer : 0
Question : Which traversal method visits the root node before its children?
Preorder
Inorder
Postorder
Level-order
Correct Answer : Preorder
Question : In a binary search tree (BST), what is the time complexity of searching for an element?
O(1)
O(log n)
O(n)
O(n^2)
Correct Answer : O(log n)
Question : Which of the following trees allows duplicate values in its nodes?
AVL Tree
Binary Search Tree (BST)
B-Tree
Heap
Correct Answer : Binary Search Tree (BST)
Question : What is the maximum number of nodes at height h in a binary tree?
2^h
h
h + 1
2^(h+1) - 1
Correct Answer : 2^h
Question : Which traversal method visits the root node after its children?
Preorder
Inorder
Postorder
Level-order
Correct Answer : Postorder
Question : Which of the following trees is commonly used for representing sorted dictionaries?
AVL Tree
Binary Search Tree (BST)
B-Tree
Trie
Correct Answer : Binary Search Tree (BST)
Question : What is the time complexity of inserting an element into a binary search tree (BST) of height h?
O(1)
O(log n)
O(n)
O(h)
Correct Answer : O(h)
Question : How many children can a node have in a binary tree?
0
1
2
Unlimited
Correct Answer : 2
Question : What is the maximum number of nodes at level 'd' in a binary tree?
d
2^d
2^(d-1)
2^d - 1
Correct Answer : 2^d
Question : In a binary tree, which traversal visits the root node between its left and right sub-trees?
Preorder
Inorder
Postorder
Level-order
Correct Answer : Preorder
Question : What is the maximum height of a binary tree with 'n' nodes?
n
log n
n - 1
log(n+1)
Correct Answer : n
Question : In a binary tree, which traversal visits the root node after its left and right sub-trees?
Preorder
Inorder
Postorder
Level-order
Correct Answer : Postorder
Question : Which of the following statements about binary trees is true?
Every binary tree is a binary search tree (BST).
Binary trees cannot have more than two children for any node.
Binary trees always have a fixed height.
In a binary tree, the left subtree contains values greater than the root.
Correct Answer : Binary trees cannot have more than two children for any node.
Question : In a complete binary tree with 'n' nodes, what is the maximum height?
log(n+1)
log(n)
n
n-1
Correct Answer : log(n)
Question : Which traversal method can be used to create a copy of a binary tree?
Preorder
Inorder
Postorder
Level-order
Correct Answer : Preorder
Question : In a binary tree, what is the maximum number of leaf nodes?
log(n)
n
n/2
n-1
Correct Answer : n/2
Question : What is the time complexity of finding the height of a binary tree with 'n' nodes?
O(1)
O(log n)
O(n)
O(n log n)
Correct Answer : O(n)
Question : In a binary search tree (BST), which property holds true for all nodes in the left subtree of a node 'X'?
All nodes have values greater than 'X'.
All nodes have values less than 'X'.
All nodes have values greater than or equal to 'X'.
All nodes have values less than or equal to 'X'.
Correct Answer : All nodes have values less than 'X'.
Question : What is the minimum number of levels in a binary search tree (BST) with 'n' nodes?
log(n)
log(n+1)
n
n-1
Correct Answer : log(n)
Question : In a binary search tree (BST), which traversal method visits the nodes in ascending order?
Preorder
Inorder
Postorder
Level-order
Correct Answer : Inorder
Question : What is the time complexity of searching for an element in a binary search tree (BST) with 'n' nodes?
O(1)
O(log n)
O(n)
O(n log n)
Correct Answer : O(log n)
Question : Which of the following operations can be performed in constant time in a binary search tree (BST)?
Insertion
Deletion
Search
Traversal
Correct Answer : Search
Question : In a binary search tree (BST), which property holds true for all nodes in the right subtree of a node 'X'?
All nodes have values greater than 'X'.
All nodes have values less than 'X'.
All nodes have values greater than or equal to 'X'.
All nodes have values less than or equal to 'X'.
Correct Answer : All nodes have values greater than 'X'.
Question : Which traversal method can be used to obtain the nodes in descending order in a binary search tree (BST)?
Preorder
Inorder
Postorder
Level-order
Correct Answer : Postorder
Question : In a binary search tree (BST), which operation is used to remove a node with two children?
Rotation
Transplant
Insertion
Deletion
Correct Answer : Transplant
Question : What is the time complexity of inserting an element into a binary search tree (BST) with 'n' nodes?
O(1)
O(log n)
O(n)
O(n log n)
Correct Answer : O(log n)
Question : In a binary search tree (BST), what is the time complexity of finding the minimum or maximum element?
O(1)
O(log n)
O(n)
O(n log n)
Correct Answer : O(log n)
Question : Which of the following trees is self-balancing and guarantees logarithmic height?
AVL Tree
Binary Search Tree (BST)
B-Tree
Red-Black Tree
Correct Answer : AVL Tree
Question : In a balanced binary search tree (BST), what is the maximum height for 'n' nodes?
log(n)
log(n+1)
n
n-1
Correct Answer : log(n)
Question : Which rebalancing operation is performed in an AVL tree to restore balance after an insertion or deletion?
Rotation
Transplant
Splay
Split
Correct Answer : Rotation
Question : What is the time complexity of searching for an element in a balanced binary search tree (BST) with 'n' nodes?
O(1)
O(log n)
O(n)
O(n log n)
Correct Answer : O(log n)
Question : Which of the following operations can be performed in constant time in a balanced binary search tree (BST)?
Insertion
Deletion
Search
Traversal
Correct Answer : Search
Question : In a Red-Black tree, what property ensures that the longest path from the root to any leaf is no more than twice the shortest path?
Black Height Property
Red Height Property
Red-Black Height Property
Balanced Height Property
Correct Answer : Black Height Property
Question : Which of the following trees is commonly used for implementing databases and file systems?
AVL Tree
B-Tree
Red-Black Tree
Splay Tree
Correct Answer : B-Tree
Question : In a B-Tree, what is the minimum number of children for a non-root internal node?
0
1
2
3
Correct Answer : 1
Question : What is the time complexity of inserting an element into a balanced binary search tree (BST) with 'n' nodes?
O(1)
O(log n)
O(n)
O(n log n)
Correct Answer : O(log n)
Question : Which balanced tree data structure adjusts itself during operations to maintain balance, avoiding the need for explicit rebalancing?
AVL Tree
Red-Black Tree
B-Tree
Splay Tree
Correct Answer : Splay Tree
Question : What type of tree structure is a heap?
Binary Tree
Balanced Tree
B-Tree
Red-Black Tree
Correct Answer : Binary Tree
Question : In a max-heap, what property holds true for each node?
The value of the node is greater than its parent's value.
The value of the node is less than its parent's value.
The value of the node is equal to its parent's value.
The value of the node is less than or equal to its parent's value.
Correct Answer : The value of the node is greater than its parent's value.
Question : What is the height of a heap with 'n' elements?
log(n)
log(n+1)
n
n-1
Correct Answer : log(n)
Question : Which operation maintains the heap property after inserting an element into a heap?
Percolate Up
Percolate Down
Heapify
Sift Up
Correct Answer : Percolate Up
Question : What is the time complexity of inserting an element into a heap with 'n' elements?
O(1)
O(log n)
O(n)
O(n log n)
Correct Answer : O(log n)
Question : Which type of heap allows both the maximum and minimum elements to be efficiently retrieved?
Max-Heap
Min-Heap
Binary Heap
Fibonacci Heap
Correct Answer : Binary Heap
Question : In a min-heap, what property holds true for each node?
The value of the node is greater than its parent's value.
The value of the node is less than its parent's value.
The value of the node is equal to its parent's value.
The value of the node is less than or equal to its parent's value.
Correct Answer : The value of the node is less than its parent's value.
Question : Which operation removes and returns the maximum element from a max-heap?
Percolate Up
Percolate Down
Extract Max
Extract Min
Correct Answer : Extract Max
Question : What is the space complexity of a heap with 'n' elements?
O(1)
O(log n)
O(n)
O(n log n)
Correct Answer : O(n)
Question : Which heap operation restores the heap property after removing the maximum (or minimum) element from a heap?
Percolate Up
Percolate Down
Heapify
Sift Down
Correct Answer : Percolate Down
Question : Which of the following data structures is commonly used to represent graphs?
Array
Stack
Queue
Adjacency List
Correct Answer : Adjacency List
Question : What does the term "degree" refer to in a graph?
The number of vertices in the graph
The number of edges incident to a vertex
The number of edges in the graph
The number of connected components in the graph
Correct Answer : The number of edges incident to a vertex
Question : Which of the following graph traversal algorithms uses a queue data structure?
Depth-First Search (DFS)
Breadth-First Search (BFS)
Dijkstra's Algorithm
Prim's Algorithm
Correct Answer : Breadth-First Search (BFS)
Question : What is the time complexity of Breadth-First Search (BFS) in a graph with 'V' vertices and 'E' edges?
O(V)
O(E)
O(V + E)
O(V * E)
Correct Answer : O(V + E)
Question : Which of the following statements about Directed Acyclic Graphs (DAGs) is true?
DAGs can have cycles.
Topological sorting is not possible in DAGs.
DAGs are always connected.
DAGs have a linear ordering of vertices.
Correct Answer : DAGs have a linear ordering of vertices.
Question : Which graph algorithm is used to find the shortest path between two vertices in a weighted graph?
Depth-First Search (DFS)
Breadth-First Search (BFS)
Dijkstra's Algorithm
Bellman-Ford Algorithm
Correct Answer : Dijkstra's Algorithm
Question : Which of the following statements about Depth-First Search (DFS) is true?
DFS always finds the shortest path between two vertices.
DFS can be used to detect cycles in a graph.
DFS requires a queue data structure.
DFS is an example of a greedy algorithm.
Correct Answer : DFS can be used to detect cycles in a graph.
Question : What is the time complexity of Depth-First Search (DFS) in a graph with 'V' vertices and 'E' edges?
O(V)
O(E)
O(V + E)
O(V * E)
Correct Answer : O(V + E)
Question : Which of the following graph algorithms is used to find the minimum spanning tree of a weighted graph?
Dijkstra's Algorithm
Prim's Algorithm
Bellman-Ford Algorithm
Kruskal's Algorithm
Correct Answer : Kruskal's Algorithm
Question : What does the term "connected graph" refer to?
A graph with no edges
A graph with no vertices
A graph in which every pair of vertices is connected by a path
A graph with only one vertex
Correct Answer : A graph in which every pair of vertices is connected by a path
Question : What is the average time complexity of search, insertion, and deletion operations in a hash table with chaining?
O(1)
O(log n)
O(n)
O(n log n)
Correct Answer : O(1)
Question : Which of the following data structures is typically used to implement hash tables?
Array
Linked List
Binary Search Tree
Heap
Correct Answer : Array
Question : What is the term used to describe a situation where two distinct keys hash to the same index in a hash table?
Collision
Hashing
Probing
Load factor
Correct Answer : Collision
Question : Which collision resolution technique involves appending collided elements to the same index in a separate data structure?
Separate Chaining
Linear Probing
Quadratic Probing
Double Hashing
Correct Answer : Separate Chaining
Question : What is the term used to describe the ratio of the number of stored elements to the size of the hash table?
Collision Rate
Load Factor
Hash Rate
Collision Factor
Correct Answer : Load Factor
Question : Which of the following collision resolution techniques may cause clustering in a hash table?
Separate Chaining
Linear Probing
Quadratic Probing
Double Hashing
Correct Answer : Linear Probing
Question : Which collision resolution technique involves rehashing and incrementing the hash value by a constant value if a collision occurs?
Separate Chaining
Linear Probing
Quadratic Probing
Double Hashing
Correct Answer : Quadratic Probing
Question : What is the worst-case time complexity of search, insertion, and deletion operations in a hash table?
O(1)
O(log n)
O(n)
O(n log n)
Correct Answer : O(n)
Question : Which of the following factors can affect the performance of a hash table?
Load Factor
Size of the input
Number of collisions
All of the above
Correct Answer : All of the above
Question : Which of the following is not a common method for handling collisions in hash tables?
Separate Chaining
Linear Probing
Quadratic Probing
Binary Search
Correct Answer : Binary Search
Featured
DSA Interview Question
Question: Various S orting algorithms Answer: There are various sorting algorithms, each with its own advantages and disadvantages in terms ...
Subscribe to:
Post Comments (Atom)
popular posts
-
Question: What is WebDriverIO? Answer: WebDriverIO is a Node.js library that provides a WebDriver API implementation for web automation. It ...
-
Question : Which command is used to maximize the browser window in WebdriverIO? browser.maximizeWindow() browser.maximize() browser.windowMa...
-
There are thousands of cryptocurrencies available in addition to Bitcoin. Here are some notable examples: 1. Ethereum (ETH): Ethereum is th...
No comments:
Post a Comment