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

Introduction To Algorithms: Unit 1 / Chapter 1

The document provides an introduction to algorithms and problem solving techniques in computer science. It discusses the basic components of a computer system including hardware and software. It then covers the steps involved in problem solving like problem definition, analysis, designing a program through algorithms and flowcharts, coding, testing and maintenance. It also provides examples of algorithms and discusses their characteristics and development process along with flowcharts.

Uploaded by

Mamatha NU
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Introduction To Algorithms: Unit 1 / Chapter 1

The document provides an introduction to algorithms and problem solving techniques in computer science. It discusses the basic components of a computer system including hardware and software. It then covers the steps involved in problem solving like problem definition, analysis, designing a program through algorithms and flowcharts, coding, testing and maintenance. It also provides examples of algorithms and discusses their characteristics and development process along with flowcharts.

Uploaded by

Mamatha NU
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 34

Introduction to

Algorithms
Unit 1 / Chapter 1
1.1 Introduction

• Computers are used to solve problems in various fields.

• A computer is a system made up of two major components:


Hardware and Software

• Computer hardware is the physical equipment.

• Software is the collection of programs / instructions that allow


the hardware to do its job
Hardware

Computer

Software
The hardware components of a computer system
consists of five main parts,

1.2 • Input devices


Computer • Output devices
Hardware • Central Processing Unit [CPU]
• Primary Storage Devices
• Auxiliary Storage devices
Problem Definition

Problem Analysis

Steps in Design
Problem
Solving Coding

Testing

Maintenance
To solve a problem, the first
step is to identify and define the
problem.

a) Problem The problem must be stated


Definition clearly, accurately and precisely.

Eg: Find largest of three


numbers
The problem analysis helps in designing and coding
for that particular problem.

1. Input specifications: The number of inputs and


b) Problem what forms the input are available
Analysis 2.Output specifications: The number of outputs
and what forms the output should be displayed.

Eg: Input – a, b, c output - d


Algorithm - step by step procedure of
c) Designing solving a problem
a program Flowcharts – It is the graphical
representation of the algorithm.
once we complete algorithm and
flowchart, we proceed to the next
step of writing down each step of
algorithm as a statements in
programming languages.

d) Coding In this process, we define data


items, variables, constraints.

Depending on the knowledge of a


programmer, programming
languages will be chosen
1 2 3 4
e) Testing Unit Program
Verificati
Validatio
on
testing Testing n Testing.
Testing
1 2
f) Maintaining Periodic review of Improvement /
Program the programs and modifications in the
modifications based program requires
on user proper
requirements documentation of
the program.
Program
Designing Algorithms Flowcharts
Tools
a) Algorithms

An algorithm is a step by step procedure to solve a given problem in


finite number of steps.

Complete, unambiguous procedure (set of instructions) for


solving a problem in a finite number of steps is called as algorithm.
CHARACTERISTICS

An algorithm should be simple and Unambiguous

Algorithm must have finite number of steps.

No instructions should be repeated.

An algorithm must take at least one or more input values.

An algorithm must provide at least one or more output values.


1. Algorithms are very easy to understand

2. It is easy to first develop an algorithm, and then convert it


into a flowchart and then into a program

3. Algorithm is machine & language independent

Advantages 4. Algorithm makes the problem simple, clear and correct

5. It explains what kind of action has taken in which order

6. It makes sure that no logical path is left incomplete

7. It clearly indicates the role played at each level

8. The complete formulation of the problem lies algorithm


itself, which helps to facilitates trouble shooting
Disadvantages

DEVELOPING A ALGORITHM IS A TRAIL IT IS TIME CONSUMING, BECAUSE


AND ERROR PROCEDURE, SO BEFORE FOR EACH AND EVERY
REQUIRES MANY ATTEMPTS TO GET PROGRAM ALGORITHM IS TO BE
THE FINAL ONE WRITTEN
Algorithm to make a Telephone Call
Step 1: Start
Step 2: Pick up the receiver
Step 3: Listen for the dial tone
Step 4: Dial Phone Number
Step 5: When someone answers talk
Step 6: Say “Bye”
Step 7: Hang up the receiver
Step 8: Stop
Write an algorithm for finding sum of two numbers.

Step 1: Start
Step 2: Read two values, say a and b
Step 3: Add a and b, and store the result
in another variable, say c
Step 4: Display the value of c.
Step 5: Stop
Assignments

1. Algorithm for finding average of 3 numbers

2. Algorithm for finding largest of 3 numbers

3. Algorithm for finding greater of two numbers


b) Flowcharts

• Flow chart is a pictorial representation of the algorithm.

• Flow chart uses some geometrical shapes for representing an algorithm


diagrammatically.

• A flow chart indicates the flow of the entire process, sequence of data input,
operations, computations, decisions, results and other information.
Types of flow charts

1. System flowcharts : It defines the broad processing in the organizations,


showing the origin of data, processing to be performed, output to be
generated.

2. Program flowcharts: It plans the program structure and also serves the
purpose of documentation for a program.
These are normally used by programmers to describe the sequence of
operations and decisions.
Characteristics

• Formulation the problem and deciding the input data.


• Identifying the various steps of computations that are must for the
solution
• Identifying the points of decision and should draw the flow regardingly.
• Knowing the expected result
Advantages
1. This is the convenient method of communications.

2. It indicates clearly just what is being done.

3. It acts as an important tool for planning & designing.

4. It saves the inconveniences in future and serves the purpose of documentation.

5. It provides overview of the system, it demonstrate the relationship between


various steps.

6. It promotes logical accuracy


Disadvantages
1. Trail and error method does not takes place in flowcharts, so many
modifications goes for a complete change

2. It is difficult to remember symbols

3. Care should be taken which showing the flow of data for complete
logic
Flowchart Symbols
Sl.
Purpose Symbol
No
1 Start and stop

Instructing / informing computer to do


2
computation

3 Input and Output Operation

4 Decision Making

5 connector

6 Route Makers
Sl.
Purpose Symbol
No

7 Predefined Process

8 Preparation / Looping
START

Draw a Pick up the receiver

flowchart Listen for dial tone


for
making Dial the phone Number

telephone When someone answers talk

call Say bye

Hang up the receiver

STOP
Draw a START

flowchart
to Read A & B
calculate
C =A * B
CA*B

Print C

STOP
Assignments

1. Draw a flowchart to find out the smallest of two numbers

2. Draw a flowchart to find average of 3 numbers

3. Draw a flowchart to add 3 numbers


Thank You

You might also like