Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
20 views

ITA 120 Introduction To Programming: Algorithms

This document discusses algorithms, including their definitions, properties, and ways of representing them. An algorithm is a precise specification of steps to solve a problem. It must have structure, unambiguous executable steps, be correct, and terminate. Algorithms can be represented narratively with instructions, as a flowchart using graphical symbols, or in pseudocode combining English and code. Examples are given of each representation type for common algorithms like finding averages or buying a movie ticket. Exercises are provided to write narratives for additional algorithms.

Uploaded by

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

ITA 120 Introduction To Programming: Algorithms

This document discusses algorithms, including their definitions, properties, and ways of representing them. An algorithm is a precise specification of steps to solve a problem. It must have structure, unambiguous executable steps, be correct, and terminate. Algorithms can be represented narratively with instructions, as a flowchart using graphical symbols, or in pseudocode combining English and code. Examples are given of each representation type for common algorithms like finding averages or buying a movie ticket. Exercises are provided to write narratives for additional algorithms.

Uploaded by

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

ITA 120

Introduction to Programming
Algorithms

Algorithm
Definitions
A precise specification of a behaviour
intended to solve a well-defined problem
A finite set of well-defined instructions for
accomplishing some task
An ordered set of unambiguous, executable
steps that defines a terminating process.

Properties of algorithms
An algorithm must:
Have a well established structure.
Consist of executable steps. To make a list of all
positive integers is not executable, as the list is infinite.
Be unambiguous. The actions required by each step
should be unique and complete.
Be correct. If the input conditions are satisfied and the
steps of the algorithm executed then the desired
outcome should be produced.
Lead to an end. The algorithm should terminate after a
finite number of steps.

Related Terms

Process
Routine
Technique
Procedure
Pattern
Recipe

Ways of Representing Algorithms


Narrative - the set of simple instructions
that combine to accomplish a task.
Flowchart a graphical representation for
the solution of a problem. Symbols are
used to represent beginning, end, data flow.
Pseudo code description of a solution that
combines English and a programming
language.
http://www.4hb.com/25f.html, www.thecomputerfolks.com/P.htm

Example - Narrative
Obtain a basket of unshelled peas and an
empty bowl.
As long as there are unshelled peas in the
basket, continue to execute the following
steps.
Take a pea from the basket
Break open the pea pod
Dump the peas from the pod into the bowl
Discard the pod

Example - Narrative
An algorithm for buying a ticket for a
movie
Go to the theatre
Walk to the ticket counter
Select a movie
Pay the price
Receive the ticket

Example - Flowchart

http://www.scpcp.org/dnn/Portals/0/process-improvement/glossary/basic-flowchart.gif

Example - Pseudocode
CalculateAverageMark
Start
1. Prompt for FirstMark
2. Get FirstMark
3. Prompt for SecondMark
4. Get SecondMark
5. Average = (FirstMark + SecondMark) / 2
6. Print Average
Stop

Exercises
Write narratives for the following:

Find the average for four numbers


Change the time in seconds to minutes
Find the perimeter of a rectangle
Find the perimeter of a circle
Find the area of a circle

You might also like