SlideShare a Scribd company logo
Algorithm and Flow Chart
2.1 ALGORITHM
2.1.1 Introduction
An algorithm is a set of instructions, sometimes called a procedure or a function that is used to
perform a certain task. This can be a simple process, such as adding two numbers together, or
a complex function, such as adding effects to an image. For example, in order to sharpen a
digital photo, the algorithm would need to process each pixel in the image and determine which
ones to change and how much to change them in order to make the image look sharper.
Most computer programmers spend a large percentage of their time creating algorithms.
(The rest of their time is spent debugging the algorithms that don’t work properly.) The goal is
to create efficient algorithms that do not waste more computer resources (such as RAM and
CPU time) than necessary. This can be difficult, because an algorithm that performs well on one
set of data may perform poorly on other data.
As you might guess, poorly written algorithms can cause programs to run slowly and even
crash. Therefore, software updates are often introduced, touting “improved stability and
performance”. While this sounds impressive, it also means that the algorithms in the previous
versions of the software were not written as well as they could have been.
Operation
An algorithm generally takes some input, carries out a number of effective steps in a finite
2
Chapter
84 Computer Basics with Office Automation
Given a list of numbers, you can easily order them from largest to smallest with the simple
instruction “Sort these numbers.” A computer, however, needs more detail to sort numbers. It
must be told to search for the smallest number, how to find the smallest number, how to compare
numbers together, etc. The operation “Sort these numbers” is ambiguous to a computer because
the computer has no basic operations for sorting. Basic operations used for writing algorithms
are known as primitive operations or primitives. When an algorithm is written in computer
primitives, then the algorithm is unambiguous and the computer can execute it.
Algorithms have effectively computable operations
Each operation in an algorithm must be doable, that is, the operation must be something that is
possible to do. Suppose you were given an algorithm for planting a garden where the first step
instructed you to remove all large stones from the soil. This instruction may not be doable if
there is a four ton rock buried just below ground level. For computers, many mathematical
operations such as division by zero or finding the square root of a negative number are also
impossible. These operations are not effectively computable so they cannot be used in writing
algorithms.
Algorithms produce a result
In our simple definition of an algorithm, we stated that an algorithm is a set of instructions for
solving a problem. Unless an algorithm produces some result, we can never be certain whether
our solution is correct. Have you ever given a command to a computer and discovered that
nothing changed? What was your response? You probably thought that the computer was
malfunctioning because your command did not produce any type of result. Without some visible
change, you have no way of determining the effect of your command. The same is true with
algorithms. Only algorithms which produce results can be verified as either right or wrong.
Algorithms halt in a finite amount of time
Algorithms should be composed of a finite number of operations and they should complete their
execution in a finite amount of time. Suppose we wanted to write an algorithm to print all the
integers greater than 1. Our steps might look something like this:
1. Print the number 2.
2. Print the number 3.
3. Print the number 4.
While our algorithm seems to be pretty clear, we have two problems. First, the algorithm
must have an infinite number of steps because there are an infinite number of integers greater
than one. Second, the algorithm will run forever trying to count to infinity. These problems
violate our definition that an algorithm must halt in a finite amount of time. Every algorithm
must reach some operation that tells it to stop.
Algorithm and Flow Chart 85
2.1.3 Advantages and Disadvantages of Algorithms
Advantages
The use of algorithms provides a number of advantages. One of these advantages is in the
development of the procedure itself, which involves identification of the processes, major decision
points, and variables necessary to solve the problem. Developing an algorithm allows and even
forces examination of the solution process in a rational manner. Identification of the processes
and decision points reduces the task into a series of smaller steps of more manageable size.
Problems that would be difficult or impossible to solve wholesale can be approached as a series
of small, solvable subproblems. The required specification aids in the identification and reduction
of subconscious biases. By using an algorithm, decision-making becomes a more rational process.
In additional to making the process more rational, use of an algorithm will make the process
more efficient and more consistent. Efficiency is an inherent result of the analysis and specification
process. Consistency comes from both the use of the same specified process and increased skill
in applying the process. An algorithm serves as a mnemonic device and helps ensure that variables
or parts of the problem are not ignored. Presenting the solution process as an algorithm allows
more precise communication. Finally, separation of the procedure steps facilitates division of
labor and development of expertise.
A final benefit of the use of an algorithm comes from the improvement it makes possible.
If the problem solver does not know what was done, he or she will not know what was done
wrong. As time goes by and results are compared with goals, the existence of a specified
solution process allows identification of weaknesses and errors in the process. Reduction of a
task to a specified set of steps or algorithm is an important part of analysis, control, and evaluation.
Disadvantages
One disadvantage of algorithms is that they always terminate, which means there are some
computational procedures—occasionally even useful ones—which are not algorithms. Furthermore,
all computational procedures, whether they terminate or not, can only give computable results,
so you cannot, for example, design a program which determines a busy beaver number more
quickly than could be done by actually running the associated types of turing machines.
2.2 FLOW CHART
2.2.1 Introduction
A flow chart, or flow diagram, is a graphical representation of a process or system that details
the sequencing of steps required to create output. A typical flow chart uses a set of basic
symbols to represent various functions, and shows the sequence and interconnection of functions
with lines and arrows. Flow charts can be used to document virtually any type of business
system, from the movement of materials through machinery in a manufacturing operation to the
flow of applicant information through the hiring process in a human resources department.
86 Computer Basics with Office Automation
Each flow chart is concerned with one particular process or system. It begins with the
input of data or materials into the system and traces all the procedures needed to convert
the input into its final output form. Specialized flow chart symbols show the processes
that take place, the actions that are performed in each step, and the relationship between
various steps. Flow charts can include different levels of detail as needed, from a high-
level overview of an entire system to a detailed diagram of one component process within
a larger system. In any case, the flow chart shows the overall structure of the process or
system, traces the flow of information and work through it, and highlights key processing
and decision points.
Flow charts are an important tool for the improvement of processes. By providing a
graphical representation, they help project teams to identify the different elements of a process
and understand the interrelationships among the various steps. Flow charts may also be used
to gather information and data about a process as an aid to decision-making or performance
evaluation. For example, the owner of a small advertising agency who hopes to reduce the
time involved in creating a print ad might be able to use a flow chart of the process to
identify and eliminate unnecessary steps. Though flow charts are relatively old design tools,
they remain popular among computer programmers working on systems analysis and design.
In recent years, many software programs have been developed to assist businesspeople in
creating flow charts.
2.2.2 Constructing Flow Charts
Flow charts typically utilize specialized symbols. Some of the main symbols that are used to
construct flow charts include:
• A round-edged rectangle to represent starting and ending activities, which are sometimes
referred to as terminal activities.
• A rectangle to represent an activity or step.
• Each step or activity within a process is indicated by a single rectangle, which is known
as an activity or process symbol.
• A diamond to signify a decision point. The question to be answered or decision to be
made is written inside the diamond, which is known as a decision symbol. The answer
determines the path that will be taken as a next step.
• Flow lines show the progression or transition from one step to another.
Constructing a flow chart involves the following main steps: (1) Define the process and
identify the scope of the flow diagram; (2) Identify project team members that are to be involved
in the construction of the process flow diagram; (3) Define the different steps involved in the
process and the interrelationships between the different steps (all team members should help
develop and agree upon the different steps for the process); (4) Finalize the diagram, involving
other concerned individuals as needed and making any modifications necessary; and (5) Use the
flow diagram and continuously update it as needed.
Algorithm and Flow Chart 87
2.2.3 Advantages and Disadvantages of Flow Chart
Advantages
1. Communication: Flow Charts are better way of communicating the logic of a system to
all concerned.
2. Effective Analysis: With the help of flow chart, problem can be analyzed in more effective
way.
3. Proper Documentation: Program flow charts serve as a good program documentation,
which is needed for various purposes.
4. Efficient Coding: The flow charts act as a guide or blueprint during the systems analysis
and program development phase.
5. Proper Debugging: The flow chart helps in debugging process.
6. Efficient Program Maintenance: The maintenance of operating program becomes easy
with the help of flow chart. It helps the programmer to put efforts more efficiently on that
part.
88 Computer Basics with Office Automation
Disadvantages
Complex logic: Sometimes, the program logic is quite complicated. In that case, flow chart
becomes complex and clumsy.
1. Alterations and Modifications: If alterations are required the flow chart may require re-
drawing completely.
2. Reproduction: As the flow chart symbols cannot be typed, reproduction of flow chart
becomes a problem.
3. The essentials of what is done can easily be lost in the technical details of how it is done.
2.3 EXAMPLES
Example 1: Write an algorithm and draw a flow chart to calculate 24
.
Algorithm: Step 1: Input Base (2), Power (4)
Step 2: Product= Base
Step 3: Product = Product * Base
Step 4: Product = Product * Base
Step 5: Product = Product * Base
Step 6: Print Product
Flow chart
Algorithm and Flow Chart 89
• Question: What happens if you want to calculate 2 to the power of 1000 (21000
)
• Answer: Use a LOOP (repeated execution of the same set of instructions)
Example 2: Write an algorithm and draw a flow chart to calculate 24
using a loop approach?
Algorithm: Step 1: Input Base (2), Power (4)
Step 2: Product = Base
Step 3: Counter = 1
Step 4: While (Counter < Power)
Repeat steps 4 through 6
Step 5: Product = Product * Base
Step 6: Counter = Counter + 1
Step 7: Print Product
Flow chart
Example 3: Write down an algorithm and draw a flow chart to find and print the largest of three
numbers. Read numbers one by one. (Use 5, 7, 3 as the numbers read)
Algorithm and Flow Chart 91
Example 4: Write down an algorithm and draw a flow chart to count and print from 1 to 10.
Algorithm: Step 1: Input Low(1), High(10)
Step 2: Count = 1
Step 4: While (Count £ High)
Repeat steps 4 through 6
Step 5: Print Count
Step 6: Count = Count + 1
Flow chart
Example 5: Write an algorithm and draw a flow chart to calculate the factorial of a number (N).
Verify your result by a trace table by assuming N = 5.
Hint: The factorial of N is the product of numbers from 1 to N.
92 Computer Basics with Office Automation
Algorithm: Step 1: Input N
Step 2: Factor = 1
Step 3: Counter = 1
Step 4: While (Counter £ N)
Repeat steps 4 through 6
Step 5: Factor = Factor * Counter
Step 6: Counter = Counter + 1
Step 7: Print (N, Factor)
Flow chart
REVIEW EXERCISE
1. Write an algorithm and draw a flow chart to print the square of all numbers from LOW
to HIGH. (Test your algorithm with LOW = 1 and HIGH = 10).
2. Write an algorithm and draw a flow chart to print the SUM of numbers from LOW to
HIGH. (Test your algorithm with LOW = 3 and HIGH = 9.)
3. Write an algorithm and draw a flow chart to print all numbers between LOW and HIGH
that are divisible by NUMBER.

