Unit 1: Problem Solving and Programming Fundamentals
Table of Contents
Introduction to Problem Solving
Problem-solving is the process of identifying a problem, breaking it down into smaller, manageable parts, and developing a logical, step-by-step solution to solve it.
In computer programming, this means translating a real-world problem into a set of instructions (an algorithm) that a computer can understand and execute to produce a desired output.
Algorithms
An algorithm is a finite, well-defined, step-by-step set of instructions or rules designed to solve a specific problem.
Algorithms are written in pseudo-code, which is a plain English, informal description of the steps, rather than in a specific programming language.
Characteristics of a Good Algorithm
- Input: It must have zero or more well-defined inputs.
- Output: It must have one or more well-defined outputs.
- Finiteness: It must terminate after a finite number of steps.
- Definiteness: Each step must be clear, precise, and unambiguous.
- Effectiveness: Each step must be basic enough to be carried out, in principle, by a person using only pencil and paper.
Flowcharts
A flowchart is a graphical or visual representation of an algorithm. It uses standard symbols to show the sequence of operations and the flow of logic.
Common Flowchart Symbols
| Symbol | Name | Function |
|---|---|---|
| Oval | Terminator | Represents the Start or End of the algorithm. |
| Rectangle | Process | Represents a calculation, assignment, or any data manipulation. (e.g., `Set count = 0`) |
| Parallelogram | Input / Output | Represents reading data (e.g., `Read N`) or printing data (e.g., `Print Sum`). |
| Diamond | Decision | Used for conditional statements. Has one entry point and two exit points (e.g., Yes/No). |
| Arrows | Flow Lines | Connect the symbols and show the direction of logic flow. |
Control Structures (Decision Making)
These structures allow the algorithm to make choices and execute different paths based on certain conditions.
1. if-then
Executes a block of code only if a condition is true.
IF (condition is true) THEN Execute this statement ENDIF