Q. Which of the following is true about the balancing of AVL trees?
A.
They require rotations to maintain balance after insertions and deletions.
B.
They do not require any balancing.
C.
They can only be balanced by deleting nodes.
D.
They are always balanced after every insertion.
Show solution
Solution
AVL trees require rotations to maintain balance after insertions and deletions to ensure that the balance factor remains within the allowed range.
Correct Answer:
A
— They require rotations to maintain balance after insertions and deletions.
Learn More →
Q. Which of the following is true about the height of a binary tree with n nodes?
A.
Height = n
B.
Height = log n
C.
Height <= n
D.
Height = n/2
Show solution
Solution
The height of a binary tree with n nodes can be at most n in the case of a skewed tree, hence Height <= n.
Correct Answer:
C
— Height <= n
Learn More →
Q. Which of the following is true about the height of a binary tree?
A.
Height is the number of nodes in the longest path from root to leaf
B.
Height is the number of edges in the longest path from root to leaf
C.
Height is always equal to the number of levels in the tree
D.
Height can be negative
Show solution
Solution
The height of a binary tree is defined as the number of edges in the longest path from the root to a leaf node.
Correct Answer:
B
— Height is the number of edges in the longest path from root to leaf
Learn More →
Q. Which of the following is true about the height of a Red-Black tree?
A.
It can be at most twice the height of an AVL tree.
B.
It is always equal to the height of a binary search tree.
C.
It is always less than or equal to log(n).
D.
It can be greater than the height of an AVL tree.
Show solution
Solution
The height of a Red-Black tree can be at most twice the height of an AVL tree, making it less balanced.
Correct Answer:
A
— It can be at most twice the height of an AVL tree.
Learn More →
Q. Which of the following is true about the inorder traversal of a binary search tree?
A.
It visits nodes in random order.
B.
It visits nodes in descending order.
C.
It visits nodes in ascending order.
D.
It visits only the leaf nodes.
Show solution
Solution
Inorder traversal of a binary search tree visits nodes in ascending order.
Correct Answer:
C
— It visits nodes in ascending order.
Learn More →
Q. Which of the following is true about the level-order traversal of a binary tree?
A.
It is depth-first
B.
It uses a stack
C.
It visits nodes level by level
D.
It is faster than in-order traversal
Show solution
Solution
Level-order traversal visits nodes level by level, typically implemented using a queue.
Correct Answer:
C
— It visits nodes level by level
Learn More →
Q. Which of the following is true about the performance of AVL trees?
A.
Faster than Red-Black Trees for all operations
B.
Slower than Red-Black Trees for all operations
C.
Faster for search operations but slower for insertions
D.
Slower for search operations but faster for insertions
Show solution
Solution
AVL trees provide faster search operations due to their stricter balancing, but they can be slower for insertions and deletions because they may require more rotations.
Correct Answer:
C
— Faster for search operations but slower for insertions
Learn More →
Q. Which of the following methods can be used to determine the optimal number of clusters in K-means?
A.
Elbow method
B.
Silhouette analysis
C.
Gap statistic
D.
All of the above
Show solution
Solution
All of the mentioned methods (Elbow method, Silhouette analysis, and Gap statistic) can be used to determine the optimal number of clusters in K-means.
Correct Answer:
D
— All of the above
Learn More →
Q. Which of the following methods can be used to evaluate the quality of clusters formed by K-means?
A.
Silhouette score
B.
Davies-Bouldin index
C.
Both A and B
D.
None of the above
Show solution
Solution
Both the Silhouette score and the Davies-Bouldin index are methods used to evaluate the quality of clusters formed by K-means.
Correct Answer:
C
— Both A and B
Learn More →
Q. Which of the following metrics is commonly used to evaluate the performance of a linear regression model?
A.
Accuracy
B.
F1 Score
C.
Mean Squared Error (MSE)
D.
Confusion Matrix
Show solution
Solution
Mean Squared Error (MSE) is a common metric used to evaluate the performance of regression models by measuring the average squared difference between predicted and actual values.
Correct Answer:
C
— Mean Squared Error (MSE)
Learn More →
Q. Which of the following metrics is commonly used to evaluate the performance of a Decision Tree?
A.
Mean Squared Error
B.
Accuracy
C.
Silhouette Score
D.
F1 Score
Show solution
Solution
Accuracy is a common metric for evaluating the performance of classification Decision Trees.
Correct Answer:
B
— Accuracy
Learn More →
Q. Which of the following metrics is NOT typically used to evaluate clustering performance?
A.
Silhouette score
B.
Adjusted Rand Index
C.
Mean Squared Error
D.
Davies-Bouldin Index
Show solution
Solution
Mean Squared Error is not typically used to evaluate clustering performance; it is more relevant for regression tasks.
Correct Answer:
C
— Mean Squared Error
Learn More →
Q. Which of the following modifications can be made to binary search to find the first occurrence of a target value?
A.
Change the comparison operator
B.
Use a different data structure
C.
Modify the mid-point calculation
D.
Continue searching left after finding the target
Show solution
Solution
To find the first occurrence, continue searching to the left even after finding the target value.
Correct Answer:
D
— Continue searching left after finding the target
Learn More →
Q. Which of the following operations can be performed in constant time on a queue?
A.
Enqueue
B.
Dequeue
C.
Peek
D.
All of the above
Show solution
Solution
All of the operations (Enqueue, Dequeue, and Peek) can be performed in constant time, O(1), in a properly implemented queue.
Correct Answer:
D
— All of the above
Learn More →
Q. Which of the following operations can be performed in constant time on an array?
A.
Insertion at end
B.
Deletion from beginning
C.
Accessing an element
D.
Insertion at beginning
Show solution
Solution
Accessing an element in an array by its index is done in constant time, O(1).
Correct Answer:
C
— Accessing an element
Learn More →
Q. Which of the following operations can be performed in O(1) time on a linked list?
A.
Insertion at the end
B.
Deletion from the beginning
C.
Searching for an element
D.
Traversal
Show solution
Solution
Deletion from the beginning of a linked list can be done in O(1) time as it only requires updating the head pointer.
Correct Answer:
B
— Deletion from the beginning
Learn More →
Q. Which of the following operations can be performed in O(1) time on a stack?
A.
Push
B.
Pop
C.
Peek
D.
All of the above
Show solution
Solution
All operations (push, pop, and peek) can be performed in O(1) time on a stack.
Correct Answer:
D
— All of the above
Learn More →
Q. Which of the following operations can cause a violation of the AVL tree property?
A.
Insertion of a node.
B.
Deletion of a node.
C.
Both insertion and deletion.
D.
Traversal of the tree.
Show solution
Solution
Both insertion and deletion can cause the AVL tree to become unbalanced, requiring rebalancing operations.
Correct Answer:
C
— Both insertion and deletion.
Learn More →
Q. Which of the following operations can cause an imbalance in an AVL tree?
A.
Insertion
B.
Deletion
C.
Both Insertion and Deletion
D.
Traversal
Show solution
Solution
Both insertion and deletion operations can cause an imbalance in an AVL tree, requiring rebalancing.
Correct Answer:
C
— Both Insertion and Deletion
Learn More →
Q. Which of the following operations has a time complexity of O(1) in a stack?
A.
Push
B.
Pop
C.
Peek
D.
All of the above
Show solution
Solution
All operations (Push, Pop, and Peek) in a stack are performed in constant time, O(1).
Correct Answer:
D
— All of the above
Learn More →
Q. Which of the following operations has a time complexity of O(n) in a linked list?
A.
Accessing an element
B.
Inserting at the end
C.
Deleting a node
D.
Searching for a value
Show solution
Solution
Searching for a value in a linked list requires traversing the list, which takes O(n) time in the worst case.
Correct Answer:
D
— Searching for a value
Learn More →
Q. Which of the following operations has a time complexity of O(n) in a singly linked list?
A.
Insertion at head
B.
Insertion at tail
C.
Deletion at head
D.
Accessing an element by index
Show solution
Solution
Accessing an element by index in a singly linked list requires traversing the list, which takes O(n) time.
Correct Answer:
D
— Accessing an element by index
Learn More →
Q. Which of the following operations has a time complexity of O(n) in a stack?
A.
Push
B.
Pop
C.
Peek
D.
None of the above
Show solution
Solution
All basic operations (Push, Pop, Peek) in a stack have a time complexity of O(1). Therefore, the correct answer is 'None of the above'.
Correct Answer:
D
— None of the above
Learn More →
Q. Which of the following operations has the worst time complexity in a singly linked list?
A.
Accessing an element
B.
Inserting an element
C.
Deleting an element
D.
Traversing the list
Show solution
Solution
Accessing an element in a singly linked list requires traversal from the head to the desired node, which takes O(n) time in the worst case.
Correct Answer:
A
— Accessing an element
Learn More →
Q. Which of the following operations is guaranteed to be O(log n) in an AVL tree?
A.
Insertion
B.
Deletion
C.
Searching
D.
All of the above
Show solution
Solution
All operations (insertion, deletion, and searching) in an AVL tree are guaranteed to be O(log n) due to the tree's balanced nature.
Correct Answer:
D
— All of the above
Learn More →
Q. Which of the following operations is guaranteed to be O(log n) in both AVL and Red-Black trees?
A.
Insertion
B.
Deletion
C.
Searching
D.
All of the above
Show solution
Solution
All of the operations (insertion, deletion, and searching) are guaranteed to be O(log n) in both AVL and Red-Black trees.
Correct Answer:
D
— All of the above
Learn More →
Q. Which of the following operations is more efficient in a Red-Black tree compared to an AVL tree?
A.
Insertion
B.
Deletion
C.
Searching
D.
All of the above
Show solution
Solution
Deletion is generally more efficient in Red-Black trees due to fewer rotations required compared to AVL trees.
Correct Answer:
B
— Deletion
Learn More →
Q. Which of the following operations is more efficient in an AVL tree compared to a Red-Black tree?
A.
Insertion
B.
Deletion
C.
Searching
D.
All of the above
Show solution
Solution
Searching is generally more efficient in AVL trees due to their stricter balancing, leading to a more consistent height.
Correct Answer:
C
— Searching
Learn More →
Q. Which of the following operations is more efficient in AVL trees compared to Red-Black trees?
A.
Search
B.
Insertion
C.
Deletion
D.
Traversal
Show solution
Solution
Search operations are generally more efficient in AVL trees due to their stricter balancing.
Correct Answer:
A
— Search
Learn More →
Q. Which of the following operations is not allowed in a Red-Black tree?
A.
Insertion
B.
Deletion
C.
Searching
D.
Creating a node with two red children
Show solution
Solution
In a Red-Black tree, a node cannot have two red children, as it violates the properties of the tree.
Correct Answer:
D
— Creating a node with two red children
Learn More →
Showing 2881 to 2910 of 3237 (108 Pages)