SlideShare a Scribd company logo
Algorithm Design and
Problem Solving
Kaavya gaur
Introduction
In order to build a computer system that performs a
specific task or solves a given problem, the task or
problem has to be clearly defined, showing what is
going to be computed and how it is going to be
computed.
This chapter introduces the tools and techniques that
are used to design a software solution that together
with the associated computer hardware will form a
computer system.
What is a computer system?
• A COMPUTER SYSTEM is made up of software, data, hardware, communications
and people.
• each computer system can be divided up into a set of sub-systems. Each subsystem
can be further divided into sub-systems and so on until each sub-system just
performs a single action.
For example, when I wake up in the morning I use an app on my smart phone for my alarm, I then check the
weather forecast on my computer before I drive to work.
The alarm program is a very small computer system; when I check the weather forecast I
obtain information from one of the largest computer systems in the world
Activity
• Identify at least five computer systems you frequently use in your daily life.
See if you can decide the size of each system.
Tools and techniques
• In order to understand how a computer system is built up and how it works,
it is often divided up into sub-systems.
• This division can be shown using :
 Top-down design
 Sub-system
 Sub-routine
 Flowcharts or pseudocode
Top-down design
• TOP-DOWN DESIGN is the breaking down
of a computer system into a set of
subsystems, then breaking each sub-system
down into a set of smaller sub-systems, until
each sub-system just performs a single action.
• The process of breaking down into smaller
sub-systems is called ‘stepwise refinement’.
Structure diagrams
• The STRUCTURE DIAGRAM shows the design of a computer system in a
hierarchical way, with each level giving a more detailed breakdown of the
system into sub-systems.
• For eg : Alarm app for a smart phone
Structure diagram for alarm app
Flowcharts
Flowchart for checking-for-the-alarm-time sub-system
This symbol
means this
process is defined
elsewhere.
flowchart for the algorithm
to calculate the cost of
buying a given number of
tickets.
Library routines and Sub-routines
• A LIBRARY ROUTINE is a set of programming instructions for a given
task that is already available for use. It is pre-tested and usually performs a
task that is frequently required. For example, the task ‘get time’ in the
checking-for-the-alarm time algorithm would probably be readily available as
a library routine.
• A SUB-ROUTINE is a set of programming instructions for a given task
that forms a sub system, not the whole system. Sub-routines written in high-
level programming languages are called ‘procedures’ or ‘functions’ depending
on how they are used.
HOW TO WRITE PSEUDOCODE
• Always capitalize the initial word (often one of the main six constructs). (READ, WRITE, IF,
WHILE, UNTIL).
• Make only one statement per line.
• Indent to show hierarchy, improve readability, and show nested constructs.
• Always end multi-line sections using any of the END keywords (ENDIF, ENDWHILE, etc.).
• Keep your statements programming language independent.
• Use the naming domain of the problem, not that of the implementation. For instance: “Append
the last name to the first name” instead of “name = first+ last.”
• Keep it simple, concise and readable.
THE MAIN CONSTRUCTS OF
PSEUDOCODE
• SEQUENCE represents linear tasks sequentially performed one after the
other.
• WHILE a loop with a condition at its beginning.
• REPEAT-UNTIL a loop with a condition at the bottom.
• FOR another way of looping.
• IF-THEN-ELSE a conditional statement changing the flow of the
algorithm.
Conditional statements
• A condition that can be true or false:
IF … THEN … ELSE … ENDIF,
• for example
IF Age < 18
THEN PRINT "Child"
ELSE PRINT "Adult"
ENDIF
• A choice between several different values:
• CASE … OF … OTHERWISE … ENDCASE,
• for example:
CASE Grade OF
"A" : PRINT "Excellent"
"B" : PRINT "Good"
"C" : PRINT "Average”
OTHERWISE PRINT "Improvement is needed"
ENDCASE
Comparison operators
The algorithm below checks if a percentage mark is valid and a pass or a fail.
This makes use of two IF statements. The second IF statement is part of the
ELSE path of the first IF statement. This is called a nested IF.
Loop structures
FOR … TO … NEXT
REPEAT … UNTIL
• This loop structure is used
when the number of
repetitions/iterations is not
known and the actions are
repeated UNTIL a given
condition becomes true.
The actions in this loop are
always completed at least
once
WHILE … DO … ENDWHILE
• This loop structure is used when
the number of
repetitions/iterations is not
known and the actions are only
repeated WHILE a given
condition is true. If the WHILE
condition is untrue when the loop
is first entered then the actions in
the loop are never performed.
Pseudocode
• PSEUDOCODE is a simple method of showing an algorithm, using
English-like words and mathematical operators that are set out to look like a
program
Pseudocode for the
checking-for-the-
alarm-time
algorithm
Tickets are sold for a concert at $20
each. If 10 tickets are bought then the
discount is 10%; if 20 tickets are
bought the discount is 20%. No more
than 25 tickets can be bought in a single
transaction. a Use pseudocode to write
an algorithm to calculate the cost of
buying a given number of tickets.
• REPEAT
• PRINT "How many tickets would you like to buy?"
• INPUT NumberOfTickets
• UNTIL NumberOfTickets > 0 AND NumberOfTickets < 26
• IF NumberOfTickets < 10
• THEN Discount ← 0
• ELSE
• IF NumberOfTickets < 20
• THEN Discount ← 0.1
• ELSE Discount ← 0.2
• ENDIF
• ENDIF
• Cost ← NumberOfTickets * 20 * (1 – Discount)
• PRINT "Your tickets cost", Cost
Standard Method's of solution
• Totalling
• Counting
• Finding maximum , minimum and average values
• Searching using a linear search
Standard Method's of solution
• Variable Assignments
When devising an algorithm the programmer will need to use variables and assign values to them. This is indicated
in pseudocode using an arrow symbol (←). The arrow points from the value being assigned towards the variable it
is being assigned to. The following line of pseudocode should be read as 'a becomes equal to 34'.
a ← 34
• Totaling and Counting : The assignment operator can also be used when finding totals, as shown in the
following example where x becomes equal to a plus b.
x ← a + b
Similarly we can also use the assignment operator for counting, by assigning a variable to become equal to the value
of itself plus 1.
x ← x + 1
• Input and Output : Output is the act or returning some data to the user of
the program. This could be in the form of a written message, a numerical
value, an image, video or sound. This is shown in pseudocode by writing
OUTPUT followed by what the output will be. The example below shows
how we would output the message 'Hello World':
OUTPUT 'Hello World'
Read Number n and print the integers
counting upto n
BEGIN
READ n
INITIALIZE i to 1
FOR i <= n, then
DISPLAY i
INCREMENT i
END FOR
END
Psuedo code for finding max,min and average
marks from the class.
MaxMarks  StudentMarks[1]
MinMarks StudentMarks[1]
For Counter 2 TO ClassSize
IF StudentMarks[Counter] > MaxMArks
THEN
MaxMarks  StudentMarks[Counter]
End if
IF StudentMark[Counter] < MinMarks
THEN
MinMarks StudentMark[Counter]
ENDIF
NEXT Counter
Total  0
For Counter  1 TO ClassSize
Total  Total +
StudentMArks[Counter]
NEXT Counter
Average  Total / ClassSize
Pseudocode for linear search
OUTPUT: “Please enter name to find”
INPUT : Name
Found  FALSE
Counter  1
REPEAT
IF Name = StudentName[Counter]
THEN
Found  TRUE
ELSE
Counter  Counter + 1
ENDIF
UNTIL Found OR Counter > ClassSize
THEN
OUTPUT Name “ Found at
position”, Counter,” in the list.”
ELSE
OTPUT NAME ,’Not found”
ENDIF

