SlideShare una empresa de Scribd logo
1 de 18
Descargar para leer sin conexión
Data Structures and Algorithms




    Problem Solving
    with Loops

The Loop Logic Structure
A third logic structure for designing decisions is the
loop structure. The loop logic structure is the repeating
structure.

     Types of Loop Structures

  @ WHILE / WHILE-END
  @ REPEAT / UNTIL
  @ AUTOMATIC COUNTER LOOP

Incrementing
The task of incrementing, or counting, is done by
adding a constant, such as 1 or 2, to the value of a
variable. To write the instruction to increment a
variable, you use an assignment statement. For
example:

          COUNTER = COUNTER + 1 or C = C+ 1
Problem Solving with Loops                              *Property of STI
                                                           Page 1 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops


Accumulating
Another task that a program must often perform is
accumulating, or summing a group of numbers. The
process of accumulating is similar to incrementing,
except a variable instead of a constant is added to
another variable, which holds the value of the sum or
total. The instruction for accumulating is the
following :

                        SUM = SUM + VARIABLE
                     PRODUCT = PRODUCT * NUMBER




Problem Solving with Loops                              *Property of STI
                                                           Page 2 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

WHILE / WHILE - END
The first of the three types of loop structures is the
WHILE/WHILE-END structure. This type of loop tells
the computer that while the condition is TRUE, repeat
all instructions between the WHILE and the WHILE-
END. The form of the algorithm is the following:

                             WHILE <CONDITION(S)>
                                INSTRUCTION
                                INSTRUCTION
                                .
                                .
                                .
                             WHILE-END




Problem Solving with Loops                                *Property of STI
                                                             Page 3 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Flowchart Diagram of WHILE/WHILE-END




Problem Solving with Loops                    *Property of STI
                                                 Page 4 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Decision Equivalent to WHILE/WHILE-END




Problem Solving with Loops                     *Property of STI
                                                  Page 5 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Problem : Create the algorithm and the flowchart to
find the average age of all the students in a class.




Problem Solving with Loops                          *Property of STI
                                                       Page 6 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Repeat/Until
The second type of loop structure is the REPEAT/UNTIL
structure. This type of loop tells the computer to
repeat the set of instructions between the REPEAT and
the until, until a condition is TRUE. The format of the
REPEAT/UNTIL algorithm is the following:


                             Repeat
                              Instruction
                              Instruction
                             .
                             .
                             .
                             Until <condition(s)>




Problem Solving with Loops                                    *Property of STI
                                                                 Page 7 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Flowchart Diagram of REPEAT/UNTIL




Problem Solving with Loops                     *Property of STI
                                                  Page 8 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Decision Equivalent to REPEAT/UNTIL




Problem Solving with Loops                      *Property of STI
                                                   Page 9 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Problem : Create the algorithm and the flowchart to
find the average age of all the students in a class.




Problem Solving with Loops                          *Property of STI
                                                      Page 10 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Automatic – Counter Loop
The third type of loop structure is the automatic-
counter loop. This type of loop increments or
decrements a variable each time the loop is repeated.
The form of the algorithm for the automatic counter-
loop is the following :

                LOOP:COUNTER = BEGIN TO END STEP S
                 INSTRUCTION
                 INSTRUCTION
                 .
                 .
                 .
                LOOP-END: COUNTER




Problem Solving with Loops                            *Property of STI
                                                        Page 11 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Decision Equivalent to Automatic-Counter Loop




Problem Solving with Loops                       *Property of STI
                                                   Page 12 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Problem : Create the algorithm and the flowchart to
find the average age of all the students in a class.




Problem Solving with Loops                          *Property of STI
                                                      Page 13 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops


Nested Loops
Loops can be nested like decisions can. Each loop must
be nested inside the loop just outside it. The general
rules regarding loops, such as where the condition is
processed and how indentation and brackets are used,
hold true for nested loops as well as single loops.

The inner loops do not have to be the same types of
loop structures as the outer loops; that is, a WHILE/
WHILE-END may be nested inside a REPEAT/UNTIL loop,
or vice versa.




Problem Solving with Loops                           *Property of STI
                                                       Page 14 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Nested Loops




Problem Solving with Loops                  *Property of STI
                                              Page 15 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops




Problem Solving with Loops                  *Property of STI
                                              Page 16 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Indicators
