←Back to Subject
Notes
Notes
Study material and explanations
Diagrams
Diagrams
Visualize concepts easily
Mnemonics
Mnemonics
Tricks to remember faster
One Night Prep
One Night Prep
Short and focused revision
Revision
Revision
Quick summary and key points
Important Questions
Important Questions
Practice most relevant questions
Notes

Algorithms, Flowcharts & Design Notations Explained

Study material and explanations for Unit 1

Algorithms, Flowcharts & Design Notations

1. What is an Algorithm? (In Simple Words)

An Algorithm is simply a step-by-step list of instructions written in plain English to solve a specific problem.

Before opening any software to code, a programmer writes down the steps on paper. If your logic on paper is clear, writing the C++ code becomes super easy.

Real-Life Example: Think of making a cup of instant noodles:

  1. Boil 1.5 cups of water in a pan.
  2. Break noodle cake into pieces and add tastemaker.
  3. Cook for 2 minutes while stirring occasionally.
  4. Turn off the flame and serve hot.
    This step-by-step recipe is an algorithm!

5 Essential Properties of an Algorithm (Donald Knuth Criteria):

For college exams, remember these 5 points:

  1. Finiteness: The algorithm must stop after a fixed number of steps. It cannot run into an infinite loop forever.
  2. Definiteness: Every single step must be crystal clear and unambiguous. Never write confusing statements like “add some suitable number”.
  3. Input: It must take zero or more well-defined inputs from the user.
  4. Output: It must produce at least one correct result or output.
  5. Effectiveness: Every operation must be simple and practical enough to be done by hand on paper in a realistic amount of time.

2. What is a Flowchart?

A Flowchart is a diagram or visual picture of an algorithm.

Instead of reading paragraphs of text, you can glance at standard shapes (like rectangles and diamonds) connected by arrows to see how data moves from start to finish.

Standard ANSI Flowchart Symbols:

Standard Flowchart Symbols & Their Purpose
Oval / Rounded Box (Terminal)
Used for the START or STOP / END of the program.
Parallelogram (Input / Output)
Used for reading data from the user (INPUT A) or printing results (PRINT Sum).
Rectangle (Process)
Used for calculations and assigning values to variables (Sum = A + B).
Diamond (Decision / Condition)
Used for checking conditions (Is A > B?). It has two branch paths: YES or NO.
Arrows (Flowlines)
Shows the direction in which the program moves (usually top-to-bottom or left-to-right).
Small Circle (Connector)
Connects different parts of a big flowchart on the same page without crossing lines.

3. Practical Algorithm & Flowchart Examples

Example 1: Finding the Largest of Three Numbers (A, B, C)

Algorithm:

Step 1: START
Step 2: INPUT three numbers A, B, and C
Step 3: IF A > B and A > C THEN
           PRINT "A is the Largest"
        ELSE IF B > C THEN
           PRINT "B is the Largest"
        ELSE
           PRINT "C is the Largest"
Step 4: STOP

Flowchart Logic Map:

        [ START ]
            │
            ▼
     [ INPUT A, B, C ]
            │
            ▼
       Is A > B ?
       ├── YES ──▶  Is A > C ?
       │              ├── YES ──▶ [ PRINT "A is Largest" ] ──┐
       │              └── NO  ──▶ [ PRINT "C is Largest" ] ──┤
       │                                                     │
       └── NO  ──▶  Is B > C ?                               │
                      ├── YES ──▶ [ PRINT "B is Largest" ] ──┤
                      └── NO  ──▶ [ PRINT "C is Largest" ] ──┤
                                                             │
                                                             ▼
                                                         [ STOP ]

Example 2: Finding Factorial of a Number N (N!)

Remember: 5! = 5 * 4 * 3 * 2 * 1 = 120.

Algorithm:

Step 1: START
Step 2: INPUT integer N
Step 3: SET Fact = 1, i = 1
Step 4: REPEAT STEPS 5 to 6 WHILE i <= N
Step 5:    Fact = Fact * i
Step 6:    i = i + 1
Step 7: PRINT Fact
Step 8: STOP

Example 3: Checking if a Number is Prime

A prime number is a number greater than 1 that cannot be divided evenly by any number except 1 and itself (like 2, 3, 5, 7, 11).

Step 1: START
Step 2: INPUT integer N
Step 3: IF N <= 1 THEN
           PRINT "Not Prime" and GOTO Step 8
Step 4: SET i = 2, isPrime = True
Step 5: WHILE i * i <= N DO
           IF N % i == 0 THEN
              isPrime = False
              BREAK
           i = i + 1
Step 6: IF isPrime == True THEN
           PRINT "Number is Prime"
        ELSE
           PRINT "Number is Not Prime"
Step 7: STOP

4. Advantages & Limitations of Flowcharts

Advantages Limitations
Easy to Understand: Non-technical people and beginners can easily understand the program logic visually. Hard to Modify: If you want to change a small step, you often have to redraw the whole diagram from scratch.
Easy Bug Finding: Helps you spot logic errors or missing conditions before typing any code. Takes Too Much Space: Flowcharts for large software take up several pages and become messy.
Language Independent: The same flowchart can be used to write code in C++, Java, or Python. Can Get Confusing: If there are too many branches and loops, lines cross each other and look like spaghetti.

DAVV Exam Preparation Tips

Frequently Asked 5-Mark Questions:

  1. Explain the five essential characteristics of an algorithm defined by Donald Knuth.
    Model Answer: List and explain:
    • Finiteness: Must finish after a fixed number of steps.
    • Definiteness: Every step must be clear and clear-cut.
    • Input: Accepts zero or more inputs.
    • Output: Produces at least one result.
    • Effectiveness: Every operation must be simple and doable on paper.
  2. Draw standard flowchart symbols and state the purpose of each symbol.
    Model Answer: Draw neat diagrams with labels:
    • Oval: Start / Stop
    • Parallelogram: Input / Output
    • Rectangle: Calculation / Process
    • Diamond: Decision / Branching (Yes/No)
    • Circle: Connector

Frequently Asked 10-Mark Questions:

  1. Write an algorithm and draw a complete flowchart to check whether a given number is Prime or Composite.
    Model Answer:
    • Define what a prime number is (divisible only by 1 and itself).
    • Write the step-by-step algorithm using loop condition i * i <= N or i <= N/2.
    • Draw the complete ANSI flowchart with start terminal, input box, decision diamond, loop line, output box, and stop terminal.
    • Trace it with two sample inputs: N = 7 (Prime) and N = 9 (Composite/Not Prime).