SlideShare a Scribd company logo
RECAP
1
PROGRAMMING IN C
2
3
RECAP
4
• Problem solving is the systematic approach to define the problem and
creating number of solutions.
• The problem-solving process starts with the problem specifications and
ends with a Correct program.
• Problem solving technique is a set of techniques that helps in
providing logic for solving a problem.
• The problem-solving Techniques can be expressed in the form of
Algorithms, Flowcharts, Pseudo code and Programs
PROBLEMSOLVING
5
STEPS IN PROBLEM SOLVING
6
• Problem definition
• Problem analysis
• Algorithm Development
• Program coding
• Program testing and Debugging
• Documentation
Problem Definition - understand the problem
Define or specify the problem by answering the following questions:
• What the computer program do?
• What tasks will it perform?
• What kind of data will it use and where will it get the data?
• What will be the output of the program?
• How will the program interact with the computer user?
Problem Analysis – determine the requirements
Analysing the problem involves
• Identifying the problem inputs
• Check any additional requirements or constraints
• Determine the required format of the results to be displayed 7
Algorithm Development - develop a step by step procedure to solve
the problem
• Find an algorithm for its solution
• An algorithm is a finite set of steps defining the solution
of a particular problem
• The algorithm development can be expressed by Pseudo code and
Flowchart
Program Coding - uses a programming language to write or
implement the actual programming instructions
Coding or programming is the process of translating the algorithm into
the syntax of a given programming language.
• Convert each step in the algorithm into one or more statements in a
programming language
8
Program Testing and Debugging
• Program testing means running the program and executing all its
instructions or functions step by step.
• Debugging is the process of finding and correcting program code mistakes.
• Errors in the program may be Syntax errors, Run time errors and Logic
Errors(bugs)
Documentation
• Internal Documentation: It consists of remarks or comments written with the
program instructions to explain what is being done in the program
• External Documentation: It is made up of the manuals or help menus written
about the solution
9
Three ways of Representation
• Algorithm
• Pseudo-code
• Flowchart
Algorithm
• Set of step-by-step instructions that perform a specific task or
operation
REPRESENTATION OF PROBLEM SOLVING SOLUTION
10
Pseudo-code
• Set of instructions that mimic programming language
instructions
REPRESENTATION OF SOLUTION
11
D I F F E R E N C E B E T W E E N A L G O R I T H M A N D P S E U D O C O D E
• An algorithm is a precise and well-defined procedure
• Pseudocode is a more informal and high-level representation of an algorithm.
12
Representation of Solution
Flowchart
• Schematic representation of an
algorithm
REPRESENTATION OF SOLUTION
13
14
• How to cut a circular cake into 8 equal pieces only with 3 cuts
15
16
ALGORITHM IMPLEMENTATION
17
• An algorithm is a detailed step by step instructions for solving a problem in a
finite amount of time
• Used in solving mathematical or sometimes computational problems
11
Algorithm
11
Algorithm
Steps involved in algorithm development
An algorithm can be defined as “a complete, unambiguous, finite number of logical steps
for solving a specific problem “ .
Step1. Identification of input: For an algorithm, there are quantities to be supplied
called input and these are fed externally. The input is to be indentified first for any
specified problem.
Step2: Identification of output: From an algorithm, at least one quantity is produced,
called for any specified problem.
Step3 : Identification the processing operations : All the calculations to be
performed in order to lead to output from the input are to be identified in an orderly
manner.
11
Algorithm
Steps involved in algorithm development
Step 4: Processing Definiteness:
The instruction composing the algorithm must be clear and there should not be
any ambiguity in them.
Step5 : Processing Finiteness :
If we go through the algorithm, then for all cases, the algorithm should
terminate after a finite number of steps.
Step6 : Possessing Effectiveness :
The instructions in the algorithm must be sufficiently basic and in practice they
can be carries out easily
Introduction to Algorithm
• Input
• Output
• Finiteness
• Definiteness/Concise
• Effectiveness
Characteristics of Algorithm
12
Input
• Algorithm should have well-defined inputs
Output
• Algorithm should have well-defined outputs, and should match the desired
output
Finiteness
• Algorithms must terminate after a finite number of steps
Definiteness/Concise
• Each step must be precisely defined
• Actions to carryout must be unambiguously (not confusing) specified
Effectiveness
• All operations must achieve the goal
13
Characteristics of Algorithm
23
A Jeroo starts at (0, 0) facing East with no flowers in its pouch. There is a flower at location (3, 0).
Write an algorithm that directs the Jeroo to pick the flower and plant it at location (3, 2). After
planting the flower, the Jeroo should hop one space East and stop. There are no other nets,
flowers, or Jeroos on the island.
WRITE ALGORITHM – SIMPLE EXAMPLE
1.The flower is exactly three spaces ahead of the jeroo.
2.The flower is to be planted exactly two spaces South of its current location.
3.The Jeroo is to finish facing East one space East of the planted flower.
4.There are no nets to worry about.
Get the flower
Put the flower
Hop East
Get the flower
Hop 3 times
Pick the flower
Put the flower
Turn right Hop 2 times Plant a flower
Hop East
Turn left Hop once
Analysis of the Problem
High-level Algorithm
Detailed Algorithm
WRITE ALGORITHM
Example for Algorithm
Problem - Write an Algorithm to Multiply two numbers
Step 1 - Start
Step 2 - Declare three Integers a, b, c
Step 3 - Define Values of a, b
Step 4 - Multiplication of a, b
Step 5 - Store the Output of step 4 to c
Step 6 - Print the value c
Step 7 - Stop
Example for Algorithm:
14
Applications of Algorithm
• Google Search
• Uber App
• Video Games
• NASA’s Manipulation of Space Ships
• FaceBook Timeline
Applications of Algorithm:
15
Advantages & Disadvantages of Algorithm
Advantages
• It makes the representation of a solution to a problem easy, which makes
easier in understanding
• It can be easily understood by a person without even having the knowledge
of programming
• It follows a definite procedure
Disadvantages
• It takes very long in writing an algorithm
• It is not a computer program, neither it helps in reducing the difficulties while
writing a code
16
L E T S H A V E A B R E A K
• A doctor’s son’s father was not a doctor. How is this possible?
• A man was born in 1945, but he’s only 30 years old now. How is
this possible?
28
L E T S H A V E A B R E A K
• A doctor’s son’s father was not a doctor. How is this possible?
• The doctor is the mother.
• A man was born in 1945, but he’s only 30 years old now. How is
this possible?
• 1945 was the number of the hospital room.
29
Summary
• Overview of Computer Programming
• Problem Solving
• Steps in Problem Solving
• Representation of Problem Solving Solution
• Algorithm
• Characteristics of Algorithm
• Example for Algorithm
• Applications of Algorithm
• Advantages & Disadvantages of Algorithm
Introduction to Problem Solving, Algorithm Implementation
17
PEER LEARNING
1. Write an algorithm to calculate your cut-off?
2. Steps to admit in an engineering college through counseling
3. Write an algorithm to build a Calculator
4. Addition of three numbers entered by the user
5. Find the largest number among three different numbers
6. Check whether a number is a prime number or not
7. Factorial of a number entered by the user
19
Introduction to Problem Solving, Introduction to Algorithm
Try Yourself
1. Mary Williams needs to change a Fahrenheit temperature to Celsius. Use
the Fahrenheit temperature of 80 degrees to test your solution.
Celsius = ((Fahrenheit - 32) * 5/9)
2. Calculate the area for a circle and display the result with proper output
message. (Hint = ^2)
𝐴𝑟𝑒𝑎 𝜋𝑟
19
ntroduction to Problem Solving, Introduction to Idea of Algorithm
33
TOP DOWN DESIGN
34
• A method of breaking a problem down into smaller, less complex pieces from the
initial overall problem.
• Most “good” problems are too complex to solve in just one step, so we divide the
problem up into smaller manageable pieces, solve each one of them and then
bring everything back together again.
• The process of making the steps more and more specific in top-down design is
called stepwise refinement.
• Top-Down Design (Divide-and-Conquer)
• Write functions top-down
• Test functions bottom-up
• Practicality: May help to write stubs (simulated functions as
temporary placeholders in top-down design)
35
• A parent node is one that has other nodes descending from it - we say that a
node is the parent of some other node.
• In the same way a child node is one that descends from a parent node.
• The root node can only be a parent node.
• Leaf nodes can only be child nodes.
• Intermediate nodes can be both parent or child nodes depending on the
desired perspective.
• All nodes in the tree are children of the root node. Conversely the root node is
a parent of all other nodes in the tree.
• Sibling nodes are two or more nodes at the same level which are descended
from the same parent.
• The depth (or height) of a tree refers to the number of levels in the tree.
• The width of a tree refers to the maximum number of nodes at any one level. 36
T O P - D O W N D E S I G N
• A software development technique that imposes a hierarchical structure on the design of the
program.
• It starts out by defining the solution at the highest level of functionality and breaking it down
further and further into small routines that can be easily documented and coded.
• Also known as:
• Divide and conquer
• Stepwise refinement
• Structured programming
37
A D V A N T A G E S O F T O P - D O W N D E S I G N
• Breaking the problem into parts helps to clarify what needs to be done.
• At each step of refinement, the new parts become less complicated and, therefore, easier to
figure out.
• Breaking the problem into parts allows more than one person to work on the solution.
38
SIMPLE STRATEGIES FOR DEVELOPING
ALGORITHMS
39
• Developing an algorithm is a very important step in problem-solving.
There are different types of strategies that could be used to develop an
algorithm to solve a problem.
• Two of the most frequently used strategies are:
– Iteration
– Recursion
1. Iterations:
A sequence of statements is executed until a specified condition is
true is called iterations.
1.
2.
for loop
While loop
For loop :
FOR( start-value to end-value) DO
Statement
...
ENDFOR
40
Example: Print n natural numbers
BEGIN
GET n
INITIALIZE i=1
FOR (i<=n) DO
PRINT i
i=i+1
ENDFOR
END
41
Syntax for While:
WHILE (condition) DO
Statement
...
ENDWHILE
Print n
natural
numbers
BEGIN
GET n
INITIALIZE i=1
WHILE(i<=n) DO
PRINT i
i=i+1
ENDWHILE
END
42
• Recursion is a technique in which a function calls itself
repeatedly until a concluding situation happen.
• A function which utilizes this technique is called a recursive function
• Using recursive algorithm, certain problems can be solved quite easily.
• Examples of such problems are
• Towers of Hanoi (TOH)
• In order/Preorder/Post order Tree Traversals,
• DFS of Graph, etc.
RECURSION
43
Ad

