2 views

Uploaded by Mandeep Singh

save

- 107352_Lec06b_QuicksortV2
- L'Algorithmique
- Jwasham_google-Interview-university_ a Complete Daily Plan for Studying to Become a Google Software Engineer
- 1 Introduction
- ch5
- 1237.pdf
- c Data Structure
- Improved Frequent Pattern Mining Algorithm using Divide and Conquer Technique with Current Problem Solutions
- COMP2211-620055419
- [IJIT-V3I3P13]:Saptarshi Bhattacharyya
- Quick Sort
- Advanced Data Research Paper
- part1.1-3.pdf
- mail_for_ds
- KS1 Crazy Character Algorithms Activity Barefoot Computing
- Parallel Prefix Sum
- amortized analysis
- M1410304 log - 09062016
- Radiology Exam
- C2 Exponentials & Logarithms - Questions
- Eee230 Engineering Optimization Using Soft Computing Th 1.00 Ac21
- Ch4 Logs Ib Practice
- Topics Entry Test IBEB NonCD Version 2014
- M43 Picturing Probabilities - JaPipeDiagrams
- samplefinalqs
- 32Vol64No1
- Exponential Growth in the Fractal Universe
- algo (1)
- Math 140 Final Revision
- Addmaths Project
- I7-Finite Automata and Regular Languages
- Sorinting And Searching
- digital logic v2
- Automata and Regular Languages-90
- and-2
- Automata and Regular Languages
- maths overvier vs-2
- 6816988-1
- llr-2
- Regular Languages
- hutuujjjjjjjjjjjjjj
- P2ch5PART II Pushdown Automata and Context-Free Langugaes
- DSA Book
- C++ Assignment
- Tutorial 1
- Formal Language & Automata Theory
- Digital and Logic Design No 2 Kmap and Queen Maclaren Method From APCOMS
- C Basic Assignment
- 9930dft
- 8085 Microprocessor by Ramesh S Gaonkar
- Intro to Automata Theory
- 127 a 347 f Application

You are on page 1of 17

Version 1.1

1

TCSS 342

Data Structures &

Algorithms

Autumn 2004

Ed Hong

TCSS 342 Autumn 2004

Version 1.1

2

Course Objectives

• (Broad) Prepare you to be a

good software engineer

• (Specific) Learn basic data

structures and algorithms

– Data structures – how data is

organized

– Algorithms – unambiguous

sequence of steps to compute

something

TCSS 342 Autumn 2004

Version 1.1

3

Software Design Goals

TCSS 342 Autumn 2004

Version 1.1

4

Course Content

Data Structures

Algorithms

Data Structures + Algorithms =

Programs

Algorithm analysis – determining how

long an algorithm will take to solve a

problem

Who cares? Aren’t computers fast

enough and getting faster?

TCSS 342 Autumn 2004

Version 1.1

5

An Example

Given an array of 1,000,000 integers,

find the maximum integer in the array.

Now suppose we are asked to find the

kth largest element. (The Selection

Problem)

…

0 1 2 999,999

TCSS 342 Autumn 2004

Version 1.1

6

Candidate Solutions

+ Candidate solution 1

Sort the entire array (from small to

large), using Java’s Arrays.sort()

Pick out the (1,000,000 – k)th

element.

+ Candidate solution 2

Sort the first k elements.

For each of the remaining

(1,000,000 – k) elements,

keep the k largest in an array.

Pick out the smallest of the k

survivors.

TCSS 342 Autumn 2004

Version 1.1

7

Is either solution good?

• Is there a better solution?

• How would you go about

determining the answer to these

questions?

TCSS 342 Autumn 2004

Version 1.1

8

Method 1

Code each algorithm and run them to

see how long they take.

Problem: How will you know if there

is a better program or whether there

is no better program?

What will happen when the number of

inputs is twice as many? Three? A

hundred?

TCSS 342 Autumn 2004

Version 1.1

9

Method 2

Develop a model of the way computers

work and compare how the

algorithms behave in the model.

Goal: To be able to predict

performance at a coarse level. That

is, to be able to distinguish between

good and bad algorithms.

Another benefit: when assumptions

change, we can predict the effects of

those changes.

TCSS 342 Autumn 2004

Version 1.1

10

Why algorithm analysis?

As computers get faster and problem

sizes get bigger, analysis will

become more important.

Why? The difference between good

and bad algorithms will get bigger.

TCSS 342 Autumn 2004

Version 1.1

11

Why data structures?

When programming, you are an

engineer.

Engineers have a bag of tools and

tricks – and the knowledge of which

tool is the right one for a given

problem.

Arrays, lists, stacks, queues, trees, hash

tables, graphs.

TCSS 342 Autumn 2004

Version 1.1

12

Software Development

Practices

• Modular code

• Appropriate commenting of code

– Each method needs a comment

explaining its parameters and its

behavior.

• Debugging with integrated

development environment (IDE)

• Incremental development

• Unified modeling language (UML)

TCSS 342 Autumn 2004

Version 1.1

13

Mathematical Background

• Exponents

X

A

X