More Related Content

What's hot

Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
Mahantesh Devoor
 
Loops in C
Loops in CLoops in C
Loops in C
Kamal Acharya
 
An Introduction To Python - Graphics
An Introduction To Python - GraphicsAn Introduction To Python - Graphics
An Introduction To Python - Graphics
Blue Elephant Consulting
 
Algorithm and flowchart
Algorithm and flowchart Algorithm and flowchart
Algorithm and flowchart
Shivam Sharma
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
Deva Singh
 
Algorithms and flowcharts ppt (seminar presentation)..
 Algorithms and flowcharts  ppt (seminar presentation).. Algorithms and flowcharts  ppt (seminar presentation)..
Algorithms and flowcharts ppt (seminar presentation)..
Nagendra N
 
Break and continue
Break and continueBreak and continue
Break and continue
Frijo Francis
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 
Algorithm
AlgorithmAlgorithm
Algorithm
IHTISHAM UL HAQ
 
Polish Notation In Data Structure
Polish Notation In Data StructurePolish Notation In Data Structure
Polish Notation In Data Structure
Meghaj Mallick
 
10. switch case
10. switch case10. switch case
10. switch case
Way2itech
 
Flowcharting and Algorithm
Flowcharting and Algorithm Flowcharting and Algorithm
Flowcharting and Algorithm
Zeinna Belle Desamito
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
DHANIK VIKRANT
 