Recommended

AOA Week 01.ppt
AOA Week 01.ppt
INAM352782
 
PPS_Unit 1.pptx
PPS_Unit 1.pptx
KundanBhatkar
 
UNIT-1.pptx python for engineering first year students
UNIT-1.pptx python for engineering first year students
SabarigiriVason
 
Algorithms and how to write an algorithms
Algorithms and how to write an algorithms
Ahmed Nobi
 
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
dinesh620610
 
s-INTRODUCTION TO PROBLEM SOLVING PPT.pptx
s-INTRODUCTION TO PROBLEM SOLVING PPT.pptx
ShamithRai
 
Study Material for Problem Solving Techniques
Study Material for Problem Solving Techniques
Bobby Murugesan
 
Problem solving
Problem solving
hamza239523
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
CC-112-Lec.1.ppsx
CC-112-Lec.1.ppsx
Aamir Shahzad
 
Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1
To Sum It Up
 
Algorithm.pdf
Algorithm.pdf
MIT,Imphal
 
Algo_Lecture01.pptx
Algo_Lecture01.pptx
ShaistaRiaz4
 
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
HarshJha34
 
Chp-1 DAA (2).pptx design analysis and algoritham presentation
Chp-1 DAA (2).pptx design analysis and algoritham presentation
vaishnavbhavna17
 
