Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Structures and Algorithms

Similar presentations


Presentation on theme: "Data Structures and Algorithms"— Presentation transcript:

1 Data Structures and Algorithms
What This Course Is About Data structures – how data is organized Algorithms – unambiguous sequence of steps to compute something 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? Oct 1, 2001 CSE 373

2 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) 1 2 999,999 Oct 1, 2001 CSE 373

3 Candidate Solutions + Candidate solution 1
Sort the entire array (from small to large), using insertion 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 smallest in an array. Pick out the smallest of the k survivors. Oct 1, 2001 CSE 373

4 Is either solution good?
Is there a better solution? How would you go about determining the answer to these questions? Oct 1, 2001 CSE 373

5 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? Oct 1, 2001 CSE 373

6 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. Oct 1, 2001 CSE 373

7 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. Oct 1, 2001 CSE 373

8 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. Oct 1, 2001 CSE 373


Download ppt "Data Structures and Algorithms"

Similar presentations


Ads by Google