More Related Content

What's hot

Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
Aakashdata
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
Syed Zaid Irshad
 
Problem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to CProblem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to C
Prabu U
 
Chapter 3-Data Representation in Computers.ppt
Chapter 3-Data Representation in Computers.pptChapter 3-Data Representation in Computers.ppt
Chapter 3-Data Representation in Computers.ppt
KalGetachew2
 
Operating system architecture
Operating system architectureOperating system architecture
Operating system architecture
Sabin dumre
 
Python final ppt
Python final pptPython final ppt
Python final ppt
Ripal Ranpara
 
Introduction to c programming language
Introduction to c programming languageIntroduction to c programming language
Introduction to c programming language
sanjay joshi
 
Flowcharts and algorithms
Flowcharts and algorithmsFlowcharts and algorithms
Flowcharts and algorithms
Student
 
Algorithm
AlgorithmAlgorithm
Algorithm
IHTISHAM UL HAQ
 
Introduction to Coding
Introduction to CodingIntroduction to Coding
Introduction to Coding
St. Petersburg College
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
Kamal Acharya
 
Computer Programming - Lecture 1
Computer Programming - Lecture 1Computer Programming - Lecture 1
Computer Programming - Lecture 1
Dr. Md. Shohel Sayeed
 
structured programming
structured programmingstructured programming
structured programming
Ahmad54321
 