Design and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit one
ssuserb7c8b8
 
Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
rajkumar1631010038
 
Problem solving methodology
Problem solving methodology
Prof. Dr. K. Adisesha
 
CP4151 Advanced data structures and algorithms
CP4151 Advanced data structures and algorithms
Sheba41
 
Problem Solving and Algorithm Design in Computer Science
Problem Solving and Algorithm Design in Computer Science
RaviRaval36
 
Introduction to problem solving in c++
Introduction to problem solving in c++
Online
 
Algorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo code
hamza javed
 
Algorithms and problem solving.pptx
Algorithms and problem solving.pptx
aikomo1
 
Programming C ppt for learning foundations
Programming C ppt for learning foundations
ssuser65733f
 
1. Introduction to Problem Solving first lesson .ppt
1. Introduction to Problem Solving first lesson .ppt
Primary2Primary2
 
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
Salini P
 
UNIT 1- Design Analysis of algorithms and its working
UNIT 1- Design Analysis of algorithms and its working
Bobby Pra A
 
Unit no_1.pptx
Unit no_1.pptx
Ganeshpatil499846
 
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 

More Related Content

Similar to Programming in C - Problem Solving using C (20)

Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
CC-112-Lec.1.ppsx
CC-112-Lec.1.ppsx
Aamir Shahzad
 
Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1
To Sum It Up
 