Indicators – are logical variables that a programmer
sets within a program to change the processing path
or to control when the processing of a loop should end.

They are sometimes called flags, switches, or trip
values.


Recursion
Another type of loop structure is recursion. Recursion
occurs when a module or a function calls itself.




Problem Solving with Loops                            *Property of STI
                                                        Page 17 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops




Problem Solving with Loops                  *Property of STI
                                              Page 18 of 18

Más contenido relacionado

La actualidad más candente

Non Linear Data Structures
Non Linear Data StructuresNon Linear Data Structures
Non Linear Data StructuresAdarsh Patel
 
Basic MIPS implementation
Basic MIPS implementationBasic MIPS implementation
Basic MIPS implementationkavitha2009
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysissumitbardhan
 
Basic Processing Unit
Basic Processing UnitBasic Processing Unit
Basic Processing UnitSlideshare
 
overview of register transfer, micro operations and basic computer organizati...
overview of register transfer, micro operations and basic computer organizati...overview of register transfer, micro operations and basic computer organizati...
overview of register transfer, micro operations and basic computer organizati...Rai University
 
Concept of Pipelining
Concept of PipeliningConcept of Pipelining
Concept of PipeliningSHAKOOR AB
 
BASIC COMPUTER ORGANIZATION AND DESIGN
BASIC  COMPUTER  ORGANIZATION  AND  DESIGNBASIC  COMPUTER  ORGANIZATION  AND  DESIGN
BASIC COMPUTER ORGANIZATION AND DESIGNDr. Ajay Kumar Singh
 
Module - 1 Discrete Mathematics and Graph Theory
Module - 1 Discrete Mathematics and Graph TheoryModule - 1 Discrete Mathematics and Graph Theory
Module - 1 Discrete Mathematics and Graph TheoryAdhiyaman Manickam
 
instruction set Architecture.....(ISA)
instruction set Architecture.....(ISA)instruction set Architecture.....(ISA)
instruction set Architecture.....(ISA)Rao Mubashar
 
Flow chart and pseudo code
Flow chart and pseudo code Flow chart and pseudo code
Flow chart and pseudo code Niva tharan
 
File handling in c
File handling in cFile handling in c
File handling in caakanksha s
 
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDAPush Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDAAshish Duggal
 
Pipeline and data hazard
Pipeline and data hazardPipeline and data hazard
Pipeline and data hazardWaed Shagareen
 
1D Array in Assembly Language
1D Array in Assembly Language1D Array in Assembly Language
1D Array in Assembly LanguageJaveria Yaqoob
 

La actualidad más candente (20)

pushdown automata
pushdown automatapushdown automata
pushdown automata
 
Memory Reference instruction
Memory Reference instructionMemory Reference instruction
Memory Reference instruction
 
Non Linear Data Structures
Non Linear Data StructuresNon Linear Data Structures
Non Linear Data Structures
 
Basic MIPS implementation
Basic MIPS implementationBasic MIPS implementation
Basic MIPS implementation
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysis
 
Basic Computer Organization and Design
Basic  Computer  Organization  and  DesignBasic  Computer  Organization  and  Design
Basic Computer Organization and Design
 
Cpu & its execution of instruction
Cpu & its execution of instructionCpu & its execution of instruction
Cpu & its execution of instruction
 
Basic Processing Unit
Basic Processing UnitBasic Processing Unit
Basic Processing Unit
 
overview of register transfer, micro operations and basic computer organizati...
overview of register transfer, micro operations and basic computer organizati...overview of register transfer, micro operations and basic computer organizati...
overview of register transfer, micro operations and basic computer organizati...
 
Concept of Pipelining
Concept of PipeliningConcept of Pipelining
Concept of Pipelining
 
4.4 hashing
4.4 hashing4.4 hashing
4.4 hashing
 
BASIC COMPUTER ORGANIZATION AND DESIGN
BASIC  COMPUTER  ORGANIZATION  AND  DESIGNBASIC  COMPUTER  ORGANIZATION  AND  DESIGN
BASIC COMPUTER ORGANIZATION AND DESIGN
 
Module - 1 Discrete Mathematics and Graph Theory
Module - 1 Discrete Mathematics and Graph TheoryModule - 1 Discrete Mathematics and Graph Theory
Module - 1 Discrete Mathematics and Graph Theory
 
