Showing 51–60 of 309 questions
Which data structure is most efficient for implementing a LRU (Least Recently Used) cache?
A
Array
B
Hash Map + Doubly Linked List
C
Binary Search Tree
D
Queue only
Correct Answer:
B. Hash Map + Doubly Linked List
EXPLANATION
Hash Map provides O(1) lookup while Doubly Linked List maintains insertion order and allows O(1) removal/reordering.
In SQL, what is the difference between HAVING and WHERE clauses?
A
Both serve identical purposes
B
WHERE filters rows before grouping; HAVING filters groups after aggregation
C
HAVING is used for individual row filtering
D
WHERE can only be used with JOIN operations
Correct Answer:
B. WHERE filters rows before grouping; HAVING filters groups after aggregation
EXPLANATION
WHERE clause filters individual rows before GROUP BY, while HAVING filters aggregated groups after GROUP BY.
What does CAP theorem state about distributed database systems?
A
All three properties can be achieved simultaneously
B
Only two of Consistency, Availability, and Partition tolerance can be guaranteed
C
Consistency is always sacrificed first
D
Partition tolerance is optional in modern systems
Correct Answer:
B. Only two of Consistency, Availability, and Partition tolerance can be guaranteed
EXPLANATION
CAP theorem proves that distributed systems can guarantee at most 2 of 3 properties: Consistency, Availability, and Partition tolerance.
Which of the following is NOT a characteristic of relational databases?
A
ACID compliance
B
Flexible schema
C
Structured data storage
D
Data integrity constraints
Correct Answer:
B. Flexible schema
EXPLANATION
Relational databases have fixed schemas. Flexible schemas are a characteristic of NoSQL databases like MongoDB.
In the OSI model, which layer is responsible for routing and logical addressing?
A
Physical Layer
B
Data Link Layer
C
Network Layer
D
Transport Layer
Correct Answer:
C. Network Layer
EXPLANATION
The Network Layer (Layer 3) handles routing, IP addressing, and logical path determination for data packets.
What is the primary purpose of indexing in databases?
A
To reduce storage space
B
To speed up data retrieval operations
C
To enforce data integrity
D
To manage concurrent access
Correct Answer:
B. To speed up data retrieval operations
EXPLANATION
Indexes create a faster lookup structure similar to a book's index, enabling rapid data retrieval without full table scans.
Which algorithm has O(n log n) time complexity and is preferred for large datasets in modern databases?
A
Bubble Sort
B
Merge Sort
C
Selection Sort
D
Insertion Sort
Correct Answer:
B. Merge Sort
EXPLANATION
Merge Sort maintains O(n log n) complexity in all cases and is stable, making it ideal for sorting large datasets.
In a relational database, what does normalization primarily aim to eliminate?
A
NULL values
B
Data redundancy and anomalies
C
Foreign key constraints
D
Index creation
Correct Answer:
B. Data redundancy and anomalies
EXPLANATION
Normalization removes data redundancy and prevents update, insertion, and deletion anomalies through organized table structures.
What is the primary advantage of using INNER JOIN over OUTER JOIN in SQL?
A
It processes faster for small datasets
B
It returns only matching records from both tables
C
It uses less memory than OUTER JOIN
D
It can handle NULL values better
Correct Answer:
B. It returns only matching records from both tables
EXPLANATION
INNER JOIN returns only rows that have matching values in both tables, making queries more efficient for specific requirements.
Which of the following is a ACID property that ensures all or nothing transaction execution?
A
Atomicity
B
Consistency
C
Isolation
D
Durability
Correct Answer:
A. Atomicity
EXPLANATION
Atomicity ensures that a transaction is treated as a single unit - either all operations complete or none do.