SPL 2 | Algorithms, Pseudo-code, and Flowchart
SPL 2 | Algorithms, Pseudo-code, and FlowchartSPL 2 | Algorithms, Pseudo-code, and Flowchart
SPL 2 | Algorithms, Pseudo-code, and Flowchart
Mohammad Imam Hossain
 
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
Meghaj Mallick
 
Pseudocode
PseudocodePseudocode
Pseudocode
Harsha Madushanka
 
pseudo code basics
pseudo code basicspseudo code basics
pseudo code basics
Sabik T S
 
Linear search-and-binary-search
Linear search-and-binary-searchLinear search-and-binary-search
Linear search-and-binary-search
International Islamic University
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithms
sathish sak
 
Input and Output In C Language
Input and Output In C LanguageInput and Output In C Language
Input and Output In C Language
Adnan Khan
 

What's hot (20)

Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
 
Loops in C
Loops in CLoops in C
Loops in C
 
An Introduction To Python - Graphics
An Introduction To Python - GraphicsAn Introduction To Python - Graphics
An Introduction To Python - Graphics
 
Algorithm and flowchart
Algorithm and flowchart Algorithm and flowchart
Algorithm and flowchart
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 
Algorithms and flowcharts ppt (seminar presentation)..
 Algorithms and flowcharts  ppt (seminar presentation).. Algorithms and flowcharts  ppt (seminar presentation)..
