Module 1 Solutions Model Questions
Module 1 Solutions Model Questions
The goal is to create a calculator that displays a menu of four operations (addition,
subtraction, multiplication, and division), performs the chosen operation on two
numbers, and displays the result.
Perform calculations:
Q. A mad scientist wishes to make a chain out of plutonium and lead pieces. There is a
problem, however. If the scientist places two pieces of plutonium next to each other,
BOOM! The question is, in how many ways can the scientist safely construct a chain of
length n? (3 marks)
Now let’s see if we can find a pattern as the chain gets longer. To figure this out, let’s think
about how we can build a chain of length nnn using shorter chains.
This gives us a rule, or formula, to find the number of ways for any length:
f(n)=f(n−1) + f(n−2)
Q. Walk through the six problem-solving steps to find the largest number out of three
numbers. (9 Marks)
To find the largest number out of three given numbers using the six problem-solving steps,
we can approach it as follows:
The objective is to identify the largest number among three given numbers (say, A, B, and C).
We need to compare these numbers to determine which one is the greatest.
We’ll use comparison operations to solve this problem. The plan is to:
Compare A with B.
Then compare the larger of A and B with C.
The result will be the largest of the three.
3. DEVELOP AN ALGORITHM
1. If A > B, then:
o If A > C, then A is the largest.
o Else, C is the largest.
2. Else, if B > C, then B is the largest.
3. Otherwise, C is the largest.
Pseudocode
READ A, B, C
IF A > B THEN
IF A > C then
OUTPUT A as the largest
ELSE
Output C as the largest
ELSE
IF B > C THEN
OUTPUT B as the largest
ELSE
OUTPUT C as the largest
We can test this algorithm with different sets of values for A, B, and C:
6. REVIEW
Evaluate if the algorithm works efficiently and correctly for all cases, including cases where two
or three numbers are equal. This approach is efficient and solves the problem using a minimal
number of comparisons.
The main goal is to complete the assignment by Wednesday. Break down this goal into
specific tasks, such as research, outlining, writing, and reviewing.
If you haven't started, the gap is larger; if you've already done some initial work, the
gap is smaller.
Allocate a specific time for each part of the task, ensuring you have time left for
review.
Use tools or resources that could help speed up certain parts (like outlining software
or typing up notes).
By breaking down and addressing each step day-by-day, you can ensure steady
progress and complete the assignment by the deadline without unnecessary last-
minute stress.
Q. Name two current problems in your life that might be solved through a heuristic approach.
Explain why each of these problems can be solved using heuristics.(4 Marks)
Heuristic problem-solving is a practical approach that relies on experience, intuition, and simple
rules to find a solution to complex problems. Heuristics offer "rules of thumb" or shortcuts that can
lead to a satisfactory answer quickly, even if it's not the optimal solution