Programming
ProgrammingProgramming
Programming
Leo Simon Anfone
 
Lecture 3 basic syntax and semantics
Lecture 3  basic syntax and semanticsLecture 3  basic syntax and semantics
Lecture 3 basic syntax and semantics
alvin567
 
Basics of python
Basics of pythonBasics of python
Basics of python
SurjeetSinghSurjeetS
 
Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowcharts
nicky_walters
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
Sangheethaa Sukumaran
 
Intro to assembly language
Intro to assembly languageIntro to assembly language
Intro to assembly language
United International University
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
Varun Garg
 

What's hot (20)

Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
 
Problem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to CProblem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to C
 
Chapter 3-Data Representation in Computers.ppt
Chapter 3-Data Representation in Computers.pptChapter 3-Data Representation in Computers.ppt
Chapter 3-Data Representation in Computers.ppt
 
Operating system architecture
Operating system architectureOperating system architecture
Operating system architecture
 
Python final ppt
Python final pptPython final ppt
Python final ppt
 
Introduction to c programming language
Introduction to c programming languageIntroduction to c programming language
Introduction to c programming language
 
Flowcharts and algorithms
Flowcharts and algorithmsFlowcharts and algorithms
Flowcharts and algorithms
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Introduction to Coding
Introduction to CodingIntroduction to Coding
Introduction to Coding
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Computer Programming - Lecture 1
Computer Programming - Lecture 1Computer Programming - Lecture 1
Computer Programming - Lecture 1
 
structured programming
structured programmingstructured programming
structured programming
 
Programming
ProgrammingProgramming
Programming
 
Lecture 3 basic syntax and semantics
Lecture 3  basic syntax and semanticsLecture 3  basic syntax and semantics
Lecture 3 basic syntax and semantics
 
Basics of python
Basics of pythonBasics of python
Basics of python
 
Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowcharts
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
Intro to assembly language
Intro to assembly languageIntro to assembly language
Intro to assembly language
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 

Similar to Algorithm Design and Problem Solving [Autosaved].pptx

Qbasic notes
Qbasic notesQbasic notes
Qbasic notes
NasirRohail1
 
Cse115 lecture03problemsolving
Cse115 lecture03problemsolvingCse115 lecture03problemsolving
Cse115 lecture03problemsolving
Md. Ashikur Rahman
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptx
TadiwaMawere
 
Introduction to programming - class 2
Introduction to programming - class 2Introduction to programming - class 2
Introduction to programming - class 2
Paul Brebner
 
Unit 2 - Complete (1).pptx
Unit 2 - Complete (1).pptxUnit 2 - Complete (1).pptx
Unit 2 - Complete (1).pptx
gogulram2
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
Mard Geer
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
SourabhPal46
 
classVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptxclassVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptx
ssusere336f4
 
02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx
arifaqazi2
 
Flowcharting week 5 2019 2020
Flowcharting week 5  2019  2020Flowcharting week 5  2019  2020
Flowcharting week 5 2019 2020
Osama Ghandour Geris
 
Problem solving and design
Problem solving and designProblem solving and design
Problem solving and design
zahid785
 
Flow charts week 5 2020 2021
Flow charts week 5 2020  2021Flow charts week 5 2020  2021
Flow charts week 5 2020 2021
Osama Ghandour Geris
 
Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1
Amr Alaa El Deen
 
Small Basic - Branching and Loop
Small Basic - Branching and LoopSmall Basic - Branching and Loop
Small Basic - Branching and Loop
Grayzon Gonzales, LPT
 
Algorithm and C code related to data structure
Algorithm and C code related to data structureAlgorithm and C code related to data structure
Algorithm and C code related to data structure
Self-Employed
 
Lec-ProblemSolving.pptx
Lec-ProblemSolving.pptxLec-ProblemSolving.pptx
Lec-ProblemSolving.pptx
miansaad18
 
programming.ppt
programming.pptprogramming.ppt
programming.ppt
AdrianVANTOPINA
 
learn computer science.ppt
learn computer science.pptlearn computer science.ppt
learn computer science.ppt
faithola1
 
Introduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- PythonIntroduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- Python
PriyankaC44
 
Algorithms - Introduction to computer programming
Algorithms - Introduction to computer programmingAlgorithms - Introduction to computer programming
Algorithms - Introduction to computer programming
baabtra.com - No. 1 supplier of quality freshers
 

Similar to Algorithm Design and Problem Solving [Autosaved].pptx (20)

Qbasic notes
Qbasic notesQbasic notes
Qbasic notes
 
Cse115 lecture03problemsolving
Cse115 lecture03problemsolvingCse115 lecture03problemsolving
Cse115 lecture03problemsolving
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptx
 
Introduction to programming - class 2
Introduction to programming - class 2Introduction to programming - class 2
Introduction to programming - class 2
 
Unit 2 - Complete (1).pptx
Unit 2 - Complete (1).pptxUnit 2 - Complete (1).pptx
Unit 2 - Complete (1).pptx
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
 
classVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptxclassVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptx
 
02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx
 
Flowcharting week 5 2019 2020
Flowcharting week 5  2019  2020Flowcharting week 5  2019  2020
Flowcharting week 5 2019 2020
 
Problem solving and design
Problem solving and designProblem solving and design
Problem solving and design
 
Flow charts week 5 2020 2021
Flow charts week 5 2020  2021Flow charts week 5 2020  2021
Flow charts week 5 2020 2021
 
Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1
 
Small Basic - Branching and Loop
Small Basic - Branching and LoopSmall Basic - Branching and Loop
Small Basic - Branching and Loop
 
Algorithm and C code related to data structure
Algorithm and C code related to data structureAlgorithm and C code related to data structure
Algorithm and C code related to data structure
 
Lec-ProblemSolving.pptx
Lec-ProblemSolving.pptxLec-ProblemSolving.pptx
Lec-ProblemSolving.pptx
 
programming.ppt
programming.pptprogramming.ppt
programming.ppt
 
learn computer science.ppt
learn computer science.pptlearn computer science.ppt
learn computer science.ppt
 
Introduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- PythonIntroduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- Python
 
Algorithms - Introduction to computer programming
Algorithms - Introduction to computer programmingAlgorithms - Introduction to computer programming
Algorithms - Introduction to computer programming
 

Recently uploaded

Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
UReason
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
AjmalKhan50578
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Certificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi AhmedCertificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi Ahmed
Mahmoud Morsy
 
BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
LAXMAREDDY22
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
SakkaravarthiShanmug
 
