Q. What happens if the binary search algorithm is applied to an unsorted array?
-
A.
It will still find the target
-
B.
It will return an error
-
C.
It may return incorrect results
-
D.
It will sort the array first
Solution
Binary search will not work correctly on an unsorted array and may return incorrect results.
Correct Answer:
C
— It may return incorrect results
Learn More →
Q. What happens if the element being searched for is not present in the array during a binary search?
-
A.
It returns -1
-
B.
It raises an error
-
C.
It returns the last index
-
D.
It returns None
Solution
Typically, if the element is not found, binary search returns -1 to indicate absence.
Correct Answer:
A
— It returns -1
Learn More →
Q. What happens if the middle element in binary search is equal to the target?
-
A.
Search continues in the left half
-
B.
Search continues in the right half
-
C.
Target is found
-
D.
Search fails
Solution
If the middle element is equal to the target, the search is successful and the target is found.
Correct Answer:
C
— Target is found
Learn More →
Q. What happens if the target value is not found in the array during binary search?
-
A.
Returns the index of the closest value
-
B.
Returns -1
-
C.
Returns the last index
-
D.
Throws an exception
Solution
If the target value is not found, binary search typically returns -1 to indicate absence.
Correct Answer:
B
— Returns -1
Learn More →
Q. What happens if the target value is not present in the array during a binary search?
-
A.
The search returns the index of the closest value
-
B.
The search returns -1
-
C.
The search continues indefinitely
-
D.
The search throws an error
Solution
If the target value is not found, binary search typically returns -1 to indicate absence.
Correct Answer:
B
— The search returns -1
Learn More →
Q. What happens if the target value is not present in the array during binary search?
-
A.
Returns the index of the closest value
-
B.
Returns -1
-
C.
Returns the last mid index
-
D.
Infinite loop
Solution
If the target value is not found, binary search typically returns -1 to indicate absence.
Correct Answer:
B
— Returns -1
Learn More →
Q. What happens if the target value is not present in the sorted array during a binary search?
-
A.
The search will return the index of the closest value
-
B.
The search will return -1
-
C.
The search will enter an infinite loop
-
D.
The search will throw an error
Solution
If the target value is not present, binary search will return -1 or a similar indicator of absence.
Correct Answer:
B
— The search will return -1
Learn More →
Q. What happens if you apply binary search on a linked list?
-
A.
It works efficiently
-
B.
It does not work
-
C.
It works but is slower than on arrays
-
D.
It requires additional data structures
Solution
Binary search does not work on linked lists because they do not allow random access to elements.
Correct Answer:
B
— It does not work
Learn More →
Q. What happens if you apply binary search on a sorted array with duplicate elements?
-
A.
It finds the first occurrence
-
B.
It finds the last occurrence
-
C.
It can find any occurrence
-
D.
It fails
Solution
Binary search can find any occurrence of the element, but it does not guarantee which one.
Correct Answer:
C
— It can find any occurrence
Learn More →
Q. What happens if you apply binary search on an array that is not sorted?
-
A.
It will find the element correctly
-
B.
It will not find the element
-
C.
It may return an incorrect index
-
D.
It will throw an error
Solution
Binary search assumes the array is sorted; if it is not, it may return an incorrect index.
Correct Answer:
C
— It may return an incorrect index
Learn More →
Q. What happens if you apply binary search on an unsorted array?
-
A.
It will always find the element
-
B.
It may return incorrect results
-
C.
It will sort the array
-
D.
It will throw an error
Solution
Binary search requires a sorted array; applying it on an unsorted array may lead to incorrect results.
Correct Answer:
B
— It may return incorrect results
Learn More →
Q. What happens if you apply DFS on a graph with cycles without tracking visited nodes?
-
A.
It will terminate successfully.
-
B.
It will enter an infinite loop.
-
C.
It will throw an error.
-
D.
It will only visit some nodes.
Solution
If DFS is applied on a graph with cycles without tracking visited nodes, it will enter an infinite loop, revisiting the same nodes.
Correct Answer:
B
— It will enter an infinite loop.
Learn More →
Q. What happens to the balance factor of an AVL tree after a node is deleted?
-
A.
It remains unchanged.
-
B.
It can become unbalanced.
-
C.
It always becomes 0.
-
D.
It can only increase.
Solution
After a node is deleted from an AVL tree, the balance factor can become unbalanced, requiring rebalancing operations.
Correct Answer:
B
— It can become unbalanced.
Learn More →
Q. What happens to the balance factor of an AVL tree after a right rotation?
-
A.
It increases.
-
B.
It decreases.
-
C.
It remains the same.
-
D.
It becomes zero.
Solution
After a right rotation, the balance factor of the affected nodes decreases, helping to restore balance in the AVL tree.
Correct Answer:
B
— It decreases.
Learn More →
Q. What happens to the balance factor of an AVL tree after an insertion?
-
A.
It remains unchanged.
-
B.
It can become -2 or 2.
-
C.
It can only be -1, 0, or 1.
-
D.
It is always reset to 0.
Solution
After an insertion, the balance factor of an AVL tree can become -2 or 2, indicating that rebalancing is needed.
Correct Answer:
B
— It can become -2 or 2.
Learn More →
Q. What happens to the balance factor of an AVL tree node after a right rotation?
-
A.
It increases by 1.
-
B.
It decreases by 1.
-
C.
It remains the same.
-
D.
It becomes zero.
Solution
After a right rotation, the balance factor of the node that was rotated down decreases by 1.
Correct Answer:
B
— It decreases by 1.
Learn More →
Q. What happens to the search space in each iteration of binary search?
-
A.
It doubles
-
B.
It halves
-
C.
It remains the same
-
D.
It increases linearly
Solution
In each iteration of binary search, the search space is halved, which contributes to its logarithmic time complexity.
Correct Answer:
B
— It halves
Learn More →
Q. What happens when a node is inserted into an AVL tree and it causes an imbalance?
-
A.
The tree is deleted.
-
B.
The tree is restructured using rotations.
-
C.
The node is removed.
-
D.
No action is taken.
Solution
When an imbalance occurs after insertion in an AVL tree, the tree is restructured using rotations to restore balance.
Correct Answer:
B
— The tree is restructured using rotations.
Learn More →
Q. What happens when an AVL tree becomes unbalanced after an insertion?
-
A.
It is deleted.
-
B.
It is rotated to restore balance.
-
C.
It is converted to a Red-Black tree.
-
D.
Nothing happens.
Solution
When an AVL tree becomes unbalanced after an insertion, rotations (single or double) are performed to restore balance.
Correct Answer:
B
— It is rotated to restore balance.
Learn More →
Q. What happens when you insert a node into an AVL tree that causes it to become unbalanced?
-
A.
The tree is deleted.
-
B.
The tree is restructured and rebalanced.
-
C.
The node is ignored.
-
D.
The tree becomes a binary tree.
Solution
When an insertion causes an AVL tree to become unbalanced, rotations are performed to restore balance.
Correct Answer:
B
— The tree is restructured and rebalanced.
Learn More →
Q. What happens when you try to enqueue an element into a full queue?
-
A.
The element is added
-
B.
The queue overflows
-
C.
An error is raised
-
D.
The queue is resized
Solution
When trying to enqueue an element into a full queue, an error is typically raised, indicating that the queue cannot accept more elements.
Correct Answer:
C
— An error is raised
Learn More →
Q. What happens when you try to pop an element from an empty stack?
-
A.
It returns null
-
B.
It throws an exception
-
C.
It returns the last element added
-
D.
It does nothing
Solution
Attempting to pop from an empty stack typically results in an exception being thrown.
Correct Answer:
B
— It throws an exception
Learn More →
Q. What is 'data drift' in the context of deployed models?
-
A.
Changes in the model architecture
-
B.
Changes in the data distribution over time
-
C.
Changes in the model's hyperparameters
-
D.
Changes in the evaluation metrics
Solution
Data drift refers to changes in the data distribution over time, which can affect the model's performance and accuracy.
Correct Answer:
B
— Changes in the data distribution over time
Learn More →
Q. What is 'discount factor' in reinforcement learning?
-
A.
A measure of the agent's performance
-
B.
A value that determines the importance of future rewards
-
C.
A method for clustering actions
-
D.
A technique for data normalization
Solution
The discount factor determines how much future rewards are valued compared to immediate rewards, influencing the agent's decision-making.
Correct Answer:
B
— A value that determines the importance of future rewards
Learn More →
Q. What is 'exploration' in the context of reinforcement learning?
-
A.
Using known information to make decisions
-
B.
Trying new actions to discover their effects
-
C.
Evaluating the performance of the agent
-
D.
Clustering similar actions
Solution
Exploration involves trying new actions to discover their potential rewards, which is essential for learning in uncertain environments.
Correct Answer:
B
— Trying new actions to discover their effects
Learn More →
Q. What is a 'lexeme' in the context of lexical analysis?
-
A.
The smallest unit of meaning in a programming language
-
B.
The actual sequence of characters that matches a token
-
C.
A type of syntax error
-
D.
A representation of a variable in the symbol table
Solution
A lexeme is the actual sequence of characters in the source code that matches a token.
Correct Answer:
B
— The actual sequence of characters that matches a token
Learn More →
-
A.
The smallest unit of a program
-
B.
A sequence of characters that matches a token
-
C.
A type of syntax error
-
D.
A part of the symbol table
Solution
A lexeme is a sequence of characters in the source code that matches a token defined by the lexical analyzer.
Correct Answer:
B
— A sequence of characters that matches a token
Learn More →
Q. What is a common application of a stack in programming?
-
A.
Managing function calls
-
B.
Storing data in a linear fashion
-
C.
Implementing a priority queue
-
D.
Searching for elements
Solution
Stacks are commonly used to manage function calls in programming languages, where the last function called is the first to return.
Correct Answer:
A
— Managing function calls
Learn More →
Q. What is a common application of arrays in programming?
-
A.
Dynamic memory allocation
-
B.
Implementing hash tables
-
C.
Storing a fixed number of elements
-
D.
Creating linked lists
Solution
Arrays are commonly used to store a fixed number of elements due to their contiguous memory allocation.
Correct Answer:
C
— Storing a fixed number of elements
Learn More →
Q. What is a common application of arrays in real-world scenarios?
-
A.
Storing user data in a database
-
B.
Implementing a stack data structure
-
C.
Managing a list of items in a shopping cart
-
D.
Creating a binary tree
Solution
Arrays are often used to manage a list of items in a shopping cart because they allow for efficient indexing and retrieval of items.
Correct Answer:
C
— Managing a list of items in a shopping cart
Learn More →
Showing 811 to 840 of 3237 (108 Pages)