34
Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Embed Size (px)

Citation preview

Page 1: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Algorithms and Data StructuresSir Joseph LindoUniversity of the Cordilleras

Page 2: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Section 1

Algorithm

Why study algorithm?• Make a lot of money out of great algorithm

• $ 10000000000000000?

• Ex. PageRank Algorithm

Why

Page 3: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Section 1

Algorithm

Why study algorithm?• Make significant contribution to the society

• Ex. Viterbi Algorithm

Why

Page 4: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Section 1

Algorithm

Why study algorithm?• Simply to be cool to invent something in computer science or IT field

• Ex. Shortest Path Algorithm

Why

Page 5: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Why

Algorithm

Definition• An algorithm is a sequence of unambiguous instructions/operations for solving a problem for obtaining a required output for any legitimate input in a finite amount of time

What

Page 6: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Why

Algorithm

What

“computer”+programs

PROBLEM

ALGORITHM

INPUT OUTPUT

Data Structures

Map Navigation AB

Graphs Path

Page 7: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Why

Algorithm

Characteristics• Finiteness

- terminates after a number of steps

• Input- Valid inputs are clearly specified

• Output- can be proven to produce the correct outcome

What

Page 8: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Why

Algorithm

Characteristics• Definiteness- rigorously and unambiguously

specified

• Effectiveness- steps are sufficiently simple and basic

What

Page 9: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Why

Algorithm

Important Points• Each step of an algorithm is unambiguous

•The range of inputs has to be specified carefully

•The same algorithm can be represented in different ways

What

Page 10: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Why

Algorithm

Important Points•The same problem may be solved by different algorithms

•Different algorithms may take different time to solve the same problem – we may prefer one to the other

What

Page 11: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Why

Algorithm

Algorithmic ProblemSolving

What1. Understanding the problem

2. Ascertaining the capabilities of a computational device

3. Choose between exact and approximate problem solving

Page 12: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Why

Algorithm

Algorithmic ProblemSolving

What4. Deciding on appropriate data structure

5. Algorithm design techniques

6. Methods of specifying an algorithm(Pseudocode or diagram)

Page 13: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Why

Algorithm

Algorithmic ProblemSolving

What7. Prove an algorithm’s correctness – mathematic induction

8. Analyzing an algorithm – Simplicity, efficiency, optimality

9. Coding an algorithm

Page 14: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Why

Algorithm

Algorithm Analysis• Correctness

• Time efficiency

• Space efficiency

What

Page 15: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Why

Algorithm

In generalA good algorithm is a result of repeated effort and rework• Better data structure• Better algorithm design• Better time or space efficiency• Easy to implement• Optimal algorithm

What

Page 16: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Why

AlgorithmHow to studyAlgorithm?• Problem

• Representation/data structure in computer

• Operations on representations

How

Page 17: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Why

AlgorithmHow to presentAlgorithm?• Human Language

• Graphical representation (Flow Chart) -->

• Pseudo code -->

Sample Problem

How

Page 18: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Case

What

How

Why

AlgorithmGroup Activity

Write the algorithm in borrowing a book at the University of the Cordilleras.

Represent the algorithm in:• Human Language• Flowchart• Pseudo code

Case

Page 19: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Algorithms and Data StructuresSir Joseph LindoUniversity of the Cordilleras

Page 20: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

PageRank Algorithm

Algorithm

Page 21: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

PageRank Algorithm

Algorithm

• Created by Larry Page

• The “soul” of Google Search Engine

• Google total assets: $31 billions 2008

Page 22: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Viterbi Algorithm

Algorithm

Page 23: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Viterbi Algorithm

Algorithm

• conceived by Andrew Viterbi in 1967 as an error-correction scheme for noisy digital communication links

• Viterbi algorithm is a standard component of tens of millions of high-speed modems

Page 24: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Viterbi Algorithm

Algorithm

• It is a key building block of modern information infrastructureDigitalcellular, dial-up modems, satellite, deep-space 802.11 wireless LANs. speech recognition, keyword spotting, computational linguistics, and bioinformatics.

Page 25: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Shortest Path Algorithm

Algorithm

CLICK HERE FOR MORE INFO

Page 26: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Shortest Path Algorithm

Algorithm

• Used in Google Maps

Page 27: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Flow Chart Symbols

Algorithm

Page 28: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Flow Chart Symbols

Algorithm

Page 29: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Flow Chart Symbols

Algorithm

Page 30: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Pseudo code

Algorithm

It is a cross between human language and a programming language

Page 31: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Name Search Problem

Algorithm

“Create a program that will determine the number of times a name occurs in a list.”

Page 32: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Human Language Representation

Algorithm

1. Get the list of names, let's call this nameList2. Get the name to look for, let's call this the keyname3. Compare the keyname to each of the names in nameList4. If the keyname is the same with a name in the list, add 1 to the count5. If all the names have been compared, output the result

Page 33: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Flowchart Representation

Algorithm

Page 34: Joseph L. Lindo Algorithms and Data Structures Sir Joseph Lindo University of the Cordilleras

Joseph L. Lindo

Pseudo code Representation

Algorithm

Let nameList = List of NamesLet keyName = the name to be soughtLet Count = 0For each name in NameList do the followingif name == keyName

Count = Count + 1Display Count