Computer Science Quiz
Questions: 16 · 10 minutes
1. A program must repeatedly search a sorted list of one million distinct numbers. Which approach most efficiently uses the fact that the list is sorted?
Check each number from the beginning until a match is found
Compare with the middle number and repeatedly discard half of the remaining list
Randomly sample positions until the number appears
Sort the list again before every search
2. What most clearly distinguishes a traditional compiler from an interpreter?
A compiler can process numbers, while an interpreter can process only text
A compiler finds every logical error automatically
A compiler is used only for operating systems
A compiler typically translates source code into a target form before execution
3. A print server must process jobs in the same order they arrive. Which data structure best fits this requirement?
A stack, removing the most recently added job first
A set, selecting any stored job next
A tree, always removing the job with the longest name
A queue, removing the earliest added job first
4. A program scans every element of a large array in order and runs faster than another version that accesses the same elements in a scattered pattern. What best explains the difference?
Sequential access changes the array's declared data type
Sequential access usually benefits from spatial locality in the cache
Scattered access forces the processor to use recursion
Scattered access automatically increases algorithmic complexity to O(n²)
5. A website needs to store user passwords responsibly. Which method is most appropriate?
Store a unique salted cryptographic hash for each password
Encrypt every password with the same key stored beside the database
Encode passwords with Base64 before saving them
Store password hints instead of the passwords themselves
6. A model is trained on thousands of emails already labeled “spam” or “not spam.” What type of machine learning is this?
Dimensionality reduction without labels
Unsupervised learning
Reinforcement learning
Supervised learning
7. You need only the customers who have at least one matching order in another SQL table. Which join is the standard choice?
CROSS JOIN
LEFT JOIN
INNER JOIN
FULL OUTER JOIN
8. A recursive function keeps calling itself until the program exhausts its call stack. What is the most likely design problem?
It uses local variables instead of global variables
Its return type is too small
It lacks a reachable base case that stops the recursion
It was written using a high-level language
9. In an unweighted graph, which algorithm finds a path with the fewest edges from a starting vertex to every reachable vertex?
Breadth-first search
Binary search
Depth-first search
Selection sort
10. Which HTTP status code conventionally indicates that the requested resource was not found?
404
301
403
200
11. According to De Morgan's law, which expression is equivalent to NOT (A AND B)?
(NOT A) AND (NOT B)
A OR B
(NOT A) OR (NOT B)
A AND (NOT B)
12. A computer runs a program whose active memory needs exceed the available physical RAM. Which operating-system feature can temporarily use secondary storage to support its address space?
Process scheduling
File compression
Device polling
Virtual memory
13. An algorithm runs one complete loop over n items inside another complete loop over those n items. What is its typical time complexity?
Logarithmic time, O(log n)
Quadratic time, O(n²)
Linear time, O(n)
Exponential time, O(2ⁿ)
14. A live voice application prioritizes low delay and can tolerate an occasional lost packet. Which transport protocol is generally the better fit?
TCP, because it waits to deliver every packet in order
UDP, because it avoids connection and retransmission overhead
HTTP, because it defines request and response messages for web resources
DNS, because it translates domain names into network addresses
15. A database repeats a customer's address in every order row, creating inconsistent copies when the customer moves. Which design practice directly helps reduce this problem?
Caching the most recent order rows
Indexing every text column in the order table
Normalization that separates customer data from order data
Combining all related records into one larger field
16. Two processes each hold one resource while waiting indefinitely for the resource held by the other. Which condition is illustrated most directly?
Circular wait in a deadlock
Memory fragmentation
Preemptive scheduling
A cache miss