Exit Chapter 07 ยท ๐Ÿงฉ Introduction to Problem Solving โ€” Quiz

Playing as a guest? to earn XP and track your progress.

Question 1 of 55 0 correct so far

๐Ÿงฉ Introduction to Problem Solving Quiz

Q1.

What is problem solving in computing?

Explanation

Problem solving means identifying a problem, developing a step-by-step solution and converting it into a working program.

Q2.

In the building analogy, the algorithm is like the building's:

Explanation

The program is the building and the algorithm is its blueprint โ€” you plan before you build.

Q3.

What is the correct order of the four steps of problem solving?

Explanation

The steps are Analyse โ†’ Develop an algorithm โ†’ Code โ†’ Test & debug (the 'A-D-C-T' trick).

Q4.

During 'Analysing the problem', a programmer identifies:

Explanation

Analysis means understanding what is needed: inputs, outputs, processing/formulas and conditions.

Q5.

For the problem 'Find the area of a rectangle', what are the inputs?

Explanation

The inputs are length (L) and breadth (B); the output is the area, and the formula is Area = L ร— B.

Q6.

What happens in the 'Testing and debugging' step?

Explanation

The program is run with different inputs (including unusual ones) to find and fix errors, then re-tested.

Q7.

What is an algorithm?

Explanation

An algorithm is a finite sequence of clear, well-defined steps that produces the desired output for the given input.

Q8.

The word 'algorithm' comes from the name of which mathematician?

Explanation

It comes from the 9th-century Persian mathematician Abu Ja'far Muhammad ibn Musa al-Khwarizmi.

Q9.

Why is writing an algorithm before coding useful?

Explanation

An algorithm gives a clear roadmap, saves time by catching logic errors early, is language independent and is easy to share.

Q10.

An algorithm being 'language independent' means:

Explanation

An algorithm is not tied to any language; it can be coded in any programming language.

Q11.

Which set lists the characteristics of a good algorithm?

Explanation

The characteristics are Precision, Uniqueness, Finiteness, Input and Output ('PUFIO').

Q12.

The instruction 'Add some sugar' violates which characteristic of a good algorithm?

Explanation

Precision requires every step to be clearly and exactly stated; 'some' is vague.

Q13.

The step 'Keep adding 1 to x' (with no stopping condition) violates:

Explanation

Finiteness requires the algorithm to stop after a finite number of steps.

Q14.

The characteristic that the result of each step depends only on the input and earlier steps is called:

Explanation

Uniqueness: each step's result is uniquely defined by the input and the results of previous steps.

Q15.

How many inputs and outputs must a good algorithm have?

Explanation

An algorithm takes zero or more inputs and produces at least one output.

Q16.

Which statement about algorithms and programs is correct?

Explanation

An algorithm is written in simple English-like steps; a program is the algorithm expressed in a language such as Python.

Q17.

What are the two popular ways of representing an algorithm?

Explanation

An algorithm can be represented visually as a flowchart or in text as pseudocode.

Q18.

What is a flowchart?

Explanation

A flowchart is a pictorial representation of an algorithm, using standard symbols and arrows to show the flow of control.

Q19.

Which flowchart symbol is used for Start and Stop?

Explanation

The oval or rounded rectangle is the terminal symbol for Start/Stop.

Q20.

Which flowchart symbol is used for a decision (Yes/No)?

Explanation

A diamond represents a decision with Yes/No (True/False) branches.

Q21.

Which flowchart symbol is used for input and output?

Explanation

Input/Output steps, such as reading a value or printing a result, use a parallelogram.

Q22.

Which flowchart symbol is used for a calculation such as sum = a + b?

Explanation

Calculations and assignments use the rectangle (process) symbol.

Q23.

What is the small circle used for in a flowchart?

Explanation

A connector (small circle) joins parts of a flowchart, for example across pages.

Q24.

A student used a rectangle to show 'INPUT num'. What is wrong?

Explanation

Input/Output uses a parallelogram; the rectangle is reserved for processing steps.

Q25.

Which is a rule for drawing flowcharts?

Explanation

Rules: one Start, at least one Stop, correct symbols, top-to-bottom/left-to-right flow, decision boxes with two exits, and no crossing lines.

Q26.

What is pseudocode?

Explanation

Pseudocode ('pseudo' means 'not real') resembles program code but follows no programming language's syntax.

Q27.

Which keywords are commonly used for input in pseudocode?

Explanation

Input keywords are INPUT, READ and GET; output keywords are PRINT, DISPLAY and OUTPUT.

