GRT Technical Skills 2 — Questions and Answers
Question 1: A sorting algorithm has a worst-case time complexity of O(n²) but an average-case complexity of O(n log n). Which algorithm fits this description?
- Merge Sort
- Quick Sort (Correct answer)
- Heap Sort
- Bubble Sort
Correct answer: Quick Sort
Quick Sort has an average-case of O(n log n) but degrades to O(n²) in the worst case when pivot selection is poor.
Question 2: In a relational database, which normal form eliminates transitive dependencies?
- First Normal Form (1NF)
- Second Normal Form (2NF)
- Third Normal Form (3NF) (Correct answer)
- Boyce-Codd Normal Form (BCNF)
Correct answer: Third Normal Form (3NF)
Third Normal Form (3NF) requires that all non-key attributes depend only on the primary key, eliminating transitive dependencies.
Question 3: Which data structure is most efficient for implementing a priority queue?
- Linked List
- Stack
- Binary Heap (Correct answer)
- Hash Table
Correct answer: Binary Heap
A Binary Heap supports O(log n) insertion and O(log n) deletion of the minimum/maximum element, making it ideal for priority queues.
Question 4: A network engineer needs to subnet a Class C IP address to support 30 hosts per subnet. What subnet mask should be used?
- /26 (255.255.255.192)
- /27 (255.255.255.224) (Correct answer)
- /28 (255.255.255.240)
- /25 (255.255.255.128)
Correct answer: /27 (255.255.255.224)
A /27 mask provides 32 addresses (30 usable hosts) per subnet, which exactly meets the 30-host requirement.
Question 5: In object-oriented programming, what principle does the Liskov Substitution Principle (LSP) enforce?
- A class should have only one reason to change
- Objects of a subclass should be replaceable for objects of the superclass (Correct answer)
- High-level modules should not depend on low-level modules
- A class should expose only what is necessary
Correct answer: Objects of a subclass should be replaceable for objects of the superclass
LSP states that subclasses must be substitutable for their parent classes without altering the correctness of the program.
Question 6: What does the term 'race condition' describe in concurrent programming?
- Two threads competing to finish first in a benchmark
- A bug where program output depends on non-deterministic thread scheduling (Correct answer)
- A deadlock between two threads waiting on each other
- A performance bottleneck caused by CPU cache misses
Correct answer: A bug where program output depends on non-deterministic thread scheduling
A race condition occurs when multiple threads access shared data concurrently and the result depends on the unpredictable order of execution.
Question 7: In version control, what does 'git rebase' do compared to 'git merge'?
- Rebase creates a merge commit; merge replays commits linearly
- Rebase replays commits on top of another branch; merge creates a merge commit (Correct answer)
- Both produce identical histories
- Rebase deletes the source branch; merge preserves it
Correct answer: Rebase replays commits on top of another branch; merge creates a merge commit
Git rebase moves or replays commits onto a new base commit, creating a linear history, while merge combines histories with a merge commit.
A sorting algorithm has a worst-case time complexity of O(n²) but an average-case complexity of O(n log n).
Which algorithm fits this description?