This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Welcome to CS 136 (Winter 2011) Instructors: Terry Anderson, Byron Weber Becker, John Whissell Tutors: Zachary Frenette, Alex Lake, Andrew Naismith, Sunny Wu, Huma Zafar Instructional Assistants (IAs): John Doucette, David Loker, Caelyn McAulay, Alejandro Salinger Web page (main information source): http://www.student.cs.uwaterloo.ca/˜cs136/ Lectures: 5 sections, each Tuesday and Thursday Tutorials: 9 sections on Mondays CS 136 Winter 2011 01: Introduction to CS 136 1 Textbooks: “How to Design Programs” (HtDP) by Felleisen, Flatt, Findler, Krishnamurthi ( http://www.htdp.org ) and “C Programming: A Modern Approach” (CP:AMA) by K. N. King. Presentation handouts: available on Web page Marking Scheme: 25% assignments (weekly), 30% midterm, 45% final exam + bonus ⇒ Your assignment average and weighted exam average must both be greater than 50% Software: RunC will be used for Racket/Scheme and C CS 136 Winter 2011 01: Introduction to CS 136 2 Where to begin? Time and Space Complexity An Idea Type (ADT) Abstract Data (Racket, C, ...) Code Specification Implementation Analysis CS 136 Winter 2011 01: Introduction to CS 136 3 An Idea 18 4 22 add remove A collection of items such that: • We can add an item to the collection • We keep track of the order in which items were added • The item that was added most recently is the only one that can be seen or removed • We can see if there is at least one item in the collection CS 136 Winter 2011 01: Introduction to CS 136 4 Abstract Data Types (ADTs) This idea can be precisely described as an Abstract Data Type (ADT) An ADT specifies two things: • The type of data that is stored • A set of operations that can be performed on the data This specification does not depend on any specific programming language CS 136 Winter 2011 01: Introduction to CS 136 5 ADT Stack Our idea is called a Stack The type of data is described as a sequence of items [ a 1 ,a 2 ,...,a n ] such that n ≥ CS 136 Winter 2011 01: Introduction to CS 136 6 We will allow the following five operations: • Make an empty stack ( makestack ) • Add an item to the top of a stack ( push ) • Remove an item from the top of a stack ( pop ) • Look at the item at the top of a stack ( peek ) • Check if the stack is empty ( stackempty? ) However, these descriptions are not precise CS 136 Winter 2011 01: Introduction to CS 136 7 Specification of Operations For each ADT operation, we must specify: • The parameters (if any) • Preconditions: What must be true before performing this operation? • Postconditions: Assuming the preconditions have been satisfied, what will be true after the operation has been performed? What will happen if the preconditions of an operation are not satisfied?...
View
Full Document
 Spring '08
 BECKER
 Big O notation, Analysis of algorithms, len, ADT stack

Click to edit the document details