Q28.

Which is a benefit of pseudocode?

Explanation

Pseudocode keeps the focus on logic, is easy to read and write, and converts easily to any language.

Q29.

Which statement comparing flowcharts and pseudocode is correct?

Explanation

Pseudocode is compact and easy to edit and suits large problems; flowcharts are visual but harder to modify.

Q30.

The flow of control means:

Explanation

Flow of control is the order in which steps are executed.

Q31.

What are the three basic control structures of any algorithm?

Explanation

Every algorithm is built from sequence, selection (decision) and repetition (iteration).

Q32.

In a sequence structure:

Explanation

Sequence executes steps one after another in the order they are written.

Q33.

What does this program print when the input is 100?

C = float(input()) F = C * 9 / 5 + 32 print(F)

Explanation

100 ร— 9 / 5 + 32 = 180.0 + 32 = 212.0 (a float because / is used).

Q34.

Selection (decision making) is best compared to:

Explanation

Selection checks a condition and chooses one of the paths, like a fork in the road.

Q35.

In the even/odd algorithm, which condition identifies an even number?

Explanation

A number is even if the remainder of num รท 2 is 0 (num % 2 == 0 in Python).

Q36.

For the 'largest of three numbers' program with inputs 12, 45 and 30, what is printed?

Explanation

a > b and a > c is False (12 < 45); then b > c (45 > 30) is True, so '45 is the largest' is printed.

Q37.

Repetition (iteration) means:

Explanation

In repetition (looping), steps repeat as long as the condition stays True.

Q38.

In the algorithm for the sum of the first N natural numbers, what must sum be initialised to?

Explanation

sum starts at 0; starting at 1 would be a logical error.

Q39.

In the factorial algorithm, why must fact start at 1 and not 0?

Explanation

Anything ร— 0 = 0, so fact must be initialised to 1.

Q40.

What is the output of the sum-of-N-natural-numbers program for N = 5?

Explanation

1 + 2 + 3 + 4 + 5 = 15.

Q41.

Dry run the factorial pseudocode for N = 4. What is printed?

Explanation

fact = 1 ร— 1 ร— 2 ร— 3 ร— 4 = 24.

Q42.

What is a dry run?

Explanation

A dry run executes the algorithm manually, recording variable values in a trace table.

Q43.

In a dry run, variable values at each step are recorded in a:

Explanation

A trace table records the values of variables as the algorithm is executed by hand.

Q44.

Testing the sum algorithm with N = 0 or N = 1 is an example of testing with:

Explanation

Boundary values test the edges of valid input; N = 5 is normal, and N = -3 or 'abc' are invalid.

Q45.

Using i < N instead of i <= N in the sum loop would cause:

Explanation

The loop would stop one step early and miss N, a logical error that a dry run can catch.

Q46.

On what basis are two algorithms for the same problem compared?

Explanation

Algorithms are compared by time complexity (number of steps/time) and space complexity (memory needed).

Q47.

Space complexity measures:

Explanation

Space complexity is the memory an algorithm requires; time complexity is the number of steps/time it takes.

Q48.

To check whether N = 101 is prime, how many divisions does the โˆšN method need, compared with 99 for dividing by every number from 2 to N โˆ’ 1?

Explanation

Dividing only by 2 to โˆš101 (about 10) needs 9 divisions, so it is much faster.

Q49.

Why is it enough to test divisors only up to โˆšN when checking whether N is prime?

Explanation

Factors come in pairs; if one factor is larger than โˆšN, its partner is smaller, so checking up to โˆšN is enough.

Q50.

What is coding?

Explanation

Coding converts the algorithm into a program; the program written by the programmer is called the source code.

Q51.

Which is a good coding practice?

Explanation

Good practices include meaningful names, comments, proper indentation, and testing with normal, boundary and invalid inputs.

Q52.

What is decomposition?

Explanation

Decomposition splits a big problem into smaller sub-problems whose solutions are combined to solve the whole.

Q53.

Which is NOT a benefit of decomposition?

Explanation

Decomposition makes problems easier to understand, supports teamwork, eases debugging and allows reuse; testing is still needed.

Q54.

A student report card system decomposed into 'input marks', 'calculate percentage', 'decide grade' and 'print report' is an example of:

Explanation

Breaking the system into smaller sub-tasks is decomposition.

Q55.

Which algorithm correctly checks whether a person is eligible to vote (age 18 or above)?

Explanation

Age 18 itself is eligible, so the condition must be age >= 18; using > 18 would wrongly reject 18-year-olds.