Skip to main content

CHAPTER 9: ALGORITHM DESIGN AND PROBLEM-SOLVING

9.1 COMPUTATIONAL THINKING SKILLS

9.1.1 Abstraction

Definition: The process of removing unnecessary details to focus on essential features.

Need:

  • Manage complexity
  • Create models of real-world systems

Benefits:

  • Focus on what matters
  • Reusable solutions

9.1.2 Decomposition

Definition: Breaking down complex problems into smaller, manageable sub-problems.

Benefits:

  • Easier to solve smaller problems
  • Can work on different parts independently
  • Leads to modular programming (procedures/functions)

9.2 ALGORITHMS

9.2.1 Algorithm Representation

Methods:

  • Structured English
  • Flowchart
  • Pseudocode

Components:

  • Input
  • Process
  • Output

Basic Constructs:

  • Sequence (order of execution)
  • Selection (IF, CASE)
  • Iteration (loops)

9.2.2 Pseudocode Guidelines

Input/Output:

<TEXT>

INPUT variable
OUTPUT variable/value

Assignment:

<TEXT>

variable ← value

Selection:

<TEXT>

IF condition THEN
statements
ELSE
statements
END IF

CASE OF variable
value1 : statement
value2 : statement
OTHERWISE : statement
END CASE

Iteration:

<TEXT>

FOR counter ← start TO end
statements
NEXT counter

WHILE condition
statements
END WHILE

REPEAT
statements
UNTIL condition

9.2.3 Stepwise Refinement

Process:

  • Start with general solution
  • Gradually add detail
  • Continue until can be programmed