instruction set Architecture.....(ISA)
instruction set Architecture.....(ISA)instruction set Architecture.....(ISA)
instruction set Architecture.....(ISA)
 
Flow chart and pseudo code
Flow chart and pseudo code Flow chart and pseudo code
Flow chart and pseudo code
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDAPush Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
 
Pipeline and data hazard
Pipeline and data hazardPipeline and data hazard
Pipeline and data hazard
 
CPU Non-Preemptive Scheduling
CPU Non-Preemptive Scheduling CPU Non-Preemptive Scheduling
CPU Non-Preemptive Scheduling
 
1D Array in Assembly Language
1D Array in Assembly Language1D Array in Assembly Language
1D Array in Assembly Language
 

Destacado

Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and FlowchartsDeva Singh
 
Problem Solving Flow Chart
Problem Solving Flow ChartProblem Solving Flow Chart
Problem Solving Flow ChartRick Presley
 
Flowchart pseudocode-examples
Flowchart pseudocode-examplesFlowchart pseudocode-examples
Flowchart pseudocode-examplesGautam Roy
 
Practices of robotics with ROBOLAB and LEGO RCX ROBOT
Practices of robotics with ROBOLAB and LEGO RCX ROBOTPractices of robotics with ROBOLAB and LEGO RCX ROBOT
Practices of robotics with ROBOLAB and LEGO RCX ROBOTalgunastecnocosas
 
Flowchart: A Problem Solving Tool
Flowchart: A Problem Solving ToolFlowchart: A Problem Solving Tool
Flowchart: A Problem Solving ToolQimpro Consultants
 
8 problem solving with the case logic structure
8 problem solving with the case logic structure8 problem solving with the case logic structure
8 problem solving with the case logic structureRheigh Henley Calderon
 
서울 미트업 2015 오픈 소스, 워드프레스, 그리고 커뮤니티
서울 미트업 2015   오픈 소스, 워드프레스, 그리고 커뮤니티서울 미트업 2015   오픈 소스, 워드프레스, 그리고 커뮤니티
서울 미트업 2015 오픈 소스, 워드프레스, 그리고 커뮤니티jekkilekki
 
Flowchart Power Point
Flowchart Power PointFlowchart Power Point
Flowchart Power PointSlideShop.com
 
Defying Logic - Business Logic Testing with Automation
Defying Logic - Business Logic Testing with AutomationDefying Logic - Business Logic Testing with Automation
Defying Logic - Business Logic Testing with AutomationRafal Los
 
2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problem2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problemFrankie Jones
 
ข้อตกลงในการเรียน
ข้อตกลงในการเรียนข้อตกลงในการเรียน
ข้อตกลงในการเรียนManit Wongmool
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch casesMeoRamos
 

Destacado (20)

Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 
Problem Solving Flow Chart
Problem Solving Flow ChartProblem Solving Flow Chart
Problem Solving Flow Chart
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Writing algorithms
Writing algorithmsWriting algorithms
Writing algorithms
 
Loops
LoopsLoops
Loops
 
Flowchart pseudocode-examples
Flowchart pseudocode-examplesFlowchart pseudocode-examples
Flowchart pseudocode-examples
 
Business Capability Analysis
Business Capability AnalysisBusiness Capability Analysis
Business Capability Analysis
 
Practices of robotics with ROBOLAB and LEGO RCX ROBOT
Practices of robotics with ROBOLAB and LEGO RCX ROBOTPractices of robotics with ROBOLAB and LEGO RCX ROBOT
Practices of robotics with ROBOLAB and LEGO RCX ROBOT
 
Flowchart: A Problem Solving Tool
Flowchart: A Problem Solving ToolFlowchart: A Problem Solving Tool
Flowchart: A Problem Solving Tool
 
8 problem solving with the case logic structure
8 problem solving with the case logic structure8 problem solving with the case logic structure
8 problem solving with the case logic structure
 
9 processing arrays
9 processing arrays9 processing arrays
9 processing arrays
 
서울 미트업 2015 오픈 소스, 워드프레스, 그리고 커뮤니티
서울 미트업 2015   오픈 소스, 워드프레스, 그리고 커뮤니티서울 미트업 2015   오픈 소스, 워드프레스, 그리고 커뮤니티
서울 미트업 2015 오픈 소스, 워드프레스, 그리고 커뮤니티
 
