CSE332: Data Abstractions Lecture 1: Introduction; Stacks/Queues Dan Grossman Spring 2010.

Slides:



Advertisements
Similar presentations
§3 The Stack ADT 1. ADT A stack is a Last-In-First-Out (LIFO) list, that is, an ordered list in which insertions and deletions are.
Advertisements

Intro to CIT 594
0 of 37 Stacks and Queues Lecture of 37 Abstract Data Types To use a method, need to know its essentials: signature and return type o additionally,
CS 206 Introduction to Computer Science II 03 / 04 / 2009 Instructor: Michael Eckmann.
 Abstract Data Type Abstract Data Type  What is the difference? What is the difference?  Stacks Stacks  Stack operations Stack operations  Parsing.
 Balancing Symbols 3. Applications
Come up and say hello! 1. CPSC 221: Algorithms and Data Structures Lecture #0: Introduction Steve Wolfman 2009W1 2.
CSE332: Data Abstractions Lecture 4: Priority Queues Dan Grossman Spring 2010.
CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis Dan Grossman Spring 2010.
CSE332: Data Abstractions Lecture 28: Course Wrap-Up / Victory Lap Dan Grossman Spring 2010.
Intro to CIT 594
June 13, Introduction to CS II Data Structures Hongwei Xi Comp. Sci. Dept. Boston University.
CMSC 132: Object-Oriented Programming II
CMSC 132: Object-Oriented Programming II Nelson Padua-Perez William Pugh Department of Computer Science University of Maryland, College Park.
CS 106 Introduction to Computer Science I 12 / 11 / 2006 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 10 / 26 / 2009 Instructor: Michael Eckmann.
Administrivia- Introduction CSE 373 Data Structures.
COMP171 Data Structures and Algorithm Qiang Yang Lecture 1 ( Fall 2006)
MATH 330: Ordinary Differential Equations Fall 2014.
CSE 326: Data Structures Lecture #0 Introduction Steve Wolfman Winter Quarter 2000.
July 16, Introduction to CS II Data Structures Hongwei Xi Comp. Sci. Dept. Boston University.
CSE 326: Data Structures Lecture #0 Introduction Bart Niswonger Summer Quarter 2001.
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Dan Grossman Fall 2013.
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Lauren Milne Summer 2015.
CSCE 3110 Data Structures and Algorithm Analysis.
Intro to CIT 594
Computer Science 102 Data Structures and Algorithms V Fall 2009 Lecture 1: administrative details Professor: Evan Korth New York University 1.
CSE 373 Data Structures and Algorithms Lecture 2: Queues.
COMP 151: Computer Programming II Spring Course Topics Review of Java and basics of software engineering (3 classes. Chapters 1 and 2) Recursion.
© 2004 Goodrich, Tamassia CS2210 Data Structures and Algorithms Lecture 1: Course Overview Instructor: Olga Veksler.
CSE332: Data Abstractions Lecture 1: Introduction; Stacks/Queues Tyler Robison Summer 2010.
CSE332: Data Abstractions Lecture 26: Course Victory Lap Dan Grossman Spring 2012.
CSCA48 Course Summary.
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Nicki Dell Spring 2014.
CSE 332 Data Abstractions: Introduction and ADTs Kate Deibel Summer 2012 June 18, 2012CSE 332 Data Abstractions, Summer
CSE332: Data Abstractions Lecture 1: Introduction; ADTs; Stacks/Queues Dan Grossman Spring 2012.
Introduction to Data Structures
Computer Science 102 Data Structures and Algorithms CSCI-UA.0102 Fall 2012 Lecture 1: administrative details Professor: Evan Korth New York University.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Introduction.
Come up and say hello! 1. CPSC 221: Algorithms and Data Structures Lecture #0: Introduction Steve Wolfman 2010W2 2.
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Kevin Quinn Fall 2015.
CSE373: Data Structures & Algorithms Lecture 6: Priority Queues Dan Grossman Fall 2013.
Welcome to Academic Strategies CS Janine Przybyl "When there is a start to be made, don't step over! Start where you are." ~Edgar Cayce.
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Catie Baker Spring 2015.
Final Exam Review CS Total Points – 60 Points Writing Programs – 50 Points Tracing Algorithms, determining results, and drawing pictures – 50.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Introduction.
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Linda Shapiro Winter 2015.
Intro to CIT 594
CSC 212 Sequences & Iterators. Announcements Midterm in one week  Will cover through chapter 5 of book  Midterm will be open book, open note (but, closed.
CSE 373: Data Structures and Algorithms Lecture 2: Queues.
April 27, 2017 COSC Data Structures I Review & Final Exam
Data Structures and Algorithms in Java AlaaEddin 2012.
Final Exam Review CS Total Points – 20 Points Writing Programs – 65 Points Tracing Algorithms, determining results, and drawing pictures – 50.
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Aaron Bauer Winter 2014.
WELCOME TO MICRO ECONOMICS AB 224 Discussion of Syllabus and Expectations in the Class.
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Linda Shapiro Spring 2016.
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Hunter Zahn Summer 2016 CSE373: Data Structures and Algorithms1.
CSE373: Data Structures and Algorithms
G64ADS Advanced Data Structures
March 27 – Course introductions; Adts; Stacks and Queues
CSE 373: Data Structures and Algorithms
Computer Science 102 Data Structures CSCI-UA
September 27 – Course introductions; Adts; Stacks and Queues
Introduction CSE 373 Data Structures.
Introduction to CS II Data Structures
Ben Lerner Summer Quarter 2007 Lecture 1
Stack A data structure in which elements are inserted and removed only at one end (called the top). Enforces Last-In-First-Out (LIFO) Uses of Stacks Evaluating.
Spring 2016 Richard Anderson Lecture 1
Administrivia- Introduction
Administrivia- Introduction
Presentation transcript:

CSE332: Data Abstractions Lecture 1: Introduction; Stacks/Queues Dan Grossman Spring 2010

Welcome! We have 10 weeks to learn fundamental data structures and algorithms for organizing and processing information –“Classic” data structures / algorithms and how to analyze rigorously their efficiency and when to use them –Queues, dictionaries, graphs, sorting, etc. –Parallelism and concurrency (new!) Today in class: Course mechanics What this course is about (“the new 326”) –And how it fits into the revised curriculum Start (finish?) stacks and queues (largely review) Spring 20102CSE332: Data Abstractions

Concise to-do list In the hours: Adjust class -list settings homework 0 (worth 0 points) to me Read all course policies Read/skim Chapters 1 and 3 of Weiss book –Relevant to Project 1, due next week –Will start Chapter 2 on Wednesday Possibly: Set up your Eclipse / Java environment for project 1 –Thursday’s section will help Spring 20103CSE332: Data Abstractions

Who Course Staff: Dan Grossman Tyler Robison Brent Sandona Spring 20104CSE332: Data Abstractions Dan: Faculty, “a 341 guy”, excited about 332 (& curriculum revision) Tyler: Grad student, Summer instructor, Winter TA Brent: Senior, CompE, veteran TA, including 326 Office hours, , etc. on course web-page

Staying in touch Course list: –Students and staff already subscribed –You must get announcements sent there –Fairly low traffic Course staff: plus individual s Message Board –For appropriate discussions; Brent will monitor –Optional, won’t use for important announcements Anonymous feedback link on webpage –For good and bad: if you don’t tell me, I don’t know Spring 20105CSE332: Data Abstractions

Course meetings Lecture (Dan) –Material posted (sometimes afterwards), but take notes –Ask questions, focus on key ideas (rarely coding details) Section (Tyler) –Often focus on software (Java features, tools, project issues) –Reinforce key issues from lecture (good practice) –Answer homework questions, etc. –Goal: More important than it was for your friends in 326 Office hours –Use them: please visit me –Ideally not just for homework questions (but that’s great too) Spring 20106CSE332: Data Abstractions

Course materials All lecture and section materials will be posted –But they are visual aids, not always a complete description! –If you have to miss, find out what you missed Textbook: Weiss 2 nd Edition in Java –Good reading, but only responsible for lecture/section/hw topics –Will assign homework problems from it Core Java book: A good Java reference (there may be others) –Don’t struggle Googling for features you don’t understand –Same book recommended for CSE331 Weeks 8-10 not in either book (or any appropriate one) –Will write and post more thorough lecture notes, etc. Spring 20107CSE332: Data Abstractions

Course Work 8 written/typed homeworks (25%) –Due at beginning of class each Friday (not this week) –No late homeworks accepted –Often covers through Monday before it’s due 3 programming projects (with phases) (25%) –First phase of first project due in 9 days –Use Java and Eclipse (see this week’s section) –One 24-hour late-day for the quarter –Projects 2 and 3 will allow partners Midterm Friday April 30 (20%) Final Tuesday June 8 (25%) Spring 20108CSE332: Data Abstractions

Collaboration and Academic Integrity Read the course policy very carefully –Explains quite clearly how you can and cannot get/provide help on homework and projects Always explain any unconventional action on your part Your instructor has promoted and enforced academic integrity since he was a freshman –Believes in great trust with little sympathy for violations –Honest work is the most important feature of a university Spring 20109CSE332: Data Abstractions

Unsolicited advice Get to class on time! –Instructor pet peeve (I will start and end promptly) –First 2 minutes are much more important than last 2! –April 30 will prove beyond any doubt you are capable Learn this stuff –You need it for so many later classes/jobs anyway –Falling behind only makes more work for you Embrace being a “charter member” of CSE332 –Things may be a little rough around the edges –But we make up for it with excitement and a nice class size Spring CSE332: Data Abstractions

Today in Class Course mechanics – Did I forget anything? What this course is about (“the new 326”) –And how it fits into the revised curriculum Start stacks and queues (largely review) Spring CSE332: Data Abstractions

Last word about 326 Many new courses have no one obvious counterpart in the old But 332 is about 70% of the material from 326 –First 7 weeks or so, obviously cutting out some topics and a little moving to 312 –Timeless, essential stuff –And a good chance to clean up some 326 “cruft” Biggest new topic: a serious treatment of programming with multiple threads –For parallelism: To use multiple processors to finish sooner –For concurrency: Allow properly synchronized access to shared resources Spring CSE332: Data Abstractions

Where 332 fits Note: This picture was the story of my life in 2009 Spring CSE332: Data Abstractions

Okay, so what is 332 about already! Introduction to many (not all) of the basic data structures used in computer software –Understand the data structures and the trade-offs they make –Rigorously analyze the algorithms that use them (math!) –Learn how to pick “the right thing for the job” –More thorough and rigorous take on topics introduced in 143 And more Practice design and analysis of data structures / algorithms Practice implementing and using these data structures by writing programs Experience the purposes and headaches of multithreading Spring CSE332: Data Abstractions

Goals To be able to make good design choices as a developer, project manager, etc. –Reason in terms of the general abstractions that come up in all non-trivial software (and many non-software) systems To be able to justify and communicate your design decisions Dan’s take: 3 years from now this course will seem like it was a waste of your time because you can’t imagine not “just knowing” every main concept in it –Key abstractions computer scientists and engineers use almost every day –A big piece of what separates us from others Spring CSE332: Data Abstractions

Data structures (Often highly non-obvious) ways to organize information in order to enable efficient computation over that information –Key goal over the next week is introducing asymptotic analysis to precisely and generally describe efficient use of time and space A data structure supports certain operations, each with a: –Meaning: what does the operation do/return –Performance: how efficient is the operation Examples: –List with operations insert and delete –Stack with operations push and pop Spring CSE332: Data Abstractions

Trade-offs A data structure strives to provide many useful, efficient operations But there are unavoidable trade-offs: –Time vs. space –One operation more efficient if another less efficient –Generality vs. simplicity vs. performance That is why there are many data structures and educated CSEers internalize their main trade-offs and techniques –And recognize logarithmic < linear < quadratic < exponential Spring CSE332: Data Abstractions

Terminology Abstract Data Type (ADT) –Mathematical description of a “thing” with set of operations on that “thing” Algorithm –A high level, language-independent description of a step-by- step process Data structure –A specific family of algorithms for implementing an ADT Implementation of a data structure –A specific implementation in a specific language Spring CSE332: Data Abstractions

Example: Stacks The Stack ADT supports operations: –isEmpty : initially true, later have there been same number of pops as pushes –push : takes an item –pop : raises an error if isEmpty, else returns most-recently pushed item not yet returned by a pop –… (Often some more operations) A Stack data structure could use a linked-list or an array or something else, and associated algorithms for the operations One implementation is in the library java.util.Stack Spring CSE332: Data Abstractions

Why useful The Stack ADT is a useful abstraction because: It arises all the time in programming (see text for more) –Recursive function calls –Balancing symbols (parentheses) –Evaluating postfix notation: * –Clever: Infix ((3+4) * 5) to postfix conversion (see text) We can code up a reusable library We can communicate in high-level terms –“Use a stack and push numbers, popping for operators…” –Rather than, “create a linked list and add a node when…” Spring CSE332: Data Abstractions

The Queue ADT Operations create destroy enqueue dequeue is_empty Just like a stack except: –Stack: LIFO (last-in-first-out) –Queue: FIFO (first-in-first-out) Just as useful and ubiquitous Spring CSE332: Data Abstractions F E D C B enqueue dequeue G A

Circular Array Queue Data Structure Spring CSE332: Data Abstractions // Basic idea only! enqueue(x) { Q[back] = x; back = (back + 1) % size } // Basic idea only! dequeue() { x = Q[front]; front = (front + 1) % size; return x; } bcdef Q: 0size - 1 front back What if queue is empty? –Enqueue? –Dequeue? What if array is full? How to test for empty? What is the complexity of the operations? Can you find the k th element in the queue?

Linked List Queue Data Structure Spring CSE332: Data Abstractions bcdef frontback // Basic idea only! enqueue(x) { back.next = new Node(x); back = back.next; } // Basic idea only! dequeue() { x = front.item; front = front.next; return x; } What if queue is empty? –Enqueue? –Dequeue? Can list be full? How to test for empty? What is the complexity of the operations? Can you find the k th element in the queue?

Circular Array vs. Linked List Array: –May waste unneeded space or run out of space –Space per element excellent –Operations very simple / fast –Constant-time access to k th element –For operation insertAtPosition, must shift all later elements –Not in Queue ADT Spring CSE332: Data Abstractions (This is something every trained computer scientist knows in his/her sleep – it’s like knowing how to do arithmetic.) List: –Always just enough space –But more space per element –Operations very simple / fast –No constant-time access to k th element –For operation insertAtPosition must traverse all earlier elements –Not in Queue ADT

The Stack ADT Operations create destroy push pop top is_empty Can also be implemented with an array or a linked list –This is Project 1! –Like queues, type of elements is irrelevant Ideal for Java’s generic types (section and Project 1B) Spring CSE332: Data Abstractions A BCDEFBCDEF E D C B A F