Section 2

2098 days ago, 675 views
PowerPoint PPT Presentation
Speaking to Algorithms. Characteristic Language - excessively verbose, equivocal and needs structure. ... Surely knew structures permit coherent thinking about calculation conduct ...

Presentation Transcript

Slide 1

Section 2 Algorithm Discovery and Design

Slide 2

Objectives In this part, you will find out about: Representing calculations Examples of algorithmic critical thinking

Slide 3

Introduction This section talks about calculations and algorithmic critical thinking utilizing three issues: Searching records Finding maxima and minima Matching examples

Slide 4

Representing Algorithms N atural Language - excessively verbose, equivocal and needs structure. Formal programming dialects – drives low level points of interest, accentuation, sentence structure punctuation. Pseudocode - English like articulations, exceptionally lucid, no syntactic tenets, and so forth., is effortlessly converted into a programming dialect.

Slide 5

Representing Algorithms Natural dialect Language talked and written in regular daily existence Examples: English, Spanish, Arabic, and so on. Issues with utilizing characteristic dialect for calculations Verbose Imprecise Relies on setting and encounters to give exact intending to a word or expression

Slide 7

Representing Algorithms High-level programming dialect Examples: C++, Java Problem with utilizing an abnormal state programming dialect for calculations During the underlying periods of plan, we are compelled to manage point by point dialect issues

Slide 8

The Beginning of the Addition Algorithm Expressed in a High-Level Programming Language

Slide 9

Representing Algorithms Pseudocode English dialect develops demonstrated to look like proclamations accessible in most programming dialects Steps displayed in an organized way (numbered, indented, and so forth.) No settled sentence structure for most operations is required

Slide 10

Representing Algorithms Pseudocode ( proceeded with) Less uncertain and more intelligible than normal dialect Emphasis is on process, not documentation Well-comprehended structures permit legitimate thinking about calculation conduct Can be effectively converted into a programming dialect

Slide 11

Types of algorithmic operations Sequential Conditional Iterative

Slide 12

Sequential Operations Sequential calculation Also called straight-line calculation Executes its guidelines in a straight line through and through and afterward stops Computation Set the estimation of "variable" to "math expression" where a Variable is a named stockpiling area that can hold an information esteem For Example: Set the estimation of c to a+b or Add an and b to get c

Slide 13

Sequential Operations Input operations To get information values from the outside world Examples: Get values for "variable1", 'variable2",... Get an esteem for r, the range of the circle Output operations To send results to the outside world for show Examples: Print values for "variable1", "variable2",... Print the estimation of Area

Slide 14

Algorithm for Computing Average Miles per Gallon

Slide 15

Conditional and Iterative Operations Control operations Conditional operations "Question asking" operations Often utilize "if" Iterative operations Looping operations Often utilize while or rehash

Slide 16

Conditional Operations Conditional operations Ask addresses and pick elective activities in light of the answers Also called branch or choice operations Example if x is more prominent than 25 then print x else print x times 100

Slide 17

Iterative Operations Iterative operations Perform "circling" conduct; rehashing activities until a continuation condition turns out to be false Loop The redundancy of a piece of directions

Slide 18

Iterative Operations [loops] Pseudocode ( Counting Loop – For Loop) Repeat step I to step J until the "True/False" condition turns out to be genuine Step I: operation … .. Step J :operation

Slide 19

Iterative Operations [loops] Pseudocode ( While circle ) Repeat while a "Genuine/False" Condition is false operation … .. operation End of the circle

Slide 20

Iterative Operations [loops] Pseudocode (Repeat Until Loop) Repeat until a "Genuine/False" Condition becomes genuine operation … .. operation End of the circle

Slide 21

Iterative Operations (circles) Examples For J = 1 to 10 print J while j > 0 do set s to s + a j set j to j - 1 rehash print a k set k to k + 1 until k > n

Slide 22

Second Version of the Average Miles per Gallon Algorithm

Slide 23

Iterative Operations [ loops] Components of a circle Continuation condition Loop body Infinite circle The continuation condition never turns out to be false A mistake

Slide 24

Iterative Operations [ loops] Pretest circle Continuation condition tried toward the start of every go through the circle It is feasible for the circle body to never be executed While circle

Slide 25

Iterative Operations [ loops] Posttest circle Continuation condition tried toward the end of circle body Loop body must be executed at any rate once Do/While circle

Slide 26

