CSC115 ยท 2074 ยท 5 marks
What is algorithm? How is it different from flow chart? [2+3]
What is algorithm? How is it different from flow chart? [2+3]
Quick answer
An algorithm is a finite, step-by-step set of instructions to solve a problem. It must be clear, unambiguous, and always terminate.
Algorithm and Flowchart
What is an Algorithm? [2 marks]
Properties of a Good Algorithm:
| Property | Description |
|---|---|
| Finiteness | Must end after a finite number of steps |
| Definiteness | Each step must be clear and unambiguous |
| Input | Has zero or more inputs |
| Output | Produces at least one output |
| Effectiveness | Each step must be simple enough to be carried out |
Example: Algorithm to find the largest of two numbers
Step 1: Start.
Step 2: Read a and b.
Step 3: If a > b, print a. Else print b.
Step 4: Stop.
Difference Between Algorithm and Flowchart [3 marks]
A flowchart is a diagram that represents an algorithm using standard symbols connected by arrows. It shows the flow of control from start to end.
| Basis | Algorithm | Flowchart |
|---|---|---|
| Nature | Written in plain text or pseudocode as numbered steps | Represented as a diagram using standard symbols and arrows |
| Form | Textual / verbal description | Visual / graphical representation |
| Symbols | No special symbols required | Uses standard symbols (oval, rectangle, diamond, parallelogram, etc.) |
| Ease of Understanding | Easier to write but may be harder to follow for complex logic | Easier to understand visually, especially for branching and loops |
| Modification | Easy to modify by editing text | Harder to modify as the diagram must be redrawn |
| Purpose | Describes the logic of a solution in steps | Depicts the flow of control from start to end graphically |
Key Relationship
An algorithm and a flowchart both serve the same purpose: to plan and represent the solution to a problem before coding. The algorithm is the textual form, while the flowchart is its graphical equivalent. A flowchart is essentially a visual translation of an algorithm.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.