300 likes | 585 Views
Come on down!. Take and fill out a survey Get a copy of lecture slides Please sit in the first 5 rows!. CSE 326: Data Structures Lecture #1 Introduction. Dan Suciu Winter Quarter 2003. Today’s Outline. Administrative Stuff Overview of 326 Survey Introduction to Complexity.
E N D
Come on down! • Take and fill out a survey • Get a copy of lecture slides • Please sit in the first 5 rows!
CSE 326: Data StructuresLecture #1Introduction Dan Suciu Winter Quarter 2003
Today’s Outline • Administrative Stuff • Overview of 326 • Survey • Introduction to Complexity
Course Information • Instructor: Dan Suciu <suciu@cs> Office hours: Mon. 2:30-3:30, 318 Sieg Hall • TA: Nilesh Dalvi <nilesh@cs> Office hours: TBA. • TA (1/2): Adam Fuchs (afuchs@cs) • Sections are held in: BLD 392, MEB 243. • Text: Data Structures & Algorithm Analysis in Java 2nd edition, by Mark Allen Weiss
Course Policies • Written homeworks • Due at the start of class on due date • Programming projects • Turned in electronically before 11pm on due date to Nilesh Dalvi • No late homeworks accepted • Work in teams only on explicit team projects • See website • Grading • Weekly assignments: 50% • Midterm: 20% • Final: 30%
Course Mechanics • 326 Web page: www/education/courses/326/03wi • 326 course directory: /cse/courses/cse326 • 326 mailing list: cse326@cs.washington.edu • subscribe using instructions on the homepage • Course labs are 232 and 329 Sieg Hall • lab has NT machines w/X servers to access UNIX • All programming projects graded on UNIX in java (preferred) or gcc • OK to develop using other tools (e.g. under Windows) but make sure you test under UNIX
What is this Course About? Clever ways to organize information in order to enable efficient computation • What do we mean by clever? • What do we mean by efficient?
Clever? Efficient? Insert Delete Find Merge Shortest Paths Union Lists, Stacks, Queues Heaps Binary Search Trees AVL Trees Hash Tables Graphs Disjoint Sets Data Structures Algorithms
Graphics Used Everywhere! Theory AI Applications Systems Mastery of this material separates you from: • Perhaps the most important course in your CS curriculum! • Guaranteed non-obsolescence!
Example 1 • Towers of Hanoi:http://www.cut-the-knot.com/recurrence/hanoi.shtml orhttp://www.mazeworks.com/hanoi/ • Question to class: how long will it run for n = 10 n = 20 n = 50 n = 100
Example 1 • How many moves do we need to solve it for some n ?T(1) = 1T(n) = T(n-1) + 1 + T(n-1) = 2 T(n-1) + 1It follows that T(n) = (2n – 1)T, where T=T(1) (why ?) • We know T(6) = 1 second • Running times are (approximate):n = 10 T(10) 24 seconds = 16 secondsn = 20 T(20) 214 seconds = over one hourn = 50 T(50) 244 seconds 1014seconds 3 million yearsn = 100 T(100) 294 seconds 1030 seconds (only 3 1017 seconds since Big Bang !)
Example 2 • n2 “pretty print” routine nearly dooms major expert system project at AT&T • 10 MB data = 10 days (100 MIPS) • programmer was brilliant, but he skipped 326…
Asymptotic Complexity Our notion of efficiency: How the running time of an algorithm scales with the size of its input • several ways to further refine: • worst case • average case • amortized over a series of runs
Asymptotic Complexity • This course is about asymptotic complexity • Deals with algorithms, and their analysis • It is not about better coding • Does not deal with coding details • I don’t need totake 326 because: • I can buy a faster laptop • I can write very good code
The Apocalyptic Laptop Seth Lloyd, SCIENCE, 31 Aug 2000 5.4 x 10 50 operations per second
What a Better Laptop Buys You Ultimate Laptop, 1 year 1 second Since Big Bang Today’s laptop (1000MIPS) 1 day Not much...
What Better Coding Buys You Ultimate Laptop, 1 year 1 second Since Big Bang Today’s laptop (1000MIPS) 1 day Ten times faster buys you… …nothing
Specific Goals of the Course • Become familiar with some of the fundamental data structures in computer science • Improve ability to solve problems abstractly • data structures are the building blocks • Improve ability to analyze your algorithms • prove correctness • gauge (and improve) time complexity • Become modestly skilled with the UNIX operating system (you’ll need this in upcoming courses)
One Preliminary Hurdle • Recall what you learned in CSE 321 … • proofs by mathematical induction • proofs by contradiction • formulas for calculating sums and products of series • recursion Know Sec 1.1 – 1.4 of text by heart!
A Second Hurdle • Unix Experience 1975 all over again! • Try to login, edit, create a Makefile, and compile your favorite “hello world” program right away • Programming Assignment 0 due next Monday • Bring your questions and frustrations to Section on Thursday!
A Third Hurdle: Java Public class Set_of_ints { Public void insert( int x ); Public void remove( int x ); … } Review the syntax Run your first program (assignment 0)
Handy Library • From Weiss:http://www.cs.fiu.edu/~weiss/dsaajava/code/ • most of CSE 326 in a box • don’t use (unless told); we’ll be rolling our own
Java Data Structures One of the all time great books in computer science: The Art of Computer Programming (1968-1973) by Donald Knuth Examples in assembly language (and English)! American Scientist says: in top 12 books of the CENTURY! Very little about Java in class.
Abstract Data Types • Abstract Data Type (ADT) • Mathematical description of an object and the set of operations on the object Data Types integer, array, pointers, … tradeoffs! • Algorithms • binary search, quicksort, …
ADT Presentation Algorithm • Present an ADT • Motivate with some applications • Repeat until it’s time to move on: • develop a data structure and algorithms for the ADT • analyze its properties • efficiency • correctness • limitations • ease of programming • Contrast strengths and weaknesses
First Example: Queue ADT • Queue operations • create • destroy • enqueue • dequeue • is_empty • Queue property: if x is enQed before y is enQed, then x will be deQed before y is deQed FIFO: First In First Out F E D C B dequeue enqueue G A
Applications of the Q • Hold jobs for a printer • Store packets on network routers • Make waitlists fair • Breadth first search
enqueue(Object x) { Q[back] = x ; back = (back + 1) % size } Circular Array Q Data Structure Q size - 1 0 b c d e f front back How test for empty list? How to find K-th element in the queue? What is complexity of these operations? Limitations of this structure? • dequeue() { • x = Q[front] ; • front = (front + 1) % size; • return x ; }
Linked List Q Data Structure b c d e f front back enqueue(Object x) { back.next = new Node(x); back = back.next; } dequeue() { saved = front.data; temp = front; front = front.next; return saved;} What are tradeoffs? • simplicity • speed • robustness • memory usage
To Do • Return your survey before leaving! • Sign up on the cse326 mailing list • Check out the web page • Log on to the PCs in course labs and access an instructional UNIX server • Read Chapters 1 and 2 in the book