SlideShare a Scribd company logo
UNIT-I ALGORITHMIC PROBLEM
SOLVING
• By
K.Karthick, AP/CSE
Kongunadu College Of Engineering And
Technology, Trichy
Algorithm -Introduction
Introduction:
After the preparation of suitable plan for
developing the program by it’s logic, The
correct sequence and procedure of
instructions required to complete the task.
The algorithms is also used to refer the
logic of a program.
Definition:
Algorithm is defined as a step by step
procedure for solving any problem.
It is also a precise rule to specifying how to
solve a problem,
An algorithm is a sequence of finite
instructions used for calculation and data
processing.
Example:
STEP-1: Start
STEP-2: Read the value of radius r
STEP-3: Calculate Area=3.14*r*r
STEP-4: Print the area of circle
STEP-5: Stop
Characteristics of Algorithm
• An Algorithm contains step by step effective
information, It is not a computer program ,It is
one of the basic tool in problem solving.
Characteristics:
Algorithm has a finite number of inputs.
Every instruction should be precise and
unambiguous.
It looks like a normal English.
Effectiveness of each step is very important.
The desired output must obtained only after the
algorithm terminates.
The algorithm should written in sequence.
Qualities of an Algorithm
Different algorithm may perform the same task
with different set of instruction. Some algorithm is
better than the other in solving problem.
The following factors that determine the Quality of
algorithm are :
1.Time
2. Memory
3. Accuracy
4. Sequence
5. Generability
Building blocks of Algorithm
• Instruction/Statements
• State
• Control flow
• functions
Statements:
• Reserved words-words with predefined meaning
• Identifier- words created by programmer
• Literals- int, float, character, string
• Operators- unary, binary, ternary
State:
• Each step in an algorithm is a state.
• Start state, Input state, terminate in a defined
end-state, etc
Control flow:
• Control flow is the flow of control.
• It is used to determine what selection of code
is run in a program. It is the order in which the
program or statements are executed.
• It contains
(i) sequential
(iii) selective(decision making)
(iv) Iteration(loops)
1. Sequence Structure:
• the sequential control structure is used to
perform the actions one after another.
Eg:
Step 1: start
Step 2:Input first number as A
Step 3: Input second number as B
Step 4: set sum= A+B
Step 5: Print sum
Step 6:Stop
2. Selection Structure:
• Selection control structures (or) Decision
structures allows the program to make a
choice between two alternate paths whether
it is true or false.
Eg: Step 1: start
Step 2:Input first number as A
Step 3: Input second number as B
Step 4: IF A=B
print “equal”
ELSE
print ”Not equal”
[End of IF]
step 5: stop
IF THEN STRUCTURE
IF THEN ELSE STRUCTURE
CASE STRUCTURE
3. Iteration(Loops):
Iterative structures are used when part of
the program is to be executed several times.
Eg:
Step 1: [initialize]set I=1,N=10
Step 2:Repeat steps 3 & 4 while I<=N
Step 3: Print I
Step 4: set I=I+1
[End of the loop]
Step 5: end
Functions:
• Functions are “self contained” modules of
code that accomplish specific task.
• Functions usually “take in” data, process it
and “return “ result.
• Once a function is written, it can be used over
and over again.
• Functions can be “called” from the inside of
other functions.
Notation
1. Pseudocode
2. Flow chart
3. Programming language
Pseudocode:
pseudo means imitation
code means instruction
• Pseudo codes cannot be run, and there is no real
formatting or rules.
• Pseudo codes are an outline of a program that can
easily be converted into programming statements.
• Pseudo codes are not really codes, it is a mix of
choice of programming languages and your
preferred human languages.
Eg: sum of two numbers
READ the value of variables a and B
sum= A+B
WRITE the output of sum
Basic guidelines for writing pseudocode
1.Write only one statement per line
2. Capitalize initial keyword(keywords should be
capital letters)
Eg: READ,WRITE,IF,ELSE,ENDIF,WHILE,ENDWHILE,
REPEAT,UNTIL
3. Indent to show hierarchy
4. End multiline structures
ended properly which provides
clarity ex: ENDIF , END
• 5. Keep statements language independent
• user can write in whatever language they are most
comfortable .
• Advantages
– Can be easily done on a word processor
– Easily modified
– It is simple like English statements
– No special symbols used
Eg: pseudocode to find leap year
READ the value of year
IF (year%4==0)THEN
WRITE the year is a leap year
ELSE
WRITE the year is not a leap year
ENDIF
stop
Flowchart
• Flowchart is a pictorial representation of an
algorithm.
• A flowchart uses different shaped symbols for
representing different instruction and this
information written into small boxes using
clear statement.
• Here lines and arrow mark represent flow of
operation.
Aim of flowchart
• Program preparation is simplified
• Easier to understand
• Provide effective documentation
• Easy to analyze and compare with various
method
• Reviewing and debugging is easy
Flowchart Basic symbols
• Flow lines
• Start and Terminal symbols
• Input/output symbols
• Process symbols
• Decision symbols
• Connectors
RULES FOR DRAWING A FLOWCHART
• The standard symbols only used.
• Arrowhead represent direction of flow control
• Usual procedure of direction is top to bottom
• Only one flow line should come process
symbols and one flow line out from each
symbols.
• <0 >0
=0
Algorithm to perform addition
Step-1: Start the program
Step-2: Read the input values a,b
Step-3:Perform addition using the formula
c=a+b;
Step-4:write the result c
Step-5:stop the program.
Basic design structures in flowchart
Three basic structure available There are:
1 . Sequence structure:
It is simplest method , Here flow is goes to only
one direction that is top to bottom.
start
C=a+b
Read a b
Write c
stop
2.Selection structure
•
• false TrueIs
a>b
Write a is
Big
Write b
is big
stop
Read a,b
start
3. Loop structure
Top tested loop
No
Yes
start
Add 1 to count
Read
count =0
Write
count
If
count<5
Stop
Bottom tested loop
start
Add 1 to count
Read
count =0
Write
count
If
count<5
Stop
Advantages of Flowcharts
1. To understand the logic clearly
2. Better communication
3. Effective analysis (problem can be solved)
4. Effective synthesis
5. Effective coding
6. Proper program documentation
7. Systematic Debugging
8. Systematic testing
9. Efficient Program Maintenance.
Programming Language
Types:
(i)Machine language (eg: 01001101)
(ii)Assembly language (eg:mnemonics)
start
add x,y
sub x,y
(iii)High level language
Main()
{
if(x>y)
{
max=x;
}
else
{
max=y;
}
……………
}