10 data structures
10 data structures10 data structures
10 data structures
 
Iteration
IterationIteration
Iteration
 
Flowchart Power Point
Flowchart Power PointFlowchart Power Point
Flowchart Power Point
 
Defying Logic - Business Logic Testing with Automation
Defying Logic - Business Logic Testing with AutomationDefying Logic - Business Logic Testing with Automation
Defying Logic - Business Logic Testing with Automation
 
2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problem2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problem
 
ECDL
ECDL ECDL
ECDL
 
ข้อตกลงในการเรียน
ข้อตกลงในการเรียนข้อตกลงในการเรียน
ข้อตกลงในการเรียน
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
 

Similar a 7 problem solving with loops

CIS110 Computer Programming Design Chapter (3)
CIS110 Computer Programming Design Chapter  (3)CIS110 Computer Programming Design Chapter  (3)
CIS110 Computer Programming Design Chapter (3)Dr. Ahmed Al Zaidy
 
01VD062009003760042.pdf
01VD062009003760042.pdf01VD062009003760042.pdf
01VD062009003760042.pdfSunilMatsagar1
 
R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to MatricesRsquared Academy
 
Understanding Parallelization of Machine Learning Algorithms in Apache Spark™
Understanding Parallelization of Machine Learning Algorithms in Apache Spark™Understanding Parallelization of Machine Learning Algorithms in Apache Spark™
Understanding Parallelization of Machine Learning Algorithms in Apache Spark™Databricks
 
A tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbiesA tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbiesVimal Gupta
 
Some "challenges" on the open-source/open-data front
Some "challenges" on the open-source/open-data frontSome "challenges" on the open-source/open-data front
Some "challenges" on the open-source/open-data frontGreg Landrum
 
Reinforcement learning-ebook-part1
Reinforcement learning-ebook-part1Reinforcement learning-ebook-part1
Reinforcement learning-ebook-part1Rajmeet Singh
 
Reinforcement Learning / E-Book / Part 1
Reinforcement Learning / E-Book / Part 1Reinforcement Learning / E-Book / Part 1
Reinforcement Learning / E-Book / Part 1Hitesh Mohapatra
 
Web UI, Algorithms, and Feature Engineering
Web UI, Algorithms, and Feature Engineering Web UI, Algorithms, and Feature Engineering
Web UI, Algorithms, and Feature Engineering BigML, Inc
 
Online Machine Learning: introduction and examples
Online Machine Learning:  introduction and examplesOnline Machine Learning:  introduction and examples
Online Machine Learning: introduction and examplesFelipe
 
GLM & GBM in H2O
GLM & GBM in H2OGLM & GBM in H2O
GLM & GBM in H2OSri Ambati
 
IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...
IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...
IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...Yamato OKAMOTO
 
Extended pso algorithm for improvement problems k means clustering algorithm
Extended pso algorithm for improvement problems k means clustering algorithmExtended pso algorithm for improvement problems k means clustering algorithm
Extended pso algorithm for improvement problems k means clustering algorithmIJMIT JOURNAL
 
A boolean modeling for improving
A boolean modeling for improvingA boolean modeling for improving
A boolean modeling for improvingcsandit
 

Similar a 7 problem solving with loops (20)

3 programming concepts
3 programming concepts3 programming concepts
3 programming concepts
 
CIS110 Computer Programming Design Chapter (3)
CIS110 Computer Programming Design Chapter  (3)CIS110 Computer Programming Design Chapter  (3)
CIS110 Computer Programming Design Chapter (3)
 
01VD062009003760042.pdf
01VD062009003760042.pdf01VD062009003760042.pdf
01VD062009003760042.pdf
 
R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to Matrices
 
cp.docx
cp.docxcp.docx
cp.docx
 
Understanding Parallelization of Machine Learning Algorithms in Apache Spark™
Understanding Parallelization of Machine Learning Algorithms in Apache Spark™Understanding Parallelization of Machine Learning Algorithms in Apache Spark™
Understanding Parallelization of Machine Learning Algorithms in Apache Spark™
 
A tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbiesA tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbies
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Algoritmos
AlgoritmosAlgoritmos
Algoritmos
 
