Download presentation
Presentation is loading. Please wait.
1
DATA STRUCTURES INTRODUCTION CSC 172 SPRING 2002
2
What this course is about Abstraction – Specifically, abstraction in computer programming through the use of abstract data types (ADTs) – Abstraction is powerful Complexity of detail is encapulated and hidden Allowing operations at a higher level – Your ability to abstract directly effects your productivity (as a lot of things) Analysis – What makes a good abstraction?
3
Which Abstractions? Lists Stacks Queues Trees Sets Graphs
4
What analysis? “Anyone” can write a computer program. What is the difference between a good solution and a not-so-good solution? – Running time – Memory requirements Mathematical tools – Proof by induction – Combinatorics – Probability – Asymptotic analysis (Big-Oh)
5
Instructor Prof. Ted Pawlicki, pawlicki@cs.rochester.edu pawlicki@cs.rochester.edu CSB 722, ext. 54198 Office Hours: TR 4:00-4:30 PM Lecture: T,R 2:00PM-3:15PM AM Dewey 101
6
Grad TAs (Mostly Projects) April Slayden slayden@cs.rochester.edu x58479 CSB 626slayden@cs.rochester.edu Rahul Tripathi rahult@cs.rochester.edu x51348 CSB 626rahult@cs.rochester.edu
7
Labs: Taylor 31 Labs: Taylor 31 MW 4:50-6:05 MW 6:15-7:30 MW 2:00-3:15 TR 9:40-10:55 TR 11:05-12:20 TR 3:25-4:40
8
EXAMS 3/8 2PM-5PM 5/10 4PM-7PM
9
Workshops Optional 10% Extra credit group project – Solitare Positive effect on grades – Independent of extra credit Group skills are valued by employers – Industrial & academic
10
Texts Foundations of Computer Science Aho & Ullman Lectures & Homeworks C & Math Data Structures with JAVA Ken & Barnett Labs Modern Java techniques
11
Is this a hard course? Yes One course has to be the hardest All majors have hard courses “No pain, no gain” Start early
12
Q&A Do you understand what is expected of you?
13
Example One dimensional pattern recognition Input: a vector x of n floating point numbers Output: the maximum sum found in any contiguous subvector of the input. X[2..6] or 187 How would you solve this? 31-415926-535897-93-2384
14
Obvious solution Check all pairs int sum; int maxsofar = 0; for (int i = 0; i<x.length;i++) for (int j = i; j<x.length;j++){ sum = 0; for (int k = i;k<=j;k++) sum += x[k]; maxsofar = max(sum,maxsofar); }
15
How long does the obvious solution take? We could “measure” it – benchmarking – What is a “good size” of input to measure?
16
How long does the obvious solution take? We could “analyse” it – Multiply the “cost” (time required) to do something by the number of times you have to do it. – If n is the length of the array – Outer loop runs exactly n times – Inner loop runs at most n times – Inner most loop runs no more than n times – Let’s say the “+=“ and “max” take unit time
17
How long does the obvious solution take? Innermost cost = n * 1 Innerloop cost = n * (Innermost cost) +1 Outerloop cost = n * (Innerloop cost) Outerloop cost = n * ( n * (Innermost cost) +1) Outerloop cost = n * (n *(n + 1) +1) Outerloop cost = n * (n 2 + n + 1) Outerloop cost = n 3 + n 2 +n
18
How long does the obvious solution take? We call this an “n 3 ” solution Can you think of a better (faster) way? Can you do an analysis that will prove it better? That is what we do in CSC 172 – For some very common tasks
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.