More Related Content

PDF
Algorithm and Programming (Introduction of Algorithms)
PDF
Algorithmic problem sloving
PPT
Unit 1 python (2021 r)
PDF
Introduction to Problem Solving Techniques- Python
PPTX
Unit 1. Problem Solving with Computer
PPTX
Computer programming and utilization
PPTX
Algorithms
PDF
Unit 1-problem solving with algorithm
Algorithm and Programming (Introduction of Algorithms)
Algorithmic problem sloving
Unit 1 python (2021 r)
Introduction to Problem Solving Techniques- Python
Unit 1. Problem Solving with Computer
Computer programming and utilization
Algorithms
Unit 1-problem solving with algorithm

What's hot (20)

PPT
algorithm
PPTX
Programming the basic computer
PPTX
Raptor tool
PDF
Problem Solving Techniques and Introduction to C
PPTX
Valuable Information on Lexical Analysis in Compiler Design
PPTX
Programming process and flowchart
PPT
Lecture 4
PPT
Cmp104 lec 7 algorithm and flowcharts
PPT
Program Logic Formulation - Ohio State University
PPTX
FPL -Part 2 ( Sem - I 2013)
PPTX
Programming flowcharts for C Language
PPT
Chapter 02 - Problem Solving
PPTX
Algorithm and Flowcharts
PPTX
Cs1123 2 comp_prog
PPTX
The analysis synthesis model of compilation
PPTX
STRUCTURED PROGRAMMING Chap2
PDF
Algorithm and c language
PDF
Lesson 2 beginning the problem solving process
PPTX
Algorithm &amp; flowchart
PDF
Problem solving (C++ Programming)
algorithm
Programming the basic computer
Raptor tool
Problem Solving Techniques and Introduction to C
Valuable Information on Lexical Analysis in Compiler Design
Programming process and flowchart
Lecture 4
Cmp104 lec 7 algorithm and flowcharts
Program Logic Formulation - Ohio State University
FPL -Part 2 ( Sem - I 2013)
Programming flowcharts for C Language
Chapter 02 - Problem Solving
Algorithm and Flowcharts
Cs1123 2 comp_prog
The analysis synthesis model of compilation
STRUCTURED PROGRAMMING Chap2
Algorithm and c language
Lesson 2 beginning the problem solving process
Algorithm &amp; flowchart
Problem solving (C++ Programming)
Ad

Similar to Unit 1 psp (20)