Algorithm.pdf
Algorithm.pdf
MIT,Imphal
 
Algo_Lecture01.pptx
Algo_Lecture01.pptx
ShaistaRiaz4
 
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
HarshJha34
 
Chp-1 DAA (2).pptx design analysis and algoritham presentation
Chp-1 DAA (2).pptx design analysis and algoritham presentation
vaishnavbhavna17
 
Design and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit one
ssuserb7c8b8
 
Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
rajkumar1631010038
 
Problem solving methodology
Problem solving methodology
Prof. Dr. K. Adisesha
 
CP4151 Advanced data structures and algorithms
CP4151 Advanced data structures and algorithms
Sheba41
 
Problem Solving and Algorithm Design in Computer Science
Problem Solving and Algorithm Design in Computer Science
RaviRaval36
 
Introduction to problem solving in c++
Introduction to problem solving in c++
Online
 
Algorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo code
hamza javed
 
Algorithms and problem solving.pptx
Algorithms and problem solving.pptx
aikomo1
 
Programming C ppt for learning foundations
Programming C ppt for learning foundations
ssuser65733f
 
1. Introduction to Problem Solving first lesson .ppt
1. Introduction to Problem Solving first lesson .ppt
Primary2Primary2
 
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
Salini P
 
UNIT 1- Design Analysis of algorithms and its working
UNIT 1- Design Analysis of algorithms and its working
Bobby Pra A
 
Unit no_1.pptx
Unit no_1.pptx
Ganeshpatil499846
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1
To Sum It Up
 
Algo_Lecture01.pptx
Algo_Lecture01.pptx
ShaistaRiaz4
 
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
HarshJha34
 
Chp-1 DAA (2).pptx design analysis and algoritham presentation
Chp-1 DAA (2).pptx design analysis and algoritham presentation
vaishnavbhavna17
 
Design and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit one
ssuserb7c8b8
 
Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
rajkumar1631010038
 
CP4151 Advanced data structures and algorithms
CP4151 Advanced data structures and algorithms
Sheba41
 
Problem Solving and Algorithm Design in Computer Science
Problem Solving and Algorithm Design in Computer Science
RaviRaval36
 
Introduction to problem solving in c++
Introduction to problem solving in c++
Online
 
Algorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo code
hamza javed
 
Algorithms and problem solving.pptx
Algorithms and problem solving.pptx
aikomo1
 
Programming C ppt for learning foundations
Programming C ppt for learning foundations
ssuser65733f
 
1. Introduction to Problem Solving first lesson .ppt
1. Introduction to Problem Solving first lesson .ppt
Primary2Primary2
 
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
Salini P
 
UNIT 1- Design Analysis of algorithms and its working
UNIT 1- Design Analysis of algorithms and its working
Bobby Pra A
 

Recently uploaded (20)

Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
 
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Revista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
 
Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...
Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...
Himalayan Group of Professional Institutions (HGPI)
 
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
 
Revista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
Ad

