QuickSort uses O(log n) space for the recursion call stack in the average case.
Q.622Easy
In a BFS (Breadth-First Search), what data structure is used?
Answer: B
BFS uses a Queue (FIFO) to explore nodes level by level. DFS uses a Stack (LIFO).
Q.623Hard
What is the correct way to check if a number is a power of 2?
Answer: A
A power of 2 has only one bit set. n & (n-1) removes the rightmost set bit, so if result is 0, n is a power of 2.
Q.624Medium
Which sorting algorithm is stable and has O(n log n) worst-case complexity?
Answer: B
MergeSort has O(n log n) worst-case and is stable. QuickSort is O(n²) worst-case, HeapSort is not stable.
Q.625Easy
What is the result of 1 XOR 1?
Answer: A
XOR (exclusive OR) returns 1 only when bits are different. 1 XOR 1 = 0 because both bits are the same.
Advertisement
Q.626Medium
In dynamic programming, what is memoization?
Answer: B
Memoization is an optimization technique where results of expensive function calls are cached and returned when same inputs occur again.
Q.627Easy
What is the time complexity of finding the median in a sorted array?
Answer: A
In a sorted array, median is at index n/2, which is accessed in constant time O(1).
Q.628Hard
What is the space complexity of DFS using recursion?
Answer: D
Recursive DFS uses call stack space proportional to the height of the tree/graph. For balanced tree, it's O(log n); worst case O(n).
Q.629Medium
What is the correct output of: print(2 3 2) in Python?
Answer: B
Exponentiation is right-associative in Python. 32 = 9, then 29 = 512
Q.630Medium
In microservices architecture, what is an API Gateway?
Answer: B
API Gateway is a server that acts as an intermediary between clients and microservices, handling routing, authentication, and load balancing.
Q.631Medium
What principle is followed when designing Google's systems?
Answer: B
Google designs distributed systems that can scale horizontally across many machines to handle billions of requests.
Q.632Hard
What is eventual consistency in distributed systems?
Answer: B
Eventual consistency means that if no new updates are made, all nodes will eventually see the same data, though there may be temporary inconsistencies.
Q.633Hard
What is the CAP theorem in distributed systems?
Answer: B
CAP theorem states that distributed systems can guarantee at most two of: Consistency, Availability, and Partition tolerance.
Q.634Medium
What does MapReduce do?
Answer: B
MapReduce is a programming model for processing large datasets in parallel by mapping data and then reducing results.
Q.635Easy
What is the purpose of a load balancer?
Answer: B
A load balancer distributes network traffic across multiple servers to improve reliability and responsiveness.
Q.636Medium
In TCP/IP model, which layer handles IP addresses?
Answer: C
The Internet Layer (Layer 3) handles IP addresses and routing. Transport Layer (Layer 4) handles ports.
Q.637Medium
A train travels from City A to City B at 60 km/h and returns at 40 km/h. The total distance between the two cities is 240 km. What is the average speed of the train for the entire journey?
Answer: A
Average speed = Total Distance / Total Time. Distance one way = 240 km. Time from A to B = 60240 = 4 hours. Time from B to A = 40240 = 6 hours. Total Distance = 480 km, Total Time = 10 hours. Average Speed = 10480 = 48 km/h.
Q.638Medium
In a sequence, each number is the sum of the previous two numbers. If the 5th number is 20 and the 6th number is 32, what is the 4th number?
Answer: B
Let the 4th number be x. Then 5th number = previous number + x. If 5th = 20 and 6th = 32, then 6th = 5th + 5th_previous, so 32 = 20 + (5th_previous). Therefore, 5th_previous = 12. Since 5th_previous is the 4th number, the answer is 12.