Ben Lerner Summer Quarter 2007 Lecture 1

Slides:



Advertisements
Similar presentations
1 Queues (5.2) CSE 2011 Winter May Announcements York Programming Contest Link also available from.
Advertisements

Come up and say hello! 1. CPSC 221: Algorithms and Data Structures Lecture #0: Introduction Steve Wolfman 2011W2 2.
Come up and say hello! 1. CPSC 221: Algorithms and Data Structures Lecture #0: Introduction Steve Wolfman 2009W1 2.
CSE 326: Data Structures Introduction 1Data Structures - Introduction.
Administrivia- Introduction CSE 373 Data Structures.
CSE 326: Data Structures Lecture #0 Introduction Steve Wolfman Winter Quarter 2000.
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 #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.
Data Structures and Programming.  John Edgar2.
Computer Science 102 Data Structures and Algorithms V Fall 2009 Lecture 1: administrative details Professor: Evan Korth New York University 1.
Data Structures and Programming.  Today:  Administrivia  Introduction to 225, Stacks  Course website: 
Come up and say hello! (Welcome!) 1. CPSC 221: Algorithms and Data Structures Lecture #0: Introduction Kendra Cooper 2014W1 2.
CSE332: Data Abstractions Lecture 1: Introduction; Stacks/Queues Tyler Robison Summer 2010.
CSCA48 Course Summary.
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Nicki Dell Spring 2014.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Review Midterm.
DATA STRUCTURES (CS212D) Week # 1: Overview & Review.
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 Catie Baker Spring 2015.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Introduction.
Data Structures and Algorithm Analysis Introduction Lecturer: Ligang Dong, egan Tel: , Office: SIEE Building.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Linda Shapiro Winter 2015.
CSE 373: Data Structures and Algorithms Lecture 2: Queues.
Review I. Final exam Date TBD. Don ’ t be late! Open book, open notes No calculators or any electronics Worth 50% of final grade.
Data Structures and Algorithms in Java AlaaEddin 2012.
DATA STRUCTURES (CS212D) Overview & Review Instructor Information 2  Instructor Information:  Dr. Radwa El Shawi  Room: 
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Aaron Bauer Winter 2014.
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Linda Shapiro Spring 2016.
Week 15 – Monday.  What did we talk about last time?  Tries.
Data Structures Intro2CS – week Stack ADT (Abstract Data Type) A container with 3 basic actions: – push(item) – pop() – is_empty() Semantics: –
Maitrayee Mukerji. INPUT MEMORY PROCESS OUTPUT DATA INFO.
Lecture 1 Data Structures Aamir Zia. Introduction Course outline Rules and regulations Course contents Good Programming Practices Data Types and Data.
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Hunter Zahn Summer 2016 CSE373: Data Structures and Algorithms1.
CSc 1302 Principles of Computer Science II
CSc 020: Programming Concepts and Methodology II
Intro Data Structure.
March 27 – Course introductions; Adts; Stacks and Queues
Chapter 15 Lists Objectives
GC211Data Structure Lecture2 Sara Alhajjam.
March 29 – Testing and Priority QUeues
CSE 373: Data Structures and Algorithms
Stacks and Queues.
Data Structures Interview / VIVA Questions and Answers
Cinda Heeren / Geoffrey Tien
Instructor: Lilian de Greef Quarter: Summer 2017
Week 15 – Monday CS221.
Computer Science 102 Data Structures CSCI-UA
September 27 – Course introductions; Adts; Stacks and Queues
Cse 373 April 26th – Exam Review.
Lecture 1: Welcome to CSE 373
CMSC 341 Lecture 5 Stacks, Queues
structures and their relationships." - Linus Torvalds
Data Structures (CS212D) Overview & Review.
structures and their relationships." - Linus Torvalds
Data Structures and Algorithms
Lecture 3: Queues, Testing, and Working with Code
Introduction to Data Structures
Introduction CSE 373 Data Structures.
Week # 1: Overview & Review
Spring 2016 Richard Anderson Lecture 1
Data Structures and Algorithms for Information Processing
Data Structures (CS212D) Overview & Review.
Administrivia- Introduction
Administrivia- Introduction
structures and their relationships." - Linus Torvalds
Presentation transcript:

Ben Lerner Summer Quarter 2007 Lecture 1 CSE 326: Data Structures Ben Lerner Summer Quarter 2007 Lecture 1

CSE 326 Crew Instructor: Ben Lerner, CSE 212 TAs: Office hours: TBD blerner@cs.washington.edu TAs: Ioannis Giotis (giotis@cs) Gyanit Singh (gyanit@cs) Office hours: TBD (Introduce everyone) “ give them a hand” 1/2/2019 CSE 326 - Introduction