B

= X

A+B

X

A

/ X

B

= X

A-B

(X

A

)

B

= X

AB

X

N

+X

N

= 2X

N

2

N

+2

N

= 2

N+1

• Logarithms

Definition: X

A

= B if and only if

log

X

B = A.

TCSS 342 Autumn 2004

Version 1.1

14

Logarithms, continued

• log AB = log A + log B

• Proof:

1 , 0 , ,

log

log

log = > = A C B A

A

B

B

C

C

A

TCSS 342 Autumn 2004

Version 1.1

15

Logarithms, Series

• log A/B = log A – log B

• log (A

B

) = B log A

Series

•

• binary representation of

numbers

1 2 2

1

0

÷ =

+

=

¿

N

N

i

i

2

) 1 (

1

+

=

¿

=

N N

i

N

i

TCSS 342 Autumn 2004

Version 1.1

16

Series

• Geometric progression: for a>0,

a ≠1

) 1 /( ) 1 (

1

0

a a a

N

N

i

i

÷ ÷ =

+

=

¿

a

TCSS 342 Autumn 2004

Version 1.1

17

Boolean Logic

• Let P and Q be statements.

• “not P” is true if P is false.

• “P and Q” is true if both P and

Q are true.

• “P or Q” is true if one of or both

P or Q are true.

• “P implies Q” is true if P is

false or Q is true (or both).

P ÷

Q P.

Q Pv

Q P Q P v ÷ = ÷

- 107352_Lec06b_QuicksortV2Uploaded byvignesvaran
- L'AlgorithmiqueUploaded byA.Benhari
- Jwasham_google-Interview-university_ a Complete Daily Plan for Studying to Become a Google Software EngineerUploaded byHarssh S Shrivastava
- 1 IntroductionUploaded bySridhar Dv
- ch5Uploaded bytheresa.painter
- 1237.pdfUploaded bysrinjoy chakravorty
- c Data StructureUploaded bySuresh Kumar
- Improved Frequent Pattern Mining Algorithm using Divide and Conquer Technique with Current Problem SolutionsUploaded byInternational Journal for Scientific Research and Development - IJSRD
- COMP2211-620055419Uploaded byjoseph_thesaint
- [IJIT-V3I3P13]:Saptarshi BhattacharyyaUploaded byIJITJournals
- Quick SortUploaded byAdeel Durrani
- Advanced Data Research PaperUploaded bysaurabh20apr
- part1.1-3.pdfUploaded byJeetendra Kumar
- mail_for_dsUploaded byDeepak Gupta
- KS1 Crazy Character Algorithms Activity Barefoot ComputingUploaded byabishefford
- Parallel Prefix SumUploaded byRenato Quezada E
- amortized analysisUploaded byAndrew Martin
- M1410304 log - 09062016Uploaded byEng Seng Lim
- Radiology ExamUploaded bysara b
- C2 Exponentials & Logarithms - QuestionsUploaded byahamed
- Eee230 Engineering Optimization Using Soft Computing Th 1.00 Ac21Uploaded bySharvanMvs
- Ch4 Logs Ib PracticeUploaded byboostoberoi
- Topics Entry Test IBEB NonCD Version 2014Uploaded byYonYon
- M43 Picturing Probabilities - JaPipeDiagramsUploaded byNora
- samplefinalqsUploaded byJason Buck
- 32Vol64No1Uploaded byRan Run
- Exponential Growth in the Fractal UniverseUploaded byRJB
- algo (1)Uploaded byRohit Gawande
- Math 140 Final RevisionUploaded byطاهرالياسر
- Addmaths ProjectUploaded byAn-Nisa Azmi

- I7-Finite Automata and Regular LanguagesUploaded byMandeep Singh
- Sorinting And SearchingUploaded byMandeep Singh
- digital logic v2Uploaded byMandeep Singh
- Automata and Regular Languages-90Uploaded byMandeep Singh
- and-2Uploaded byMandeep Singh
- Automata and Regular LanguagesUploaded byMandeep Singh
- maths overvier vs-2Uploaded byMandeep Singh
- 6816988-1Uploaded byMandeep Singh
- llr-2Uploaded byMandeep Singh
- Regular LanguagesUploaded byMandeep Singh
- hutuujjjjjjjjjjjjjjUploaded byMandeep Singh
- P2ch5PART II Pushdown Automata and Context-Free LangugaesUploaded byMandeep Singh
- DSA BookUploaded byMandeep Singh
- C++ AssignmentUploaded byMandeep Singh
- Tutorial 1Uploaded byMandeep Singh
- Formal Language & Automata TheoryUploaded byMandeep Singh
- Digital and Logic Design No 2 Kmap and Queen Maclaren Method From APCOMSUploaded byMandeep Singh
- C Basic AssignmentUploaded byMandeep Singh
- 9930dftUploaded byMandeep Singh
- 8085 Microprocessor by Ramesh S GaonkarUploaded byMandeep Singh
- Intro to Automata TheoryUploaded byMandeep Singh
- 127 a 347 f ApplicationUploaded byMandeep Singh