PPTX
Introduction to problem solving Techniques
PDF
Python Unit 1.pdfPython Notes for Bharathiar university syllabus
PPTX
UNIT I.pptxpython unit 1 engineering full unit completed
PDF
GE3151 PSPP _Unit 1 notes and Question bank.pdf
PPTX
Data Structures_Introduction to algorithms.pptx
PPTX
UNIT 1.pptx
PPTX
Lesson 1 of c programming algorithms and flowcharts.pptx
PPT
Proble, Solving & Automation
PPT
UNIT- 3-FOC.ppt
PPTX
Algorithm and flowchart.pptx
PPTX
UNIT-1.pptx python for engineering first year students
PDF
GE8151 notes pdf.pdf
PDF
Fundamental of Information Technology - UNIT 6
DOCX
programming concept
PPT
PDF
Cse115 lecture03problemsolving
PPT
Programming algorithms and flowchart.ppt
PPTX
lecture 5
PPTX
Introduction to computer science
PPTX
Algorithm and flowchart
Introduction to problem solving Techniques
Python Unit 1.pdfPython Notes for Bharathiar university syllabus
UNIT I.pptxpython unit 1 engineering full unit completed
GE3151 PSPP _Unit 1 notes and Question bank.pdf
Data Structures_Introduction to algorithms.pptx
UNIT 1.pptx
Lesson 1 of c programming algorithms and flowcharts.pptx
Proble, Solving & Automation
UNIT- 3-FOC.ppt
Algorithm and flowchart.pptx
UNIT-1.pptx python for engineering first year students
GE8151 notes pdf.pdf
Fundamental of Information Technology - UNIT 6
programming concept
Cse115 lecture03problemsolving
Programming algorithms and flowchart.ppt
lecture 5
Introduction to computer science
Algorithm and flowchart
Ad

Recently uploaded (20)

PPT
Occupational Health and Safety Management System
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
Visual Aids for Exploratory Data Analysis.pdf
PPTX
Fundamentals of Mechanical Engineering.pptx
PPTX
Management Information system : MIS-e-Business Systems.pptx
PDF
Abrasive, erosive and cavitation wear.pdf
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PPTX
"Array and Linked List in Data Structures with Types, Operations, Implementat...
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PDF
Design Guidelines and solutions for Plastics parts
PPTX
Software Engineering and software moduleing
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PDF
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PPTX
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
PPT
Total quality management ppt for engineering students
Occupational Health and Safety Management System
R24 SURVEYING LAB MANUAL for civil enggi
Visual Aids for Exploratory Data Analysis.pdf
Fundamentals of Mechanical Engineering.pptx
Management Information system : MIS-e-Business Systems.pptx
Abrasive, erosive and cavitation wear.pdf
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
"Array and Linked List in Data Structures with Types, Operations, Implementat...
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
Design Guidelines and solutions for Plastics parts
Software Engineering and software moduleing
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
Total quality management ppt for engineering students