Algorithms and flowcharts ppt (seminar presentation)..
 
Break and continue
Break and continueBreak and continue
Break and continue
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Polish Notation In Data Structure
Polish Notation In Data StructurePolish Notation In Data Structure
Polish Notation In Data Structure
 
10. switch case
10. switch case10. switch case
10. switch case
 
Flowcharting and Algorithm
Flowcharting and Algorithm Flowcharting and Algorithm
Flowcharting and Algorithm
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
 
SPL 2 | Algorithms, Pseudo-code, and Flowchart
SPL 2 | Algorithms, Pseudo-code, and FlowchartSPL 2 | Algorithms, Pseudo-code, and Flowchart
SPL 2 | Algorithms, Pseudo-code, and Flowchart
 
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
 
Pseudocode
PseudocodePseudocode
Pseudocode
 
pseudo code basics
pseudo code basicspseudo code basics
pseudo code basics
 
Linear search-and-binary-search
Linear search-and-binary-searchLinear search-and-binary-search
Linear search-and-binary-search
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithms
 
Input and Output In C Language
Input and Output In C LanguageInput and Output In C Language
Input and Output In C Language
 

Similar to Algo and flowchart

11 Unit 1 Problem Solving Techniques
11  Unit 1 Problem Solving Techniques11  Unit 1 Problem Solving Techniques
11 Unit 1 Problem Solving Techniques
Praveen M Jigajinni
 
Chapter 6 algorithms and flow charts
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow charts
Praveen M Jigajinni
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptx
TadiwaMawere
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)
praveena p
 
251 - Alogarithms Lects.pdf
251 - Alogarithms Lects.pdf251 - Alogarithms Lects.pdf
251 - Alogarithms Lects.pdf
Abdulkadir Jibril
 
AOA Week 01.ppt
AOA Week 01.pptAOA Week 01.ppt
AOA Week 01.ppt
INAM352782
 
