DSA Simple Algorithm

DSA Simple Algorithm – Beginner Friendly Explanation (With Examples)
A simple algorithm in Data Structures & Algorithms (DSA) is a clear step-by-step method to solve a basic problem.
This is the starting point for understanding DSA.
What is a Simple Algorithm?
A simple algorithm:
Solves a basic problem
Has clear steps
Is easy to understand
Focuses on logic, not code
Example problems:
Add two numbers
Find largest number
Check even or odd
Calculate sum of array
Characteristics of a Simple Algorithm
- Input
- Output
- Finite steps
- Clear logic
- Correct result
Example 1: Algorithm to Add Two Numbers
Problem
Add two numbers and display the result.
Algorithm Steps
Start
Read number
aRead number
bCalculate
sum = a + bDisplay
sumStop
This is a classic DSA beginner algorithm.
Example 2: Algorithm to Check Even or Odd
Problem
Check whether a number is even or odd.
Algorithm Steps
Start
Read number
nIf
n % 2 == 0Print Even
Else
Print Odd
Stop
Example 3: Algorithm to Find Largest of Two Numbers
Algorithm Steps
Start
Read numbers
aandbIf
a > bPrint
ais largest
Else
Print
bis largest
Stop
Example 4: Algorithm to Find Sum of First N Numbers
Algorithm Steps
Start
Read
nSet
sum = 0For
i = 1tonsum = sum + i
Print
sumStop
Algorithm vs Program
| Algorithm | Program |
|---|---|
| Step-by-step logic | Code implementation |
| Language independent | Language dependent |
| Written in plain English | Written in C/C++/Java/Swift |
| Focus on thinking | Focus on syntax |
Why Learn Simple Algorithms First?
- Builds logical thinking
- Base for complex algorithms
- Required for exams
- Improves problem-solving
- Helps in coding interviews
Common Beginner Mistakes
- Skipping steps
- Writing code instead of logic
- Infinite steps
- No clear input/output
Exam / Interview Questions (Simple Algorithms)
Q1. What is an algorithm?
Step-by-step method to solve a problem
Q2. Is algorithm language dependent?
No
Q3. What comes first: algorithm or code?
Algorithm
Summary
- Algorithm = step-by-step solution
- Simple algorithms solve basic problems
- Easy to understand & write
- Foundation of DSA
- Must-learn for beginners