Some "challenges" on the open-source/open-data front
Some "challenges" on the open-source/open-data frontSome "challenges" on the open-source/open-data front
Some "challenges" on the open-source/open-data front
 
Reinforcement learning-ebook-part1
Reinforcement learning-ebook-part1Reinforcement learning-ebook-part1
Reinforcement learning-ebook-part1
 
Reinforcement Learning / E-Book / Part 1
Reinforcement Learning / E-Book / Part 1Reinforcement Learning / E-Book / Part 1
Reinforcement Learning / E-Book / Part 1
 
Web UI, Algorithms, and Feature Engineering
Web UI, Algorithms, and Feature Engineering Web UI, Algorithms, and Feature Engineering
Web UI, Algorithms, and Feature Engineering
 
Online Machine Learning: introduction and examples
Online Machine Learning:  introduction and examplesOnline Machine Learning:  introduction and examples
Online Machine Learning: introduction and examples
 
ilp
ilpilp
ilp
 
GLM & GBM in H2O
GLM & GBM in H2OGLM & GBM in H2O
GLM & GBM in H2O
 
algo 1.ppt
algo 1.pptalgo 1.ppt
algo 1.ppt
 
IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...
IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...
IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...
 
Extended pso algorithm for improvement problems k means clustering algorithm
Extended pso algorithm for improvement problems k means clustering algorithmExtended pso algorithm for improvement problems k means clustering algorithm
Extended pso algorithm for improvement problems k means clustering algorithm
 
A boolean modeling for improving
A boolean modeling for improvingA boolean modeling for improving
A boolean modeling for improving
 

Más de Rheigh Henley Calderon (20)

4 introduction to programming structure
4 introduction to programming structure4 introduction to programming structure
4 introduction to programming structure
 
2 beginning problem solving concepts for the computer
2 beginning problem solving concepts for the computer2 beginning problem solving concepts for the computer
2 beginning problem solving concepts for the computer
 
1 introduction to problem solving and programming
1 introduction to problem solving and programming1 introduction to problem solving and programming
1 introduction to problem solving and programming
 
9 technical support
9 technical support9 technical support
9 technical support
 
8 customer service
8 customer service8 customer service
8 customer service
 
7 laptop repair
7 laptop repair7 laptop repair
7 laptop repair
 
6 laptop basics
6 laptop basics6 laptop basics
6 laptop basics
 
5 pc maintenance
5 pc maintenance5 pc maintenance
5 pc maintenance
 
4 pc repair
4 pc repair4 pc repair
4 pc repair
 
3 pc upgrade
3 pc upgrade3 pc upgrade
3 pc upgrade
 
2 pc assembly
2 pc assembly2 pc assembly
2 pc assembly
 
1 hardware fundamentals
1 hardware fundamentals1 hardware fundamentals
1 hardware fundamentals
 
8 cyber crimes
8 cyber crimes8 cyber crimes
8 cyber crimes
 
7 computer ethics
7 computer ethics7 computer ethics
7 computer ethics
 
6 professional ethics
6 professional ethics6 professional ethics
6 professional ethics
 
5 business ethics
5 business ethics5 business ethics
5 business ethics
 
4 human relation
4 human relation4 human relation
4 human relation
 
2 morality
2 morality2 morality
2 morality
 
3 rights and duties
3 rights and duties3 rights and duties
3 rights and duties
 
1 general ethics
1 general ethics1 general ethics
1 general ethics
 

Último

AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 

Último (20)

AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 

