Q. In a singly linked list, how do you find the middle element?
A.
Traverse the list twice
B.
Use two pointers
C.
Count elements first
D.
Use a stack
Show solution
Solution
Using two pointers, where one moves twice as fast as the other, allows you to find the middle element in O(n) time.
Correct Answer:
B
— Use two pointers
Learn More →
Q. In a singly linked list, how do you insert a new node at the beginning?
A.
Create a new node and point it to the head
B.
Point the head to the new node
C.
Insert at the end
D.
None of the above
Show solution
Solution
To insert a new node at the beginning, create a new node and set its next pointer to the current head.
Correct Answer:
A
— Create a new node and point it to the head
Learn More →
Q. In a singly linked list, how do you reverse the list?
A.
Swap elements
B.
Use a stack
C.
Iterate and change pointers
D.
Use recursion
Show solution
Solution
To reverse a singly linked list, you can iterate through the list and change the next pointers of each node.
Correct Answer:
C
— Iterate and change pointers
Learn More →
Q. In a singly linked list, what is the time complexity of inserting a new node at the beginning?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Inserting a new node at the beginning of a singly linked list is done in constant time, O(1).
Correct Answer:
A
— O(1)
Learn More →
Q. In a singly linked list, what is the time complexity to insert an element at the beginning?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Inserting an element at the beginning of a singly linked list is done by adjusting the head pointer, which takes constant time, O(1).
Correct Answer:
A
— O(1)
Learn More →
Q. In a stack implemented using an array, what happens when you try to push an element onto a full stack?
A.
The element is added
B.
The stack overflows
C.
The stack shrinks
D.
The element is ignored
Show solution
Solution
Pushing onto a full stack results in a stack overflow error, as there is no space to add more elements.
Correct Answer:
B
— The stack overflows
Learn More →
Q. In a stack implemented using an array, what is the time complexity of the push operation?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
The push operation in a stack implemented with an array is O(1) as it adds an element to the top of the stack.
Correct Answer:
A
— O(1)
Learn More →
Q. In a stack, what happens when you try to pop an element from an empty stack?
A.
Returns null
B.
Throws an exception
C.
Returns 0
D.
Does nothing
Show solution
Solution
Popping from an empty stack typically throws an exception to indicate that the operation cannot be performed.
Correct Answer:
B
— Throws an exception
Learn More →
Q. In a stack, what is the result of the operation 'push(5)', followed by 'push(10)', and then 'pop()'?
A.
5
B.
10
C.
Both 5 and 10
D.
Stack is empty
Show solution
Solution
The 'pop()' operation will return 10, as it is the last element pushed onto the stack.
Correct Answer:
B
— 10
Learn More →
Q. In a stack, what is the time complexity of accessing the top element?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Accessing the top element of a stack is done in constant time, O(1), as it simply involves returning the last added element.
Correct Answer:
A
— O(1)
Learn More →
Q. In a stack, what is the time complexity of checking if it is empty?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Checking if a stack is empty is done in constant time, O(1), as it only requires checking the size or the top pointer.
Correct Answer:
A
— O(1)
Learn More →
Q. In a stack, what is the time complexity of the 'top' operation?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
The 'top' operation in a stack, which retrieves the top element without removing it, has a time complexity of O(1).
Correct Answer:
A
— O(1)
Learn More →
Q. In a stack, what is the time complexity of the pop operation when implemented using a dynamic array?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
The pop operation in a stack implemented using a dynamic array takes O(1) time, as it simply removes the top element.
Correct Answer:
A
— O(1)
Learn More →
Q. In a stack, what will be the output of popping an element from an empty stack?
A.
Null
B.
Error
C.
0
D.
Undefined
Show solution
Solution
Popping an element from an empty stack typically results in an error, as there are no elements to remove.
Correct Answer:
B
— Error
Learn More →
Q. In a stack, what will be the result of popping an element from an empty stack?
A.
Return null
B.
Throw an exception
C.
Return 0
D.
Return -1
Show solution
Solution
Popping an element from an empty stack typically throws an exception, indicating that the operation cannot be performed.
Correct Answer:
B
— Throw an exception
Learn More →
Q. In a stack, which operation is performed in constant time?
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. In a stack, which operation is performed last?
A.
Push
B.
Pop
C.
Peek
D.
None of the above
Show solution
Solution
In a stack, the last operation performed is Pop, which removes the most recently added element.
Correct Answer:
B
— Pop
Learn More →
Q. In a stack, which operation is used to remove the top element?
A.
Enqueue
B.
Dequeue
C.
Push
D.
Pop
Show solution
Solution
The operation used to remove the top element from a stack is called 'Pop'.
Correct Answer:
D
— Pop
Learn More →
Q. In a subnet mask of 255.255.255.0, how many usable IP addresses are available?
A.
254
B.
256
C.
512
D.
1024
Show solution
Solution
A subnet mask of 255.255.255.0 allows for 256 total addresses, but 2 are reserved (network and broadcast), leaving 254 usable addresses.
Correct Answer:
A
— 254
Learn More →
Q. In a subnet mask of 255.255.255.192, how many subnets can be created from a Class C network?
Show solution
Solution
The subnet mask 255.255.255.192 corresponds to /26, which allows for 2^(26-24) = 4 subnets from a Class C network.
Correct Answer:
B
— 4
Learn More →
Q. In a subnet with a subnet mask of 255.255.255.248, how many usable IP addresses are there?
Show solution
Solution
A subnet mask of 255.255.255.248 allows for 2^3 - 2 = 6 usable IP addresses.
Correct Answer:
B
— 6
Learn More →
Q. In a supervised learning context, what is cross-validation used for?
A.
To increase the size of the training dataset
B.
To evaluate the model's performance on unseen data
C.
To reduce the dimensionality of the dataset
D.
To cluster the data points
Show solution
Solution
Cross-validation is used to evaluate the model's performance on unseen data by partitioning the dataset into training and validation sets.
Correct Answer:
B
— To evaluate the model's performance on unseen data
Learn More →
Q. In a switched network, what is the primary function of a switch?
A.
To route packets between different networks
B.
To connect devices within the same network
C.
To provide a firewall
D.
To manage bandwidth
Show solution
Solution
A switch connects devices within the same network and forwards data based on MAC addresses.
Correct Answer:
B
— To connect devices within the same network
Learn More →
Q. In a tree structure, which traversal method is typically used for searching?
A.
BFS
B.
DFS
C.
Both BFS and DFS
D.
Neither BFS nor DFS
Show solution
Solution
Both BFS and DFS can be used for searching in a tree structure, depending on the specific requirements.
Correct Answer:
C
— Both BFS and DFS
Learn More →
Q. In a tree, which traversal method is equivalent to a level order traversal?
A.
DFS
B.
BFS
C.
In-order
D.
Pre-order
Show solution
Solution
Level order traversal of a tree is equivalent to BFS, as it visits nodes level by level.
Correct Answer:
B
— BFS
Learn More →
Q. In a weighted graph, if all edge weights are equal, which algorithm can be used to find the shortest path?
A.
Dijkstra's algorithm
B.
Breadth-First Search
C.
Depth-First Search
D.
A* algorithm
Show solution
Solution
If all edge weights are equal, Dijkstra's algorithm is still applicable, but Breadth-First Search (BFS) can also be used to find the shortest path.
Correct Answer:
B
— Breadth-First Search
Learn More →
Q. In a weighted graph, if all edge weights are equal, which algorithm can be used instead of Dijkstra's?
A.
Depth-First Search
B.
Breadth-First Search
C.
A* Search
D.
Bellman-Ford Algorithm
Show solution
Solution
If all edge weights are equal, Breadth-First Search can be used to find the shortest path, as it explores all neighbors at the present depth prior to moving on.
Correct Answer:
B
— Breadth-First Search
Learn More →
Q. In an AVL tree, what is the balance factor of a node?
A.
Height of left subtree - height of right subtree
B.
Height of right subtree - height of left subtree
C.
Number of nodes in left subtree - number of nodes in right subtree
D.
Height of the node itself
Show solution
Solution
The balance factor of a node in an AVL tree is defined as the height of the left subtree minus the height of the right subtree.
Correct Answer:
A
— Height of left subtree - height of right subtree
Learn More →
Q. In an AVL tree, what is the maximum height difference allowed between the left and right subtrees?
Show solution
Solution
An AVL tree allows a maximum height difference of 1 between the left and right subtrees.
Correct Answer:
B
— 2
Learn More →
Q. In an AVL tree, what is the maximum height difference between the left and right subtrees of any node?
Show solution
Solution
In an AVL tree, the height difference (balance factor) between the left and right subtrees of any node must be at most 1 to maintain balance.
Correct Answer:
B
— 1
Learn More →
Showing 331 to 360 of 3237 (108 Pages)