Today’s Outline Introductions Administrative Info What is this course about? Review: Queues and stacks 1/2/2019 CSE 326 - Introduction

Course Information Text: Data Structures & Algorithm Analysis in Java, (Mark Allen Weiss), 1999 Web page: http://www.cs.washington.edu/326 (will be available soon) Mailing Lists: announcement list: cse326-announce@cs.washington.edu Subscribe to this using web interface, see homepage Discussion list: link on course home page (Coming soon!) Announce is required. 1/2/2019 CSE 326 - Introduction

Course Mechanics Written homeworks (8 total) Due at the start of class on due date No late homeworks accepted Programming homeworks (3 total, with phases) In Java Turned in electronically and on paper Can have one “late day” for extra 24 hours – Must email TA in advance Work in teams only on explicit team projects Appropriate discussions encouraged – see website Gilligan’s Island rule applies 1/2/2019 CSE 326 - Introduction

Course Mechanics Approximate Grading 25% - Written Homework Assignments 25% - Programming Assignments 20% - Midterm Exam (in class, fifth week) 30% - Final Exam (last day of class) 1/2/2019 CSE 326 - Introduction

Project/Homework Guides On the website - note especially Homeworks: use pseudocode, not code. A human being is reading your homeworks See website for pseudocode examples Projects: execution is only 40% of your grade! Spend time commenting your code as you write - it will help you be a better programmer 1/2/2019 CSE 326 - Introduction

Homework for Today!! Sign up for mailing list (immediately) Project #1: Implement stacks and queues (due in 1 week) Reading in Weiss Chapter 1 – (review) Mathematics and Java Chapter 3 – (Project #1) Lists, Stacks, & Queues Chapter 2 – (Topic for Friday) Algorithm Analysis Homework #1: based off reading, handed out next class See course web page for more on both of these 1/2/2019 CSE 326 - Introduction

Project 1 Soundblaster! Reverse a song Implement a stack and a queue to make the “Reverse” program work Read the website Detailed description of assignment Detailed description of how programming projects are graded 1/2/2019 CSE 326 - Introduction

Today’s Outline Introductions Administrative Info What is this course about? Review: Queues and stacks 1/2/2019 CSE 326 - Introduction

Class Overview Introduction to many of the basic data structures used in computer software Understand the data structures Analyze the algorithms that use them Know when to apply them Practice design and analysis of data structures. Practice using these data structures by writing programs. Make the transformation from programmer to computer scientist 1/2/2019 CSE 326 - Introduction

Goal You will understand So that you can You will be able to what the tools are for storing and processing common data types which tools are appropriate for which need So that you can make good design choices as a developer, project manager, or system customer You will be able to Justify your design decisions via formal reasoning Communicate ideas about programs clearly and precisely 1/2/2019 CSE 326 - Introduction

Data Structures “Clever” ways to organize information in order to enable efficient computation What do we mean by clever? What do we mean by efficient? clever – range from techniques with which you are already familiar – eg, representing simple lists – to ones that are more complex, such as hash tables or self-balancing trees. Elegant, mathematically deep, non obvious. making the different meanings of “efficient” precise is much of the work of this course! 1/2/2019 CSE 326 - Introduction

Picking the best Data Structure for the job The data structure you pick needs to support the operations you need Ideally it supports the operations you will use most often in an efficient manner Examples of operations: A List with operations insert and delete A Stack with operations push and pop 1/2/2019 CSE 326 - Introduction

Terminology Abstract Data Type (ADT) Algorithm Data structure Mathematical description of an object with set of operations on the object. Useful building block. Algorithm A high level, language independent, description of a step-by-step process Data structure A specific family of algorithms for implementing an abstract data type. Implementation of data structure A specific implementation in a specific language 1/2/2019 CSE 326 - Introduction

Terminology examples A stack is an abstract data type supporting push, pop and isEmpty operations A stack data structure could use an array, a linked list, or anything that can hold data One stack implementation is java.util.Stack; another is java.util.LinkedList 1/2/2019 CSE 326 - Introduction

Concepts vs. Mechanisms Abstract Pseudocode Algorithm A sequence of high-level, language independent operations, which may act upon an abstracted view of data. Abstract Data Type (ADT) A mathematical description of an object and the set of operations on the object. Concrete Specific programming language Program A sequence of operations in a specific programming language, which may act upon real data in the form of numbers, images, sound, etc. Data structure A specific way in which a program’s data is represented, which reflects the programmer’s design choices/goals. Note how much messier life becomes when we move from abstract concepts to concrete mechanisms. Being able to abstract the intrinsic problems from the real world scenarios -- or, alternatively, being able to realize an abstract concept in code -- is one of the important skills that computer scientists need to possess. Note that pseudocode is a concept, and a programming language is a mechanism. 1/2/2019 CSE 326 - Introduction