7 problem solving with loops

  • 1. Data Structures and Algorithms Problem Solving with Loops The Loop Logic Structure A third logic structure for designing decisions is the loop structure. The loop logic structure is the repeating structure. Types of Loop Structures @ WHILE / WHILE-END @ REPEAT / UNTIL @ AUTOMATIC COUNTER LOOP Incrementing The task of incrementing, or counting, is done by adding a constant, such as 1 or 2, to the value of a variable. To write the instruction to increment a variable, you use an assignment statement. For example: COUNTER = COUNTER + 1 or C = C+ 1 Problem Solving with Loops *Property of STI Page 1 of 18
  • 2. Data Structures and Algorithms Problem Solving with Loops Accumulating Another task that a program must often perform is accumulating, or summing a group of numbers. The process of accumulating is similar to incrementing, except a variable instead of a constant is added to another variable, which holds the value of the sum or total. The instruction for accumulating is the following : SUM = SUM + VARIABLE PRODUCT = PRODUCT * NUMBER Problem Solving with Loops *Property of STI Page 2 of 18
  • 3. Data Structures and Algorithms Problem Solving with Loops WHILE / WHILE - END The first of the three types of loop structures is the WHILE/WHILE-END structure. This type of loop tells the computer that while the condition is TRUE, repeat all instructions between the WHILE and the WHILE- END. The form of the algorithm is the following: WHILE <CONDITION(S)> INSTRUCTION INSTRUCTION . . . WHILE-END Problem Solving with Loops *Property of STI Page 3 of 18
  • 4. Data Structures and Algorithms Problem Solving with Loops Flowchart Diagram of WHILE/WHILE-END Problem Solving with Loops *Property of STI Page 4 of 18
  • 5. Data Structures and Algorithms Problem Solving with Loops Decision Equivalent to WHILE/WHILE-END Problem Solving with Loops *Property of STI Page 5 of 18
  • 6. Data Structures and Algorithms Problem Solving with Loops Problem : Create the algorithm and the flowchart to find the average age of all the students in a class. Problem Solving with Loops *Property of STI Page 6 of 18
  • 7. Data Structures and Algorithms Problem Solving with Loops Repeat/Until The second type of loop structure is the REPEAT/UNTIL structure. This type of loop tells the computer to repeat the set of instructions between the REPEAT and the until, until a condition is TRUE. The format of the REPEAT/UNTIL algorithm is the following: Repeat Instruction Instruction . . . Until <condition(s)> Problem Solving with Loops *Property of STI Page 7 of 18
  • 8. Data Structures and Algorithms Problem Solving with Loops Flowchart Diagram of REPEAT/UNTIL Problem Solving with Loops *Property of STI Page 8 of 18
  • 9. Data Structures and Algorithms Problem Solving with Loops Decision Equivalent to REPEAT/UNTIL Problem Solving with Loops *Property of STI Page 9 of 18
  • 10. Data Structures and Algorithms Problem Solving with Loops Problem : Create the algorithm and the flowchart to find the average age of all the students in a class. Problem Solving with Loops *Property of STI Page 10 of 18
  • 11. Data Structures and Algorithms Problem Solving with Loops Automatic – Counter Loop The third type of loop structure is the automatic- counter loop. This type of loop increments or decrements a variable each time the loop is repeated. The form of the algorithm for the automatic counter- loop is the following : LOOP:COUNTER = BEGIN TO END STEP S INSTRUCTION INSTRUCTION . . . LOOP-END: COUNTER Problem Solving with Loops *Property of STI Page 11 of 18
  • 12. Data Structures and Algorithms Problem Solving with Loops Decision Equivalent to Automatic-Counter Loop Problem Solving with Loops *Property of STI Page 12 of 18
  • 13. Data Structures and Algorithms Problem Solving with Loops Problem : Create the algorithm and the flowchart to find the average age of all the students in a class. Problem Solving with Loops *Property of STI Page 13 of 18
  • 14. Data Structures and Algorithms Problem Solving with Loops Nested Loops Loops can be nested like decisions can. Each loop must be nested inside the loop just outside it. The general rules regarding loops, such as where the condition is processed and how indentation and brackets are used, hold true for nested loops as well as single loops. The inner loops do not have to be the same types of loop structures as the outer loops; that is, a WHILE/ WHILE-END may be nested inside a REPEAT/UNTIL loop, or vice versa. Problem Solving with Loops *Property of STI Page 14 of 18
  • 15. Data Structures and Algorithms Problem Solving with Loops Nested Loops Problem Solving with Loops *Property of STI Page 15 of 18
  • 16. Data Structures and Algorithms Problem Solving with Loops Problem Solving with Loops *Property of STI Page 16 of 18
  • 17. Data Structures and Algorithms Problem Solving with Loops Indicators Indicators – are logical variables that a programmer sets within a program to change the processing path or to control when the processing of a loop should end. They are sometimes called flags, switches, or trip values. Recursion Another type of loop structure is recursion. Recursion occurs when a module or a function calls itself. Problem Solving with Loops *Property of STI Page 17 of 18
  • 18. Data Structures and Algorithms Problem Solving with Loops Problem Solving with Loops *Property of STI Page 18 of 18