Showing 641–650 of 654 questions
In dynamic programming, what is memoization?
A
Breaking problem into subproblems
B
Storing results of subproblems to avoid recomputation
C
Creating a memo
D
Sorting results
Correct Answer:
B. Storing results of subproblems to avoid recomputation
Explanation:
Memoization is an optimization technique where results of expensive function calls are cached and returned when same inputs occur again.
What is the time complexity of finding the median in a sorted array?
A
O(1)
B
O(log n)
C
O(n)
D
O(n log n)
Explanation:
In a sorted array, median is at index n/2, which is accessed in constant time O(1).
What is the space complexity of DFS using recursion?
A
O(1)
B
O(n)
C
O(log n)
D
O(h) where h is height
Correct Answer:
D. O(h) where h is height
Explanation:
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).
What is the correct output of: print(2 ** 3 ** 2) in Python?
Explanation:
Exponentiation is right-associative in Python. 32 = 9, then 2 9 = 512
In microservices architecture, what is an API Gateway?
A
A server that stores APIs
B
A single entry point for client requests to multiple microservices
C
A database for API data
D
A security firewall
Correct Answer:
B. A single entry point for client requests to multiple microservices
Explanation:
API Gateway is a server that acts as an intermediary between clients and microservices, handling routing, authentication, and load balancing.
What principle is followed when designing Google's systems?
A
Monolithic architecture
B
Distributed systems with horizontal scalability
C
Centralized database model
D
Sequential processing
Correct Answer:
B. Distributed systems with horizontal scalability
Explanation:
Google designs distributed systems that can scale horizontally across many machines to handle billions of requests.
What is eventual consistency in distributed systems?
A
All nodes have same data at all times
B
Data will be consistent across all nodes eventually
C
Consistency is never achieved
D
Only one node is consistent
Correct Answer:
B. Data will be consistent across all nodes eventually
Explanation:
Eventual consistency means that if no new updates are made, all nodes will eventually see the same data, though there may be temporary inconsistencies.
What is the CAP theorem in distributed systems?
A
Consistency, Availability, Partition tolerance - you can have all three
B
Consistency, Availability, Partition tolerance - you can have at most two
C
It's about database capacity
D
It's about memory limits
Correct Answer:
B. Consistency, Availability, Partition tolerance - you can have at most two
Explanation:
CAP theorem states that distributed systems can guarantee at most two of: Consistency, Availability, and Partition tolerance.
What does MapReduce do?
A
Reduces maps to a single value
B
Processes large datasets by mapping operations and reducing results
C
Only works with arrays
D
Is used only in front-end development
Correct Answer:
B. Processes large datasets by mapping operations and reducing results
Explanation:
MapReduce is a programming model for processing large datasets in parallel by mapping data and then reducing results.
In a system with 100 servers, if each has 99.9% uptime, what is the system's expected uptime?
A
99.9%
B
36.5%
C
1%
D
50%
Explanation:
If all servers must be up: (0.999)^100 ≈ 0.905 * 100 = 90.5%... Actually (0.999)^100 ≈ 0.9048 or ~90.48%. Closest is 36.5% for series of events