Why So Many Data Structures? Ideal data structure: “fast”, “elegant”, memory efficient Generates tensions: time vs. space performance vs. elegance generality vs. simplicity one operation’s performance vs. another’s What does it mean to be “fast”? What about “elegant”? The study of data structures is the study of tradeoffs. That’s why we have so many of them! 1/2/2019 CSE 326 - Introduction

Today’s Outline Introductions Administrative Info What is this course about? Review: Queues and stacks 1/2/2019 CSE 326 - Introduction

First Example: Queue ADT FIFO: First In First Out Queue operations create destroy enqueue dequeue is_empty F E D C B enqueue dequeue G A Here comes our first instance of this algorithm… You’ve probably seen the Q before. If so, this is an opportunity to get familiar with how we will be presenting algorithms in this class. If not, then the Q is a simple but very powerful abstraction, and you should make sure you understand it thoroughly. Note the lack of any implementation details – just the interface and key properties that must be satisfied. 1/2/2019 CSE 326 - Introduction

Circular Array Queue Data Structure size - 1 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? enqueue(Object x) { Q[back] = x ; back = (back + 1) % size } Here is a data structure implementation of the Q. The queue is stored as an array, and, to avoid shifting all the elements each time an element is dequeued, we imagine that the array wraps around on itself. There’s also another problem here. What’s wrong with the Enqueue and Dequeue functions? Your data structures should be robust! Make them robust before you even consider thinking about making them efficient! That is an order! dequeue() { x = Q[front] ; front = (front + 1) % size; return x ; } 1/2/2019 CSE 326 - Introduction

Linked List Queue Data Structure b c d e f front back void enqueue(Object x) { if (is_empty()) front = back = new Node(x) else back->next = new Node(x) back = back->next } bool is_empty() { return front == null Object dequeue() { assert(!is_empty) return_data = front->data temp = front front = front->next delete temp return return_data } 1/2/2019 CSE 326 - Introduction

Circular Array vs. Linked List Too much space Kth element accessed “easily” Not as complex Could make array more robust Can grow as needed Can keep growing No back looping around to front Linked list code more complex LinkedList takes more memory, but no size limitations. LinkedList code a little more complex. May want dummy header node. 1/2/2019 CSE 326 - Introduction

Second Example: Stack ADT LIFO: Last In First Out Stack operations create destroy push pop top is_empty A B C D E F E D C B A F 1/2/2019 CSE 326 - Introduction

Stacks in Practice Function call stack Removing recursion Balancing symbols (parentheses) Evaluating Reverse Polish Notation 1/2/2019 CSE 326 - Introduction

Algorithm Analysis: Why? Correctness: Does the algorithm do what is intended. How well does the algorithm complete its goal Performance: What is the running time of the algorithm. How much storage does it consume. Different algorithms may correctly solve a given task Which should I use? 1/2/2019 CSE 326 - Introduction

Iterative algorithm for sum Find the sum of the first n integers stored in an array v. sum(integer array v, integer n) returns integer let sum = 0 for i = 1...n sum = sum + ith number return sum Note the use of pseudocode 1/2/2019 CSE 326 - Introduction

Recursive algorithm for sum Write a recursive function to find the sum of the first n integers stored in array v. sum(integer array v, integer n) returns integer if n = 0 then sum = 0 else sum = nth number + sum of first n-1 numbers return sum 1/2/2019 CSE 326 - Introduction

Proof by Induction Basis Step: The algorithm is correct for a base case or two by inspection. Inductive Hypothesis (n=k): Assume that the algorithm works correctly for the first k cases. Inductive Step (n=k+1): Given the hypothesis above, show that the k+1 case will be calculated correctly. 1/2/2019 CSE 326 - Introduction

Program Correctness by Induction Basis Step: sum(v,0) = 0.  Inductive Hypothesis (n=k): Assume sum(v,k) correctly returns sum of first k elements of v, i.e. v[0]+v[1]+…+v[k-1] Inductive Step (n=k+1): sum(v,n) returns v[k]+sum(v,k)= (by inductive hyp.) v[k]+(v[0]+v[1]+…+v[k-1])= v[0]+v[1]+…+v[k-1]+v[k]  1/2/2019 CSE 326 - Introduction

Algorithms vs Programs Proving correctness of an algorithm is very important a well designed algorithm is guaranteed to work correctly and its performance can be estimated Proving correctness of a program (an implementation) is fraught with weird bugs Abstract Data Types are a way to bridge the gap between mathematical algorithms and programs 1/2/2019 CSE 326 - Introduction