0% found this document useful (0 votes)
39 views

Algorithm and Flow Chart

This document discusses algorithms and flow charts. It defines an algorithm as a tool for solving well-specified computational problems that takes input, applies a process, and produces output. Algorithms must be correct, producing the appropriate output for each input, and efficient. The document also discusses how algorithms are written as pseudo code that can be implemented in any programming language, and how the problem solving process moves from analyzing a problem to implementing an algorithm as a program.

Uploaded by

Shahzad Ashraf
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Algorithm and Flow Chart

This document discusses algorithms and flow charts. It defines an algorithm as a tool for solving well-specified computational problems that takes input, applies a process, and produces output. Algorithms must be correct, producing the appropriate output for each input, and efficient. The document also discusses how algorithms are written as pseudo code that can be implemented in any programming language, and how the problem solving process moves from analyzing a problem to implementing an algorithm as a program.

Uploaded by

Shahzad Ashraf
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 42

Lecture# 7

Algorithm and flow chart

By: Dr. Shahzad Ashraf


Algorithms
 A tool for solving a well-specified
computational problem

Input Algorithm Output

 Algorithms must be:


 Correct: For each input produce an appropriate output
 Efficient: run as quickly as possible, and use as little
memory as possible – more about this later

3
.Algorithms Cont
 A well-defined computational procedure that
takes some value, or set of values, as input and
produces some value, or set of values, as output.

 Written in a pseudo code which can be


implemented in the language of programmer’s
choice.

4
Correct and incorrect algorithms
 Algorithm is correct if, for every input instance, it ends
with the correct output. We say that a correct algorithm
solves the given computational problem.

 An incorrect algorithm might not end at all on some input


instances, or it might end with an answer other than the
desired one.

 We shall be concerned only with correct algorithms.

5
Problems and Algorithms
 We need to solve a computational problem
 “Convert a weight in pounds to Kg”

 An algorithm specifies how to solve it, e.g.:


 1. Read weight-in-pounds
 2. Calculate weight-in-Kg = weight-in-pounds *
0.455
 3. Print weight-in-Kg

 A computer program is a computer-


executable description of an algorithm

6
The Problem-solving Process

Analysis
Problem
specification
Design

Algorithm
Implementation
Program

Compilation
Executable
(solution)

7
From Algorithms to Programs
Problem
Algorithm:
Algorithm A sequence
of instructions describing
how to do a task (or
process)

C Program
8
The End

You might also like