DATA STRUCTURE AND ALGORITHMS | FROM QUESTION
TO PERFECTION| STUDY WITH CONFIDENCE!
Course Code:
Course Title:
Programme:
Academic Year: 2026/2027
Duration: 2 Hours.
Total Marks: 70%.
Candidate Instructions:
1) Write your Registration Number on every answer booklet used.
2) Answer ALL questions in Section A and ANY TWO (2) questions in Section B.
3) Read each question carefully before answering.
4) Begin each question on a new page.
5) The marks for each question are indicated in brackets.
6) This paper consists of several printed pages, including this page.
7) Ensure your copy is complete before the examination begins.
8) Unauthorized materials and communication with other candidates are not permitted.
Turn Over.
APPHIA – Crafted with Care and Precision for Academic Excellence.
1
, What is recursion? Answer: Recursion is the ability of a function to call itself.
What is the goal of the Towers of Hanoi problem? Answer: Move a tower of discs from Pillar 1
to Pillar 3.
What are the rules of the Towers of Hanoi? Answer: 1. A larger disc cannot be placed on top of
a smaller disc. 2. Only one disc can be moved at a time.
What is a recursive solution approach for moving n discs? Answer: 1. Move the top n-1 discs to
the temporary pillar. 2. Move the largest disc to the destination pillar. 3. Move the n-1 discs
from the temporary pillar to the destination.
Why use recursion? Answer: Recursion can provide cleaner, more intuitive solutions for
problems that are naturally self-similar.
What is a key challenge in recursion? Answer: The terminating condition must be defined to
prevent infinite loops.
What are the advantages of using recursion? Answer: 1. Simpler, cleaner code. 2. Mirrors
problem structure. 3. Reduces need for manual state tracking. 4. Easier for divide-and-conquer
problems.
What is a disadvantage of recursion? Answer: 1. High memory usage due to call stack. 2.
Performance overhead compared to iterative solutions. 3. Risk of infinite recursion. 4. Can be
hard to trace and debug.
What is Test Driven Development (TDD)? Answer: TDD is an evolutionary approach to
development that combines test-first development with refactoring.
What are the two simple rules of TDD? Answer: 1. Write new business code only when an
automated test has failed. 2. Eliminate any duplication found.
What is Test First Development (TFD)? Answer: TFD is the practice of writing tests before
writing any functional code.
What are the benefits of TDD? Answer: 1. Improves code quality. 2. Reduces bugs. 3. Provides
documentation. 4. Encourages simpler design. 5. Increases confidence.
What are common assertions in unit testing? Answer: General asserts include: Are Equal, Are
Not Equal, Is Null, Is Not Null, Is True, Is False.
What is Big-O notation? Answer: Big-O notation measures the efficiency and scalability of an
algorithm, estimating how runtime or space requirements grow relative to input size.
What does O(1) represent in Big-O notation? Answer: O(1) represents constant time
performance, where performance does not change with input size.
What does O(n) represent in Big-O notation? Answer: O(n) represents linear time performance,
where performance grows directly proportional to input size.
APPHIA – Crafted with Care and Precision for Academic Excellence.
2
TO PERFECTION| STUDY WITH CONFIDENCE!
Course Code:
Course Title:
Programme:
Academic Year: 2026/2027
Duration: 2 Hours.
Total Marks: 70%.
Candidate Instructions:
1) Write your Registration Number on every answer booklet used.
2) Answer ALL questions in Section A and ANY TWO (2) questions in Section B.
3) Read each question carefully before answering.
4) Begin each question on a new page.
5) The marks for each question are indicated in brackets.
6) This paper consists of several printed pages, including this page.
7) Ensure your copy is complete before the examination begins.
8) Unauthorized materials and communication with other candidates are not permitted.
Turn Over.
APPHIA – Crafted with Care and Precision for Academic Excellence.
1
, What is recursion? Answer: Recursion is the ability of a function to call itself.
What is the goal of the Towers of Hanoi problem? Answer: Move a tower of discs from Pillar 1
to Pillar 3.
What are the rules of the Towers of Hanoi? Answer: 1. A larger disc cannot be placed on top of
a smaller disc. 2. Only one disc can be moved at a time.
What is a recursive solution approach for moving n discs? Answer: 1. Move the top n-1 discs to
the temporary pillar. 2. Move the largest disc to the destination pillar. 3. Move the n-1 discs
from the temporary pillar to the destination.
Why use recursion? Answer: Recursion can provide cleaner, more intuitive solutions for
problems that are naturally self-similar.
What is a key challenge in recursion? Answer: The terminating condition must be defined to
prevent infinite loops.
What are the advantages of using recursion? Answer: 1. Simpler, cleaner code. 2. Mirrors
problem structure. 3. Reduces need for manual state tracking. 4. Easier for divide-and-conquer
problems.
What is a disadvantage of recursion? Answer: 1. High memory usage due to call stack. 2.
Performance overhead compared to iterative solutions. 3. Risk of infinite recursion. 4. Can be
hard to trace and debug.
What is Test Driven Development (TDD)? Answer: TDD is an evolutionary approach to
development that combines test-first development with refactoring.
What are the two simple rules of TDD? Answer: 1. Write new business code only when an
automated test has failed. 2. Eliminate any duplication found.
What is Test First Development (TFD)? Answer: TFD is the practice of writing tests before
writing any functional code.
What are the benefits of TDD? Answer: 1. Improves code quality. 2. Reduces bugs. 3. Provides
documentation. 4. Encourages simpler design. 5. Increases confidence.
What are common assertions in unit testing? Answer: General asserts include: Are Equal, Are
Not Equal, Is Null, Is Not Null, Is True, Is False.
What is Big-O notation? Answer: Big-O notation measures the efficiency and scalability of an
algorithm, estimating how runtime or space requirements grow relative to input size.
What does O(1) represent in Big-O notation? Answer: O(1) represents constant time
performance, where performance does not change with input size.
What does O(n) represent in Big-O notation? Answer: O(n) represents linear time performance,
where performance grows directly proportional to input size.
APPHIA – Crafted with Care and Precision for Academic Excellence.
2