Unit 1 psp

  • 1. UNIT-I ALGORITHMIC PROBLEM SOLVING • By K.Karthick, AP/CSE Kongunadu College Of Engineering And Technology, Trichy
  • 2. Algorithm -Introduction Introduction: After the preparation of suitable plan for developing the program by it’s logic, The correct sequence and procedure of instructions required to complete the task. The algorithms is also used to refer the logic of a program.
  • 3. Definition: Algorithm is defined as a step by step procedure for solving any problem. It is also a precise rule to specifying how to solve a problem, An algorithm is a sequence of finite instructions used for calculation and data processing. Example: STEP-1: Start STEP-2: Read the value of radius r STEP-3: Calculate Area=3.14*r*r STEP-4: Print the area of circle STEP-5: Stop
  • 4. Characteristics of Algorithm • An Algorithm contains step by step effective information, It is not a computer program ,It is one of the basic tool in problem solving. Characteristics: Algorithm has a finite number of inputs. Every instruction should be precise and unambiguous. It looks like a normal English. Effectiveness of each step is very important. The desired output must obtained only after the algorithm terminates. The algorithm should written in sequence.
  • 5. Qualities of an Algorithm Different algorithm may perform the same task with different set of instruction. Some algorithm is better than the other in solving problem. The following factors that determine the Quality of algorithm are : 1.Time 2. Memory 3. Accuracy 4. Sequence 5. Generability
  • 6. Building blocks of Algorithm • Instruction/Statements • State • Control flow • functions
  • 7. Statements: • Reserved words-words with predefined meaning • Identifier- words created by programmer • Literals- int, float, character, string • Operators- unary, binary, ternary State: • Each step in an algorithm is a state. • Start state, Input state, terminate in a defined end-state, etc
  • 8. Control flow: • Control flow is the flow of control. • It is used to determine what selection of code is run in a program. It is the order in which the program or statements are executed. • It contains (i) sequential (iii) selective(decision making) (iv) Iteration(loops)
  • 9. 1. Sequence Structure: • the sequential control structure is used to perform the actions one after another. Eg: Step 1: start Step 2:Input first number as A Step 3: Input second number as B Step 4: set sum= A+B Step 5: Print sum Step 6:Stop
  • 10. 2. Selection Structure: • Selection control structures (or) Decision structures allows the program to make a choice between two alternate paths whether it is true or false. Eg: Step 1: start Step 2:Input first number as A Step 3: Input second number as B Step 4: IF A=B print “equal” ELSE print ”Not equal” [End of IF] step 5: stop
  • 12. IF THEN ELSE STRUCTURE
  • 14. 3. Iteration(Loops): Iterative structures are used when part of the program is to be executed several times. Eg: Step 1: [initialize]set I=1,N=10 Step 2:Repeat steps 3 & 4 while I<=N Step 3: Print I Step 4: set I=I+1 [End of the loop] Step 5: end
  • 15. Functions: • Functions are “self contained” modules of code that accomplish specific task. • Functions usually “take in” data, process it and “return “ result. • Once a function is written, it can be used over and over again. • Functions can be “called” from the inside of other functions.
  • 16. Notation 1. Pseudocode 2. Flow chart 3. Programming language
  • 17. Pseudocode: pseudo means imitation code means instruction • Pseudo codes cannot be run, and there is no real formatting or rules. • Pseudo codes are an outline of a program that can easily be converted into programming statements. • Pseudo codes are not really codes, it is a mix of choice of programming languages and your preferred human languages.
  • 18. Eg: sum of two numbers READ the value of variables a and B sum= A+B WRITE the output of sum
  • 19. Basic guidelines for writing pseudocode 1.Write only one statement per line 2. Capitalize initial keyword(keywords should be capital letters) Eg: READ,WRITE,IF,ELSE,ENDIF,WHILE,ENDWHILE, REPEAT,UNTIL 3. Indent to show hierarchy 4. End multiline structures ended properly which provides clarity ex: ENDIF , END
  • 20. • 5. Keep statements language independent • user can write in whatever language they are most comfortable . • Advantages – Can be easily done on a word processor – Easily modified – It is simple like English statements – No special symbols used
  • 21. Eg: pseudocode to find leap year READ the value of year IF (year%4==0)THEN WRITE the year is a leap year ELSE WRITE the year is not a leap year ENDIF stop
  • 22. Flowchart • Flowchart is a pictorial representation of an algorithm. • A flowchart uses different shaped symbols for representing different instruction and this information written into small boxes using clear statement. • Here lines and arrow mark represent flow of operation.
  • 23. Aim of flowchart • Program preparation is simplified • Easier to understand • Provide effective documentation • Easy to analyze and compare with various method • Reviewing and debugging is easy
  • 24. Flowchart Basic symbols • Flow lines • Start and Terminal symbols • Input/output symbols • Process symbols • Decision symbols • Connectors
  • 25. RULES FOR DRAWING A FLOWCHART • The standard symbols only used. • Arrowhead represent direction of flow control • Usual procedure of direction is top to bottom • Only one flow line should come process symbols and one flow line out from each symbols. • <0 >0 =0
  • 26. Algorithm to perform addition Step-1: Start the program Step-2: Read the input values a,b Step-3:Perform addition using the formula c=a+b; Step-4:write the result c Step-5:stop the program.
  • 27. Basic design structures in flowchart Three basic structure available There are: 1 . Sequence structure: It is simplest method , Here flow is goes to only one direction that is top to bottom. start C=a+b Read a b Write c stop
  • 28. 2.Selection structure • • false TrueIs a>b Write a is Big Write b is big stop Read a,b start
  • 29. 3. Loop structure Top tested loop No Yes start Add 1 to count Read count =0 Write count If count<5 Stop
  • 30. Bottom tested loop start Add 1 to count Read count =0 Write count If count<5 Stop
  • 31. Advantages of Flowcharts 1. To understand the logic clearly 2. Better communication 3. Effective analysis (problem can be solved) 4. Effective synthesis 5. Effective coding 6. Proper program documentation 7. Systematic Debugging 8. Systematic testing 9. Efficient Program Maintenance.
  • 32. Programming Language Types: (i)Machine language (eg: 01001101) (ii)Assembly language (eg:mnemonics) start add x,y sub x,y