AI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptxAI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptx
architagupta876
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
Las Vegas Warehouse
 

Recently uploaded (20)

Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Certificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi AhmedCertificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi Ahmed
 
BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
 
AI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptxAI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptx
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
 

Algorithm Design and Problem Solving [Autosaved].pptx

  • 1. Algorithm Design and Problem Solving Kaavya gaur
  • 2. Introduction In order to build a computer system that performs a specific task or solves a given problem, the task or problem has to be clearly defined, showing what is going to be computed and how it is going to be computed. This chapter introduces the tools and techniques that are used to design a software solution that together with the associated computer hardware will form a computer system.
  • 3. What is a computer system? • A COMPUTER SYSTEM is made up of software, data, hardware, communications and people. • each computer system can be divided up into a set of sub-systems. Each subsystem can be further divided into sub-systems and so on until each sub-system just performs a single action.
  • 4. For example, when I wake up in the morning I use an app on my smart phone for my alarm, I then check the weather forecast on my computer before I drive to work. The alarm program is a very small computer system; when I check the weather forecast I obtain information from one of the largest computer systems in the world
  • 5. Activity • Identify at least five computer systems you frequently use in your daily life. See if you can decide the size of each system.
  • 6. Tools and techniques • In order to understand how a computer system is built up and how it works, it is often divided up into sub-systems. • This division can be shown using :  Top-down design  Sub-system  Sub-routine  Flowcharts or pseudocode
  • 7. Top-down design • TOP-DOWN DESIGN is the breaking down of a computer system into a set of subsystems, then breaking each sub-system down into a set of smaller sub-systems, until each sub-system just performs a single action. • The process of breaking down into smaller sub-systems is called ‘stepwise refinement’.
  • 8. Structure diagrams • The STRUCTURE DIAGRAM shows the design of a computer system in a hierarchical way, with each level giving a more detailed breakdown of the system into sub-systems. • For eg : Alarm app for a smart phone
  • 11.
  • 12. Flowchart for checking-for-the-alarm-time sub-system This symbol means this process is defined elsewhere.
  • 13. flowchart for the algorithm to calculate the cost of buying a given number of tickets.
  • 14. Library routines and Sub-routines • A LIBRARY ROUTINE is a set of programming instructions for a given task that is already available for use. It is pre-tested and usually performs a task that is frequently required. For example, the task ‘get time’ in the checking-for-the-alarm time algorithm would probably be readily available as a library routine. • A SUB-ROUTINE is a set of programming instructions for a given task that forms a sub system, not the whole system. Sub-routines written in high- level programming languages are called ‘procedures’ or ‘functions’ depending on how they are used.
  • 15. HOW TO WRITE PSEUDOCODE • Always capitalize the initial word (often one of the main six constructs). (READ, WRITE, IF, WHILE, UNTIL). • Make only one statement per line. • Indent to show hierarchy, improve readability, and show nested constructs. • Always end multi-line sections using any of the END keywords (ENDIF, ENDWHILE, etc.). • Keep your statements programming language independent. • Use the naming domain of the problem, not that of the implementation. For instance: “Append the last name to the first name” instead of “name = first+ last.” • Keep it simple, concise and readable.
  • 16. THE MAIN CONSTRUCTS OF PSEUDOCODE • SEQUENCE represents linear tasks sequentially performed one after the other. • WHILE a loop with a condition at its beginning. • REPEAT-UNTIL a loop with a condition at the bottom. • FOR another way of looping. • IF-THEN-ELSE a conditional statement changing the flow of the algorithm.
  • 17. Conditional statements • A condition that can be true or false: IF … THEN … ELSE … ENDIF, • for example IF Age < 18 THEN PRINT "Child" ELSE PRINT "Adult" ENDIF
  • 18. • A choice between several different values: • CASE … OF … OTHERWISE … ENDCASE, • for example: CASE Grade OF "A" : PRINT "Excellent" "B" : PRINT "Good" "C" : PRINT "Average” OTHERWISE PRINT "Improvement is needed" ENDCASE
  • 20. The algorithm below checks if a percentage mark is valid and a pass or a fail. This makes use of two IF statements. The second IF statement is part of the ELSE path of the first IF statement. This is called a nested IF.
  • 22. FOR … TO … NEXT
  • 23. REPEAT … UNTIL • This loop structure is used when the number of repetitions/iterations is not known and the actions are repeated UNTIL a given condition becomes true. The actions in this loop are always completed at least once
  • 24. WHILE … DO … ENDWHILE • This loop structure is used when the number of repetitions/iterations is not known and the actions are only repeated WHILE a given condition is true. If the WHILE condition is untrue when the loop is first entered then the actions in the loop are never performed.
  • 25. Pseudocode • PSEUDOCODE is a simple method of showing an algorithm, using English-like words and mathematical operators that are set out to look like a program Pseudocode for the checking-for-the- alarm-time algorithm
  • 26. Tickets are sold for a concert at $20 each. If 10 tickets are bought then the discount is 10%; if 20 tickets are bought the discount is 20%. No more than 25 tickets can be bought in a single transaction. a Use pseudocode to write an algorithm to calculate the cost of buying a given number of tickets. • REPEAT • PRINT "How many tickets would you like to buy?" • INPUT NumberOfTickets • UNTIL NumberOfTickets > 0 AND NumberOfTickets < 26 • IF NumberOfTickets < 10 • THEN Discount ← 0 • ELSE • IF NumberOfTickets < 20 • THEN Discount ← 0.1 • ELSE Discount ← 0.2 • ENDIF • ENDIF • Cost ← NumberOfTickets * 20 * (1 – Discount) • PRINT "Your tickets cost", Cost
  • 27. Standard Method's of solution • Totalling • Counting • Finding maximum , minimum and average values • Searching using a linear search
  • 28. Standard Method's of solution • Variable Assignments When devising an algorithm the programmer will need to use variables and assign values to them. This is indicated in pseudocode using an arrow symbol (←). The arrow points from the value being assigned towards the variable it is being assigned to. The following line of pseudocode should be read as 'a becomes equal to 34'. a ← 34 • Totaling and Counting : The assignment operator can also be used when finding totals, as shown in the following example where x becomes equal to a plus b. x ← a + b Similarly we can also use the assignment operator for counting, by assigning a variable to become equal to the value of itself plus 1. x ← x + 1
  • 29. • Input and Output : Output is the act or returning some data to the user of the program. This could be in the form of a written message, a numerical value, an image, video or sound. This is shown in pseudocode by writing OUTPUT followed by what the output will be. The example below shows how we would output the message 'Hello World': OUTPUT 'Hello World'
  • 30. Read Number n and print the integers counting upto n BEGIN READ n INITIALIZE i to 1 FOR i <= n, then DISPLAY i INCREMENT i END FOR END
  • 31. Psuedo code for finding max,min and average marks from the class. MaxMarks  StudentMarks[1] MinMarks StudentMarks[1] For Counter 2 TO ClassSize IF StudentMarks[Counter] > MaxMArks THEN MaxMarks  StudentMarks[Counter] End if IF StudentMark[Counter] < MinMarks THEN MinMarks StudentMark[Counter] ENDIF NEXT Counter Total  0 For Counter  1 TO ClassSize Total  Total + StudentMArks[Counter] NEXT Counter Average  Total / ClassSize
  • 32. Pseudocode for linear search OUTPUT: “Please enter name to find” INPUT : Name Found  FALSE Counter  1 REPEAT IF Name = StudentName[Counter] THEN Found  TRUE ELSE Counter  Counter + 1 ENDIF UNTIL Found OR Counter > ClassSize THEN OUTPUT Name “ Found at position”, Counter,” in the list.” ELSE OTPUT NAME ,’Not found” ENDIF