Practical 01 (detailed)
Practical 01 (detailed)Practical 01 (detailed)
Practical 01 (detailed)
Muhammadalizardari
 
Chap6
Chap6Chap6
Lect 3-4 Zaheer Abbas
Lect 3-4 Zaheer AbbasLect 3-4 Zaheer Abbas
Lect 3-4 Zaheer Abbas
Information Technology Center
 
Prepare and Interpret Technical Drawing.pptx
Prepare and Interpret Technical Drawing.pptxPrepare and Interpret Technical Drawing.pptx
Prepare and Interpret Technical Drawing.pptx
RivenBarquilla
 
Chapter 1 Data structure.pptx
Chapter 1 Data structure.pptxChapter 1 Data structure.pptx
Chapter 1 Data structure.pptx
wondmhunegn
 
pccf unit 1 _VP.pptx
pccf unit 1 _VP.pptxpccf unit 1 _VP.pptx
pccf unit 1 _VP.pptx
vishnupriyapm4
 
Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
rajkumar1631010038
 
Traditional Quality Tools.pptx
Traditional Quality Tools.pptxTraditional Quality Tools.pptx
Traditional Quality Tools.pptx
mayankdubey99
 
FLOW CHARTS
FLOW CHARTSFLOW CHARTS
FLOW CHARTS
Swarnima Tiwari
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sit
Saurabh846965
 
Programming Fundamentals lecture 3
Programming Fundamentals lecture 3Programming Fundamentals lecture 3
Programming Fundamentals lecture 3
REHAN IJAZ
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
mshoaib15
 
New folderIMAG2318.jpgNew folderIMAG2319.jpgNew folder.docx
New folderIMAG2318.jpgNew folderIMAG2319.jpgNew folder.docxNew folderIMAG2318.jpgNew folderIMAG2319.jpgNew folder.docx
New folderIMAG2318.jpgNew folderIMAG2319.jpgNew folder.docx
henrymartin15260
 
FIT-Unit3 chapter 1 -computer program
FIT-Unit3 chapter 1 -computer programFIT-Unit3 chapter 1 -computer program
FIT-Unit3 chapter 1 -computer program
raksharao
 

Similar to Algo and flowchart (20)

11 Unit 1 Problem Solving Techniques
11  Unit 1 Problem Solving Techniques11  Unit 1 Problem Solving Techniques
11 Unit 1 Problem Solving Techniques
 
Chapter 6 algorithms and flow charts
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow charts
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptx
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)
 
251 - Alogarithms Lects.pdf
251 - Alogarithms Lects.pdf251 - Alogarithms Lects.pdf
251 - Alogarithms Lects.pdf
 
AOA Week 01.ppt
AOA Week 01.pptAOA Week 01.ppt
AOA Week 01.ppt
 
Practical 01 (detailed)
Practical 01 (detailed)Practical 01 (detailed)
Practical 01 (detailed)
 
Chap6
Chap6Chap6
Chap6
 
Lect 3-4 Zaheer Abbas
Lect 3-4 Zaheer AbbasLect 3-4 Zaheer Abbas
Lect 3-4 Zaheer Abbas
 
Prepare and Interpret Technical Drawing.pptx
Prepare and Interpret Technical Drawing.pptxPrepare and Interpret Technical Drawing.pptx
Prepare and Interpret Technical Drawing.pptx
 
Chapter 1 Data structure.pptx
Chapter 1 Data structure.pptxChapter 1 Data structure.pptx
Chapter 1 Data structure.pptx
 
pccf unit 1 _VP.pptx
pccf unit 1 _VP.pptxpccf unit 1 _VP.pptx
pccf unit 1 _VP.pptx
 
Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
 
Traditional Quality Tools.pptx
Traditional Quality Tools.pptxTraditional Quality Tools.pptx
Traditional Quality Tools.pptx
 