Third Version of the Average Miles per Gallon Algorithm

Slide 27

Summary of Pseudocode Language Instructions

Slide 28

Example 1: Go Forth and Multiply A Simple circling issue Multiply two numbers utilizing rehashed option Get values for an and b Determine the estimation of a+a+a+… a+ (b times) Use a circle that executes b times and adds the estimation of a to an aggregate every time Print the estimation of the item

Slide 29

Example 2: Looking, Looking, Looking Examples of algorithmic critical thinking Sequential inquiry : locate a specific esteem in an unordered accumulation Find most extreme : locate the biggest esteem in a gathering of information Pattern coordinating : figure out whether and where a specific example happens in a bit of content

Slide 30

Example 2: Looking, Looking, Looking (proceeded with) Task Find a specific individual's name from an unordered rundown of phone supporters Algorithm plot Start with the primary passage and check its name, then rehash the procedure for all sections

Slide 31

Example 2: Looking, Looking, Looking (proceeded with) Algorithm revelation Finding an answer for a given issue Naïve successive hunt calculation Down every passage, compose a different segment of the calculation that checks for a match Problems Only works for accumulations of precisely one size Duplicates similar operations again and again

Slide 32

Example 2: Looking, Looking, Looking (proceeded with) Correct consecutive pursuit calculation Uses emphasis to improve the undertaking Refers to an esteem in the rundown utilizing a record (or pointer) Handles extraordinary cases (like a name not found in the gathering) Uses the variable Found to leave the cycle when a match is discovered

Slide 33

The Sequential Search Algorithm

Slide 34

Example 2: Looking, Looking, Looking (proceeded with) The choice of a calculation to take care of an issue is incredibly impacted by the way the information for that issue are sorted out

Slide 35

Example 3: Big, Bigger, Biggest Task Find the biggest esteem from a rundown of qualities Algorithm diagram Keep track of the biggest esteem seen in this way (introduced to be the first in the rundown) Compare every esteem to the biggest seen as such, and keep the bigger as the new biggest

Slide 36

Example 3: Big, Bigger, Biggest (proceeded with) Once a calculation has been produced, it might itself be utilized as a part of the development of other, more unpredictable calculations Algorithms can be utilized as the building squares of programming Library A gathering of helpful calculations An essential apparatus in calculation plan and advancement

Slide 37

Example 3: Big, Bigger, Biggest (proceeded with) Find Largest calculation Uses emphasis and files like past illustration Updates area and biggest so far when required on top of it

Slide 38

Algorithm to Find the Largest Value in a List

Slide 39

Example 4: Meeting Your Match Task Find if and where an example string happens inside a more extended bit of content Algorithm layout Try every conceivable area of example string thus At every area, analyze design characters against string characters

Slide 40

Example 4: Meeting Your Match (proceeded with) Abstraction Separating abnormal state see from low-level subtle elements Key idea in software engineering Makes troublesome issues mentally reasonable Allows piece-by-piece improvement of calculations

Slide 41

Example 4: Meeting Your Match (proceeded with) Top-down plan When taking care of a mind boggling issue: Create abnormal state operations in first draft of a calculation After drafting the framework of the calculation, come back to the abnormal state operations and expound every one Repeat until all operations are primitives

Slide 42

Example 3: Meeting Your Match (proceeded with) Pattern-coordinating calculation Contains a circle inside a circle External circle emphasizes through conceivable areas of matches to design Internal circle repeats through relating characters of example and string to assess coordinate

Slide 43

Final Draft of the Pattern-Matching Algorithm

Slide 44

Summary Algorithm outline is an initial phase in building up a calculation Must likewise: Ensure the calculation is right Ensure the calculation is adequately proficient Pseudocode is utilized to outline and speak to calculations

Slide 45

Pattern Matching Some applications Matching expressions in Literature or content Find an example and supplant it with another Web seek ( "Google")- coordinating strings Patterns in X-beams, CAT filters, and so on. Designs in the human genome – entire new field of bioinformatics

Slide 46

Summary Pseudocode is decipherable, unambiguous, and analyzable Algorithm plan is an innovative procedure; utilizes various drafts and top-down outline to build up the best arrangement Abstraction is a key device for good outline

Slide 47

Important Algorithms Sequential pursuit ( Get values) and Start toward the start of rundown Set discovered = false Repeat until found or end of rundown Look at every component If component = target set discovered = genuine and print craved component else move pointer to next component