problem, problem solving, algorithm & flow charts –part 1 presented by manesh t course:101 cs...
DESCRIPTION
Problem and Problem Solving Definitions The state of feeling difficulty in completing any task is called problem The process of working through details of a problem to reach a solution. Problem solving may include mathematical or systematic operations and can be a gauge of an individual's critical thinking skills. 101CS Manesh T3TRANSCRIPT
1
Problem , Problem Solving, Algorithm & Flow Charts –Part 1
Presented ByManesh TCourse:101 CS
101CS Manesh T
Week 10
2
Objectives of the Session Defining Problem Defining Problem Solving Need for Problem Solving Problem Solving Strategy Define-Algorithms- Rules of Algorithms Examples of Algorithms Define-Flowcharts-Rules of Flowchart Examples of Flowcharts Model Exercises Take Away Tutorials
101CS Manesh T
3
Problem and Problem SolvingDefinitions The state of feeling difficulty in completing any task is
called problem
The process of working through details of a problem to reach a solution. Problem solving may include mathematical or systematic operations and can be a gauge of an individual's critical thinking skills.
101CS Manesh T
4
Need for Problem Solving
A computer is a tool that can be used to implement a plan for solving a problem.
A computer program is a set of instructions for a computer. These instructions describe the steps that the computer must follow to implement a plan.
An algorithm is a plan for solving a problem. A person must design an algorithm. A person must translate an algorithm into a computer
program.
101CS Manesh T
5
ALGORITHMS AND FLOWCHARTS Algorithm
Step by step method to solve a problem is algorithm
Flow Chart Diagrammatic representation of algorithm
101CS Manesh T
6
Divide and conquer strategy A divide and conquer algorithm works
by recursively breaking down a problem into two or more sub-problems of the same (or related) type, until solved
101CS Manesh T
7101CS
Manesh T
8
Steps in development of Algorithms1. Define Problem2. Adopt Problem solving Method3. Specify of Algorithm4. Design an Algorithm5. Check correctness of Algorithm6. Analysis of Algorithm7. Implementation of Algorithm8. Test Algorithm9. Documentation Preparation
101CS Manesh T
9
Qualities of a good algorithm
Inputs and outputs should be defined precisely. Each steps in algorithm should be clear and
unambiguous. Algorithm should be most effective among many different
ways to solve a problem. An algorithm shouldn't have computer code. Instead, the
algorithm should be written in such a way that, it can be used in similar programming languages.
101CS Manesh T
10
Algorithm Problem: How to brush your teeth Real life Example Step 1: StartStep 2: Wake upStep 3: Wash mouthStep 4: Wash brush, apply toothpasteStep 5: Brush your teethStep 6. Wash mouth and brushStep 7: Put brush back to holderStep 8: Stop
101CS Manesh T
11
Problem: Add two numbers
Algorithm Step 1: Start Step 2: Read A, B
Step 3: C=A+B Step 4: Print C Step 5: Stop
101CS Manesh T
12
AlgorithmProblem: Multiply 2 numbersStep 1: StartStep 2: Read A, BStep 3: C=A*BStep 4: Print C Step 5: Stop
Problem: Subtract 2 numbersStep 1: StartStep 2: Read A, BStep 3: C=A-BStep 4: Print C Step 5: Stop
101CS Manesh T
13
AlgorithmProblem: Average of 3 numbers
Step 1: Start Step 2: Read A, B, C
Step 3: Avg=(A+B+C)/3 Step 4: Print Avg Step 5: Stop
101CS Manesh T
14
AlgorithmProblem: Find your Age Step 1: Start Step 2: Read Byear
Step 3: Age=2015-Byear Step 4: Print Age
Step 5: Stop
101CS Manesh T
15
AlgorithmProblem: Area of Circle Step 1: Start Step 2: Read Radius
Step 3: Area=3.14*Radius *Radius Step 4: Print Area
Step 5: Stop
101CS Manesh T
16
AlgorithmProblem: Find even or odd
Step 1: Start Step 2: Read N
Step 3: Is (N%2=0) thenPrint “Even”
elsePrint “Odd”
Step 4: Stop101CS
Manesh T
17
AlgorithmProblem: Find +ve or -ve Step 1: Start Step 2: Read Number
Step 3: Is (N>0) thenPrint “+ve number”
elsePrint “-ve Number”
Step 4: Stop
101CS Manesh T
18
Detailed Algorithm Step 1: Start Step 2: Read Mark
Step 3: Is (Mark>=60) thenPrint “PASS”
elsePrint “Fail”
Step 4: Stop
AlgorithmProblem: Find Pass or Fail
101CS Manesh T
19
The FlowchartA Flowchart is another algorithm but graphical.
shows logic solutionemphasizes individual steps and their
interconnectionsA flowchart must have a start and stopA steps in a flowchart must connect.
101CS Manesh T
20
Flowchart Symbols General Used Symbols
101CS Manesh T
21
Flow Chart: Add Two NumbersStart
Read A, B
C=A+B
Print C
Stop
AlgorithmFlowchart
101CS Manesh T
22
DECISION STRUCTURES The expression A>B is a logical expression it describes a condition we want to test if A>B is true (if A is greater than B) we take
the action on left print the value of A if A>B is false (if A is not greater than B) we
take the action on right print the value of B
101CS Manesh T
23
DECISION STRUCTURES
isA>B
Y N
Print A Print B
101CS Manesh T
24
Flow Chart: Find Even or OddStart
Read N
Print “Odd”
Stop
Print “Even”
IsN%2=0
NY
101CS Manesh T
25
Flow Chart: Find Largest of two numbersStart
Read A, B
Print “B is large”
Stop
Print “A is large”
IsA>B
NY
101CS Manesh T
26
Problem: Write Algorithm and Flowchart to find solution of Quadratic equation
Algorithm: Step 1: Start Step 2: Read a, b, c Step 3: d sqrt ( ) Step 4: x1 (–b + d) / (2 x a) Step 5: x2 (–b – d) / (2 x a) Step 6: Print x1, x2 Step 7: Stop
START
Reada, b, c
d sqrt(b x b – 4 x a x c)
STOP
x1 (–b + d) / (2 x a)
X2 (–b – d) / (2 x a)
4b b a c
Print X1, X2
101CS Manesh T
27
Assignment 1 Draw algorithm and flowchart
1. Find area of triangle (area=(1/2)*breadth*height)2. Convert Celsius to Fahrenheit temperature f = (1.8*c) + 32; 3. Find Area of Rectangle (area= b*h)4. Find Volume of cylinder(V= 3.14*R*R*Height)5. Find volume of sphere (4/3* 3.14*R*R*R)6. Find biggest of three numbers.
101CS Manesh T
28
Instructions to students
Study definition well Study different algorithms well Study how to draw flowchart for specific
problems. Work-out various assignment problems Approach me for any doubt clarifications
101CS Manesh T