2074 4

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]

C ProgrammingChapter 1: Problem Solving with ComputerAlgorithms and Flowchart

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:

PropertyDescription
FinitenessMust end after a finite number of steps
DefinitenessEach step must be clear and unambiguous
InputHas zero or more inputs
OutputProduces at least one output
EffectivenessEach 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.

BasisAlgorithmFlowchart
NatureWritten in plain text or pseudocode as numbered stepsRepresented as a diagram using standard symbols and arrows
FormTextual / verbal descriptionVisual / graphical representation
SymbolsNo special symbols requiredUses standard symbols (oval, rectangle, diamond, parallelogram, etc.)
Ease of UnderstandingEasier to write but may be harder to follow for complex logicEasier to understand visually, especially for branching and loops
ModificationEasy to modify by editing textHarder to modify as the diagram must be redrawn
PurposeDescribes the logic of a solution in stepsDepicts 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.