Programming in C - Problem Solving using C

  • 4. 4
  • 5. • Problem solving is the systematic approach to define the problem and creating number of solutions. • The problem-solving process starts with the problem specifications and ends with a Correct program. • Problem solving technique is a set of techniques that helps in providing logic for solving a problem. • The problem-solving Techniques can be expressed in the form of Algorithms, Flowcharts, Pseudo code and Programs PROBLEMSOLVING 5
  • 6. STEPS IN PROBLEM SOLVING 6 • Problem definition • Problem analysis • Algorithm Development • Program coding • Program testing and Debugging • Documentation
  • 7. Problem Definition - understand the problem Define or specify the problem by answering the following questions: • What the computer program do? • What tasks will it perform? • What kind of data will it use and where will it get the data? • What will be the output of the program? • How will the program interact with the computer user? Problem Analysis – determine the requirements Analysing the problem involves • Identifying the problem inputs • Check any additional requirements or constraints • Determine the required format of the results to be displayed 7
  • 8. Algorithm Development - develop a step by step procedure to solve the problem • Find an algorithm for its solution • An algorithm is a finite set of steps defining the solution of a particular problem • The algorithm development can be expressed by Pseudo code and Flowchart Program Coding - uses a programming language to write or implement the actual programming instructions Coding or programming is the process of translating the algorithm into the syntax of a given programming language. • Convert each step in the algorithm into one or more statements in a programming language 8
  • 9. Program Testing and Debugging • Program testing means running the program and executing all its instructions or functions step by step. • Debugging is the process of finding and correcting program code mistakes. • Errors in the program may be Syntax errors, Run time errors and Logic Errors(bugs) Documentation • Internal Documentation: It consists of remarks or comments written with the program instructions to explain what is being done in the program • External Documentation: It is made up of the manuals or help menus written about the solution 9
  • 10. Three ways of Representation • Algorithm • Pseudo-code • Flowchart Algorithm • Set of step-by-step instructions that perform a specific task or operation REPRESENTATION OF PROBLEM SOLVING SOLUTION 10
  • 11. Pseudo-code • Set of instructions that mimic programming language instructions REPRESENTATION OF SOLUTION 11
  • 12. D I F F E R E N C E B E T W E E N A L G O R I T H M A N D P S E U D O C O D E • An algorithm is a precise and well-defined procedure • Pseudocode is a more informal and high-level representation of an algorithm. 12 Representation of Solution
  • 13. Flowchart • Schematic representation of an algorithm REPRESENTATION OF SOLUTION 13
  • 14. 14
  • 15. • How to cut a circular cake into 8 equal pieces only with 3 cuts 15
  • 16. 16
  • 18. • An algorithm is a detailed step by step instructions for solving a problem in a finite amount of time • Used in solving mathematical or sometimes computational problems 11 Algorithm
  • 19. 11 Algorithm Steps involved in algorithm development An algorithm can be defined as “a complete, unambiguous, finite number of logical steps for solving a specific problem “ . Step1. Identification of input: For an algorithm, there are quantities to be supplied called input and these are fed externally. The input is to be indentified first for any specified problem. Step2: Identification of output: From an algorithm, at least one quantity is produced, called for any specified problem. Step3 : Identification the processing operations : All the calculations to be performed in order to lead to output from the input are to be identified in an orderly manner.
  • 20. 11 Algorithm Steps involved in algorithm development Step 4: Processing Definiteness: The instruction composing the algorithm must be clear and there should not be any ambiguity in them. Step5 : Processing Finiteness : If we go through the algorithm, then for all cases, the algorithm should terminate after a finite number of steps. Step6 : Possessing Effectiveness : The instructions in the algorithm must be sufficiently basic and in practice they can be carries out easily
  • 21. Introduction to Algorithm • Input • Output • Finiteness • Definiteness/Concise • Effectiveness Characteristics of Algorithm 12
  • 22. Input • Algorithm should have well-defined inputs Output • Algorithm should have well-defined outputs, and should match the desired output Finiteness • Algorithms must terminate after a finite number of steps Definiteness/Concise • Each step must be precisely defined • Actions to carryout must be unambiguously (not confusing) specified Effectiveness • All operations must achieve the goal 13 Characteristics of Algorithm
  • 23. 23 A Jeroo starts at (0, 0) facing East with no flowers in its pouch. There is a flower at location (3, 0). Write an algorithm that directs the Jeroo to pick the flower and plant it at location (3, 2). After planting the flower, the Jeroo should hop one space East and stop. There are no other nets, flowers, or Jeroos on the island. WRITE ALGORITHM – SIMPLE EXAMPLE
  • 24. 1.The flower is exactly three spaces ahead of the jeroo. 2.The flower is to be planted exactly two spaces South of its current location. 3.The Jeroo is to finish facing East one space East of the planted flower. 4.There are no nets to worry about. Get the flower Put the flower Hop East Get the flower Hop 3 times Pick the flower Put the flower Turn right Hop 2 times Plant a flower Hop East Turn left Hop once Analysis of the Problem High-level Algorithm Detailed Algorithm WRITE ALGORITHM
  • 25. Example for Algorithm Problem - Write an Algorithm to Multiply two numbers Step 1 - Start Step 2 - Declare three Integers a, b, c Step 3 - Define Values of a, b Step 4 - Multiplication of a, b Step 5 - Store the Output of step 4 to c Step 6 - Print the value c Step 7 - Stop Example for Algorithm: 14
  • 26. Applications of Algorithm • Google Search • Uber App • Video Games • NASA’s Manipulation of Space Ships • FaceBook Timeline Applications of Algorithm: 15
  • 27. Advantages & Disadvantages of Algorithm Advantages • It makes the representation of a solution to a problem easy, which makes easier in understanding • It can be easily understood by a person without even having the knowledge of programming • It follows a definite procedure Disadvantages • It takes very long in writing an algorithm • It is not a computer program, neither it helps in reducing the difficulties while writing a code 16
  • 28. L E T S H A V E A B R E A K • A doctor’s son’s father was not a doctor. How is this possible? • A man was born in 1945, but he’s only 30 years old now. How is this possible? 28
  • 29. L E T S H A V E A B R E A K • A doctor’s son’s father was not a doctor. How is this possible? • The doctor is the mother. • A man was born in 1945, but he’s only 30 years old now. How is this possible? • 1945 was the number of the hospital room. 29
  • 30. Summary • Overview of Computer Programming • Problem Solving • Steps in Problem Solving • Representation of Problem Solving Solution • Algorithm • Characteristics of Algorithm • Example for Algorithm • Applications of Algorithm • Advantages & Disadvantages of Algorithm Introduction to Problem Solving, Algorithm Implementation 17
  • 31. PEER LEARNING 1. Write an algorithm to calculate your cut-off? 2. Steps to admit in an engineering college through counseling 3. Write an algorithm to build a Calculator 4. Addition of three numbers entered by the user 5. Find the largest number among three different numbers 6. Check whether a number is a prime number or not 7. Factorial of a number entered by the user 19 Introduction to Problem Solving, Introduction to Algorithm
  • 32. Try Yourself 1. Mary Williams needs to change a Fahrenheit temperature to Celsius. Use the Fahrenheit temperature of 80 degrees to test your solution. Celsius = ((Fahrenheit - 32) * 5/9) 2. Calculate the area for a circle and display the result with proper output message. (Hint = ^2) 𝐴𝑟𝑒𝑎 𝜋𝑟 19 ntroduction to Problem Solving, Introduction to Idea of Algorithm
  • 33. 33
  • 34. TOP DOWN DESIGN 34 • A method of breaking a problem down into smaller, less complex pieces from the initial overall problem. • Most “good” problems are too complex to solve in just one step, so we divide the problem up into smaller manageable pieces, solve each one of them and then bring everything back together again. • The process of making the steps more and more specific in top-down design is called stepwise refinement. • Top-Down Design (Divide-and-Conquer) • Write functions top-down • Test functions bottom-up • Practicality: May help to write stubs (simulated functions as temporary placeholders in top-down design)
  • 35. 35
  • 36. • A parent node is one that has other nodes descending from it - we say that a node is the parent of some other node. • In the same way a child node is one that descends from a parent node. • The root node can only be a parent node. • Leaf nodes can only be child nodes. • Intermediate nodes can be both parent or child nodes depending on the desired perspective. • All nodes in the tree are children of the root node. Conversely the root node is a parent of all other nodes in the tree. • Sibling nodes are two or more nodes at the same level which are descended from the same parent. • The depth (or height) of a tree refers to the number of levels in the tree. • The width of a tree refers to the maximum number of nodes at any one level. 36
  • 37. T O P - D O W N D E S I G N • A software development technique that imposes a hierarchical structure on the design of the program. • It starts out by defining the solution at the highest level of functionality and breaking it down further and further into small routines that can be easily documented and coded. • Also known as: • Divide and conquer • Stepwise refinement • Structured programming 37
  • 38. A D V A N T A G E S O F T O P - D O W N D E S I G N • Breaking the problem into parts helps to clarify what needs to be done. • At each step of refinement, the new parts become less complicated and, therefore, easier to figure out. • Breaking the problem into parts allows more than one person to work on the solution. 38
  • 39. SIMPLE STRATEGIES FOR DEVELOPING ALGORITHMS 39 • Developing an algorithm is a very important step in problem-solving. There are different types of strategies that could be used to develop an algorithm to solve a problem. • Two of the most frequently used strategies are: – Iteration – Recursion
  • 40. 1. Iterations: A sequence of statements is executed until a specified condition is true is called iterations. 1. 2. for loop While loop For loop : FOR( start-value to end-value) DO Statement ... ENDFOR 40
  • 41. Example: Print n natural numbers BEGIN GET n INITIALIZE i=1 FOR (i<=n) DO PRINT i i=i+1 ENDFOR END 41
  • 42. Syntax for While: WHILE (condition) DO Statement ... ENDWHILE Print n natural numbers BEGIN GET n INITIALIZE i=1 WHILE(i<=n) DO PRINT i i=i+1 ENDWHILE END 42
  • 43. • Recursion is a technique in which a function calls itself repeatedly until a concluding situation happen. • A function which utilizes this technique is called a recursive function • Using recursive algorithm, certain problems can be solved quite easily. • Examples of such problems are • Towers of Hanoi (TOH) • In order/Preorder/Post order Tree Traversals, • DFS of Graph, etc. RECURSION 43