Q. In a queue, which operation is performed to remove an element?
A.
Push
B.
Pop
C.
Enqueue
D.
Dequeue
Show solution
Solution
The operation to remove an element from a queue is called Dequeue, following the FIFO (First In, First Out) principle.
Correct Answer:
D
— Dequeue
Learn More →
Q. In a queue, which operation is used to remove an element?
A.
Push
B.
Pop
C.
Enqueue
D.
Dequeue
Show solution
Solution
The operation used to remove an element from a queue is called Dequeue.
Correct Answer:
D
— Dequeue
Learn More →
Q. In a Random Forest, what is the purpose of bootstrapping?
A.
To reduce overfitting
B.
To increase the number of features
C.
To create multiple subsets of data for training
D.
To improve model interpretability
Show solution
Solution
Bootstrapping involves creating multiple subsets of the training data, which helps in building diverse trees in the Random Forest.
Correct Answer:
C
— To create multiple subsets of data for training
Learn More →
Q. In a Random Forest, what is the purpose of using multiple Decision Trees?
A.
To increase the model's complexity
B.
To reduce overfitting and improve accuracy
C.
To simplify the model
D.
To ensure all trees are identical
Show solution
Solution
Using multiple Decision Trees in a Random Forest helps to reduce overfitting and improve the overall accuracy of the model.
Correct Answer:
B
— To reduce overfitting and improve accuracy
Learn More →
Q. In a real-world application, SVM can be used for which of the following?
A.
Image recognition
B.
Time series forecasting
C.
Clustering customer segments
D.
Generating text
Show solution
Solution
SVM is widely used in image recognition tasks, where it can classify images based on their features.
Correct Answer:
A
— Image recognition
Learn More →
Q. In a real-world application, which of the following scenarios is best suited for linear regression?
A.
Classifying emails as spam or not spam
B.
Predicting house prices based on features like size and location
C.
Segmenting customers into different groups
D.
Identifying topics in a set of documents
Show solution
Solution
Linear regression is best suited for predicting continuous outcomes, such as house prices based on various features.
Correct Answer:
B
— Predicting house prices based on features like size and location
Learn More →
Q. In a real-world application, which of the following scenarios is most suitable for linear regression?
A.
Classifying emails as spam or not spam
B.
Predicting house prices based on features like size and location
C.
Segmenting customers into different groups
D.
Identifying anomalies in network traffic
Show solution
Solution
Linear regression is suitable for predicting continuous outcomes, such as house prices based on various features.
Correct Answer:
B
— Predicting house prices based on features like size and location
Learn More →
Q. In a recursive function, what is the purpose of the return statement?
A.
To terminate the program
B.
To return control to the caller
C.
To call the function again
D.
To print the output
Show solution
Solution
The return statement is used to return control to the caller along with any computed value.
Correct Answer:
B
— To return control to the caller
Learn More →
Q. In a recursive implementation of binary search, what is the base case?
A.
When the array is empty
B.
When the target is found
C.
When the left index exceeds the right index
D.
When the mid index is zero
Show solution
Solution
The base case for recursion in binary search is when the left index exceeds the right index, indicating the target is not found.
Correct Answer:
C
— When the left index exceeds the right index
Learn More →
Q. In a Red-Black tree, what color can the root node be?
A.
Red
B.
Black
C.
Either Red or Black
D.
None of the above
Show solution
Solution
The root node of a Red-Black tree must always be black to maintain the properties of the tree.
Correct Answer:
B
— Black
Learn More →
Q. In a Red-Black tree, what color is the root node required to be?
A.
Red
B.
Black
C.
Either red or black
D.
None of the above
Show solution
Solution
The root node of a Red-Black tree is required to be black, which is one of the properties that help maintain the balance of the tree.
Correct Answer:
B
— Black
Learn More →
Q. In a Red-Black tree, what color is the root node?
A.
Red
B.
Black
C.
Green
D.
Blue
Show solution
Solution
The root of a Red-Black tree is always black to maintain the properties of the tree.
Correct Answer:
B
— Black
Learn More →
Q. In a Red-Black tree, what happens when a red node is inserted as a child of another red node?
A.
The tree remains valid.
B.
The tree is immediately balanced.
C.
A recoloring and rotation may be needed.
D.
The insertion is not allowed.
Show solution
Solution
When a red node is inserted as a child of another red node, a recoloring and possibly a rotation are needed to maintain the properties of the Red-Black tree.
Correct Answer:
C
— A recoloring and rotation may be needed.
Learn More →
Q. In a Red-Black tree, what happens when a red node is inserted?
A.
It is always the root.
B.
It may cause a violation of Red-Black properties.
C.
It is always a leaf.
D.
It cannot be inserted.
Show solution
Solution
Inserting a red node may cause a violation of the Red-Black properties, requiring adjustments.
Correct Answer:
B
— It may cause a violation of Red-Black properties.
Learn More →
Q. In a Red-Black tree, what is the maximum height of the tree in terms of the number of nodes n?
A.
2n
B.
n
C.
log(n)
D.
2 * log(n)
Show solution
Solution
The maximum height of a Red-Black tree is 2 * log(n), ensuring that the tree remains balanced.
Correct Answer:
D
— 2 * log(n)
Learn More →
Q. In a Red-Black tree, what is the maximum number of black nodes on any path from the root to a leaf?
A.
1
B.
2
C.
3
D.
It can vary.
Show solution
Solution
In a Red-Black tree, the number of black nodes can vary, but every path from the root to the leaves must have the same number of black nodes.
Correct Answer:
D
— It can vary.
Learn More →
Q. In a Red-Black tree, what must be true about the children of a red node?
A.
They must be red.
B.
They must be black.
C.
They can be either color.
D.
They must be leaf nodes.
Show solution
Solution
In a Red-Black tree, the children of a red node must be black to maintain the tree's properties.
Correct Answer:
B
— They must be black.
Learn More →
Q. In a Red-Black Tree, what must be true about the path from any node to its descendant leaves?
A.
All paths must have the same number of black nodes
B.
All paths must have the same number of red nodes
C.
All paths must alternate colors
D.
All paths must have at least one red node
Show solution
Solution
In a Red-Black Tree, every path from a node to its descendant leaves must have the same number of black nodes.
Correct Answer:
A
— All paths must have the same number of black nodes
Learn More →
Q. In a Red-Black Tree, what must be true about the path from the root to any leaf?
A.
All paths must have the same number of black nodes.
B.
All paths must have the same number of red nodes.
C.
All paths must have the same number of total nodes.
D.
All paths must alternate colors.
Show solution
Solution
In a Red-Black Tree, every path from the root to any leaf must have the same number of black nodes to maintain balance.
Correct Answer:
A
— All paths must have the same number of black nodes.
Learn More →
Q. In a Red-Black tree, what property ensures that no two red nodes are adjacent?
A.
Root property
B.
Red property
C.
Black property
D.
Leaf property
Show solution
Solution
The Red property of Red-Black trees states that no two red nodes can be adjacent, ensuring that the tree remains balanced.
Correct Answer:
B
— Red property
Learn More →
Q. In a Red-Black tree, what property ensures that the tree remains approximately balanced?
A.
Every node is either red or black
B.
The root is always black
C.
Every red node must have two black children
D.
All leaves are black
Show solution
Solution
In a Red-Black tree, every red node must have two black children, which helps maintain balance and ensures that no path from the root to a leaf is more than twice as long as any other such path.
Correct Answer:
C
— Every red node must have two black children
Learn More →
Q. In a Red-Black tree, what property ensures that the tree remains balanced?
A.
Every node has two children
B.
The root is always black
C.
No two red nodes can be adjacent
D.
All leaves are at the same level
Show solution
Solution
In a Red-Black tree, no two red nodes can be adjacent, which helps maintain balance and ensures that the longest path from the root to a leaf is no more than twice as long as the shortest path.
Correct Answer:
C
— No two red nodes can be adjacent
Learn More →
Q. In a Red-Black Tree, what property must be maintained after an insertion?
A.
The tree must be a complete binary tree
B.
The root must always be red
C.
Every path from a node to its descendant leaves must have the same number of black nodes
D.
All leaves must be red
Show solution
Solution
In a Red-Black Tree, every path from a node to its descendant leaves must have the same number of black nodes.
Correct Answer:
C
— Every path from a node to its descendant leaves must have the same number of black nodes
Learn More →
Q. In a Red-Black tree, what property must be maintained after every insertion?
A.
The tree must be complete.
B.
The tree must be balanced.
C.
The root must always be black.
D.
All leaves must be red.
Show solution
Solution
In a Red-Black tree, the root must always be black to maintain the properties of the tree.
Correct Answer:
C
— The root must always be black.
Learn More →
Q. In a regression case study, which metric would best evaluate the model's prediction error?
A.
Confusion Matrix
B.
R-squared
C.
Precision
D.
Recall
Show solution
Solution
R-squared is a common metric for evaluating the goodness of fit in regression models, indicating how well the model explains the variability of the data.
Correct Answer:
B
— R-squared
Learn More →
Q. In a regression problem, what does the R-squared value indicate?
A.
The strength of the relationship between variables
B.
The number of features used in the model
C.
The accuracy of the classification
D.
The error rate of the predictions
Show solution
Solution
R-squared indicates the strength of the relationship between the independent variables and the dependent variable in regression.
Correct Answer:
A
— The strength of the relationship between variables
Learn More →
Q. In a regression problem, what does the term 'overfitting' refer to?
A.
The model performs well on training data but poorly on unseen data
B.
The model is too simple to capture the underlying trend
C.
The model has too few features
D.
The model is perfectly accurate
Show solution
Solution
Overfitting occurs when a model learns the training data too well, capturing noise instead of the underlying pattern, leading to poor performance on new data.
Correct Answer:
A
— The model performs well on training data but poorly on unseen data
Learn More →
Q. In a singly linked list, how can you find the middle element in one pass?
A.
Use two pointers
B.
Count nodes first
C.
Use recursion
D.
Use a stack
Show solution
Solution
By using two pointers, where one moves twice as fast as the other, you can find the middle element in one pass.
Correct Answer:
A
— Use two pointers
Learn More →
Q. In a singly linked list, how do you access the last element?
A.
Direct access
B.
Iterate from the head
C.
Use a tail pointer
D.
Access via index
Show solution
Solution
In a singly linked list, you must iterate from the head to access the last element, as there is no direct access.
Correct Answer:
B
— Iterate from the head
Learn More →
Q. In a singly linked list, how do you delete a node given only access to that node?
A.
Set the node to null
B.
Copy the next node's data
C.
Change the previous node's pointer
D.
You cannot delete it
Show solution
Solution
To delete a node in a singly linked list when you only have access to that node, you can copy the data from the next node and then delete the next node.
Correct Answer:
B
— Copy the next node's data
Learn More →
Showing 301 to 330 of 3237 (108 Pages)