FLOW CHARTS
FLOW CHARTSFLOW CHARTS
FLOW CHARTS
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sit
 
Programming Fundamentals lecture 3
Programming Fundamentals lecture 3Programming Fundamentals lecture 3
Programming Fundamentals lecture 3
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
 
New folderIMAG2318.jpgNew folderIMAG2319.jpgNew folder.docx
New folderIMAG2318.jpgNew folderIMAG2319.jpgNew folder.docxNew folderIMAG2318.jpgNew folderIMAG2319.jpgNew folder.docx
New folderIMAG2318.jpgNew folderIMAG2319.jpgNew folder.docx
 
FIT-Unit3 chapter 1 -computer program
FIT-Unit3 chapter 1 -computer programFIT-Unit3 chapter 1 -computer program
FIT-Unit3 chapter 1 -computer program
 

Recently uploaded

Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
BoudhayanBhattachari
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
National Information Standards Organization (NISO)
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
ssuser13ffe4
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
melliereed
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
RamseyBerglund
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 

Recently uploaded (20)

Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 

Algo and flowchart

  • 1. Algorithm and Flow Chart 2.1 ALGORITHM 2.1.1 Introduction An algorithm is a set of instructions, sometimes called a procedure or a function that is used to perform a certain task. This can be a simple process, such as adding two numbers together, or a complex function, such as adding effects to an image. For example, in order to sharpen a digital photo, the algorithm would need to process each pixel in the image and determine which ones to change and how much to change them in order to make the image look sharper. Most computer programmers spend a large percentage of their time creating algorithms. (The rest of their time is spent debugging the algorithms that don’t work properly.) The goal is to create efficient algorithms that do not waste more computer resources (such as RAM and CPU time) than necessary. This can be difficult, because an algorithm that performs well on one set of data may perform poorly on other data. As you might guess, poorly written algorithms can cause programs to run slowly and even crash. Therefore, software updates are often introduced, touting “improved stability and performance”. While this sounds impressive, it also means that the algorithms in the previous versions of the software were not written as well as they could have been. Operation An algorithm generally takes some input, carries out a number of effective steps in a finite 2 Chapter
  • 2. 84 Computer Basics with Office Automation Given a list of numbers, you can easily order them from largest to smallest with the simple instruction “Sort these numbers.” A computer, however, needs more detail to sort numbers. It must be told to search for the smallest number, how to find the smallest number, how to compare numbers together, etc. The operation “Sort these numbers” is ambiguous to a computer because the computer has no basic operations for sorting. Basic operations used for writing algorithms are known as primitive operations or primitives. When an algorithm is written in computer primitives, then the algorithm is unambiguous and the computer can execute it. Algorithms have effectively computable operations Each operation in an algorithm must be doable, that is, the operation must be something that is possible to do. Suppose you were given an algorithm for planting a garden where the first step instructed you to remove all large stones from the soil. This instruction may not be doable if there is a four ton rock buried just below ground level. For computers, many mathematical operations such as division by zero or finding the square root of a negative number are also impossible. These operations are not effectively computable so they cannot be used in writing algorithms. Algorithms produce a result In our simple definition of an algorithm, we stated that an algorithm is a set of instructions for solving a problem. Unless an algorithm produces some result, we can never be certain whether our solution is correct. Have you ever given a command to a computer and discovered that nothing changed? What was your response? You probably thought that the computer was malfunctioning because your command did not produce any type of result. Without some visible change, you have no way of determining the effect of your command. The same is true with algorithms. Only algorithms which produce results can be verified as either right or wrong. Algorithms halt in a finite amount of time Algorithms should be composed of a finite number of operations and they should complete their execution in a finite amount of time. Suppose we wanted to write an algorithm to print all the integers greater than 1. Our steps might look something like this: 1. Print the number 2. 2. Print the number 3. 3. Print the number 4. While our algorithm seems to be pretty clear, we have two problems. First, the algorithm must have an infinite number of steps because there are an infinite number of integers greater than one. Second, the algorithm will run forever trying to count to infinity. These problems violate our definition that an algorithm must halt in a finite amount of time. Every algorithm must reach some operation that tells it to stop.
  • 3. Algorithm and Flow Chart 85 2.1.3 Advantages and Disadvantages of Algorithms Advantages The use of algorithms provides a number of advantages. One of these advantages is in the development of the procedure itself, which involves identification of the processes, major decision points, and variables necessary to solve the problem. Developing an algorithm allows and even forces examination of the solution process in a rational manner. Identification of the processes and decision points reduces the task into a series of smaller steps of more manageable size. Problems that would be difficult or impossible to solve wholesale can be approached as a series of small, solvable subproblems. The required specification aids in the identification and reduction of subconscious biases. By using an algorithm, decision-making becomes a more rational process. In additional to making the process more rational, use of an algorithm will make the process more efficient and more consistent. Efficiency is an inherent result of the analysis and specification process. Consistency comes from both the use of the same specified process and increased skill in applying the process. An algorithm serves as a mnemonic device and helps ensure that variables or parts of the problem are not ignored. Presenting the solution process as an algorithm allows more precise communication. Finally, separation of the procedure steps facilitates division of labor and development of expertise. A final benefit of the use of an algorithm comes from the improvement it makes possible. If the problem solver does not know what was done, he or she will not know what was done wrong. As time goes by and results are compared with goals, the existence of a specified solution process allows identification of weaknesses and errors in the process. Reduction of a task to a specified set of steps or algorithm is an important part of analysis, control, and evaluation. Disadvantages One disadvantage of algorithms is that they always terminate, which means there are some computational procedures—occasionally even useful ones—which are not algorithms. Furthermore, all computational procedures, whether they terminate or not, can only give computable results, so you cannot, for example, design a program which determines a busy beaver number more quickly than could be done by actually running the associated types of turing machines. 2.2 FLOW CHART 2.2.1 Introduction A flow chart, or flow diagram, is a graphical representation of a process or system that details the sequencing of steps required to create output. A typical flow chart uses a set of basic symbols to represent various functions, and shows the sequence and interconnection of functions with lines and arrows. Flow charts can be used to document virtually any type of business system, from the movement of materials through machinery in a manufacturing operation to the flow of applicant information through the hiring process in a human resources department.
  • 4. 86 Computer Basics with Office Automation Each flow chart is concerned with one particular process or system. It begins with the input of data or materials into the system and traces all the procedures needed to convert the input into its final output form. Specialized flow chart symbols show the processes that take place, the actions that are performed in each step, and the relationship between various steps. Flow charts can include different levels of detail as needed, from a high- level overview of an entire system to a detailed diagram of one component process within a larger system. In any case, the flow chart shows the overall structure of the process or system, traces the flow of information and work through it, and highlights key processing and decision points. Flow charts are an important tool for the improvement of processes. By providing a graphical representation, they help project teams to identify the different elements of a process and understand the interrelationships among the various steps. Flow charts may also be used to gather information and data about a process as an aid to decision-making or performance evaluation. For example, the owner of a small advertising agency who hopes to reduce the time involved in creating a print ad might be able to use a flow chart of the process to identify and eliminate unnecessary steps. Though flow charts are relatively old design tools, they remain popular among computer programmers working on systems analysis and design. In recent years, many software programs have been developed to assist businesspeople in creating flow charts. 2.2.2 Constructing Flow Charts Flow charts typically utilize specialized symbols. Some of the main symbols that are used to construct flow charts include: • A round-edged rectangle to represent starting and ending activities, which are sometimes referred to as terminal activities. • A rectangle to represent an activity or step. • Each step or activity within a process is indicated by a single rectangle, which is known as an activity or process symbol. • A diamond to signify a decision point. The question to be answered or decision to be made is written inside the diamond, which is known as a decision symbol. The answer determines the path that will be taken as a next step. • Flow lines show the progression or transition from one step to another. Constructing a flow chart involves the following main steps: (1) Define the process and identify the scope of the flow diagram; (2) Identify project team members that are to be involved in the construction of the process flow diagram; (3) Define the different steps involved in the process and the interrelationships between the different steps (all team members should help develop and agree upon the different steps for the process); (4) Finalize the diagram, involving other concerned individuals as needed and making any modifications necessary; and (5) Use the flow diagram and continuously update it as needed.
  • 5. Algorithm and Flow Chart 87 2.2.3 Advantages and Disadvantages of Flow Chart Advantages 1. Communication: Flow Charts are better way of communicating the logic of a system to all concerned. 2. Effective Analysis: With the help of flow chart, problem can be analyzed in more effective way. 3. Proper Documentation: Program flow charts serve as a good program documentation, which is needed for various purposes. 4. Efficient Coding: The flow charts act as a guide or blueprint during the systems analysis and program development phase. 5. Proper Debugging: The flow chart helps in debugging process. 6. Efficient Program Maintenance: The maintenance of operating program becomes easy with the help of flow chart. It helps the programmer to put efforts more efficiently on that part.
  • 6. 88 Computer Basics with Office Automation Disadvantages Complex logic: Sometimes, the program logic is quite complicated. In that case, flow chart becomes complex and clumsy. 1. Alterations and Modifications: If alterations are required the flow chart may require re- drawing completely. 2. Reproduction: As the flow chart symbols cannot be typed, reproduction of flow chart becomes a problem. 3. The essentials of what is done can easily be lost in the technical details of how it is done. 2.3 EXAMPLES Example 1: Write an algorithm and draw a flow chart to calculate 24 . Algorithm: Step 1: Input Base (2), Power (4) Step 2: Product= Base Step 3: Product = Product * Base Step 4: Product = Product * Base Step 5: Product = Product * Base Step 6: Print Product Flow chart
  • 7. Algorithm and Flow Chart 89 • Question: What happens if you want to calculate 2 to the power of 1000 (21000 ) • Answer: Use a LOOP (repeated execution of the same set of instructions) Example 2: Write an algorithm and draw a flow chart to calculate 24 using a loop approach? Algorithm: Step 1: Input Base (2), Power (4) Step 2: Product = Base Step 3: Counter = 1 Step 4: While (Counter < Power) Repeat steps 4 through 6 Step 5: Product = Product * Base Step 6: Counter = Counter + 1 Step 7: Print Product Flow chart Example 3: Write down an algorithm and draw a flow chart to find and print the largest of three numbers. Read numbers one by one. (Use 5, 7, 3 as the numbers read)
  • 8. Algorithm and Flow Chart 91 Example 4: Write down an algorithm and draw a flow chart to count and print from 1 to 10. Algorithm: Step 1: Input Low(1), High(10) Step 2: Count = 1 Step 4: While (Count £ High) Repeat steps 4 through 6 Step 5: Print Count Step 6: Count = Count + 1 Flow chart Example 5: Write an algorithm and draw a flow chart to calculate the factorial of a number (N). Verify your result by a trace table by assuming N = 5. Hint: The factorial of N is the product of numbers from 1 to N.
  • 9. 92 Computer Basics with Office Automation Algorithm: Step 1: Input N Step 2: Factor = 1 Step 3: Counter = 1 Step 4: While (Counter £ N) Repeat steps 4 through 6 Step 5: Factor = Factor * Counter Step 6: Counter = Counter + 1 Step 7: Print (N, Factor) Flow chart REVIEW EXERCISE 1. Write an algorithm and draw a flow chart to print the square of all numbers from LOW to HIGH. (Test your algorithm with LOW = 1 and HIGH = 10). 2. Write an algorithm and draw a flow chart to print the SUM of numbers from LOW to HIGH. (Test your algorithm with LOW = 3 and HIGH = 9.) 3. Write an algorithm and draw a flow chart to print all numbers between LOW and HIGH that are divisible by NUMBER.