CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues. Lauren Milne Summer 2015

Similar documents
CSE 332: Data Abstractions. Ruth Anderson Spring 2014 Lecture 1

COURSE MECHANICS. Welcome! CSE 332 Data Abstractions: Introduction and ADTs. Concise to-do list. Today in Class. Instructor: Kate Deibel

CSE 332: Data Structures. Spring 2016 Richard Anderson Lecture 1

CSE373: Data Structures and Algorithms Lecture 1: Introduc<on; ADTs; Stacks/Queues

Adam Blank Lecture 1 Winter 2017 CSE 332. Data Abstractions

CSE 326 Team. Today s Outline. Course Information. Instructor: Steve Seitz. Winter Lecture 1. Introductions. Web page:

CSE 373 Data Structures and Algorithms. Lecture 2: Queues

CPSC 221: Algorithms and Data Structures ADTs, Stacks, and Queues

CPSC 221: Algorithms and Data Structures Lecture #1: Stacks and Queues

PA3 Design Specification

1 P age DS & OOPS / UNIT II

CS 206 Introduction to Computer Science II

3137 Data Structures and Algorithms in C++

EC8393FUNDAMENTALS OF DATA STRUCTURES IN C Unit 3

CPSC 221: Algorithms and Data Structures Lecture #0: Introduction. Come up and say hello! Fibonacci. Fibonacci. Fibonacci. Fibonacci. (Welcome!

CS W3134: Data Structures in Java

CS 206 Introduction to Computer Science II

CSC148H Week 3. Sadia Sharmin. May 24, /20

CSE 373: Introduction, ADTs, Design Decisions, Generics. Michael Lee Wednesday Jan 3, 2017

CS2013 Course Syllabus Spring 2018 Lecture: Mon/Wed 2:00 P.M. 2:50 P.M. SH C259 Lab: Mon/Wed 2:50 P.M. 4:00 P.M. SH C259

STACKS AND QUEUES. Problem Solving with Computers-II

Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis

Total No. of Questions :09] [Total No. of Pages : 02. II/IV B.Tech. DEGREE EXAMINATIONS, NOV/DEC First Semester CSE/IT DATA STRUCTURES USING C

12 Abstract Data Types

Lecture 6. COMP1006/1406 (the OOP course) Summer M. Jason Hinek Carleton University

Cpt S 122 Data Structures. Course Review Midterm Exam # 1


csci 210: Data Structures Stacks and Queues

Data Structures and Algorithms

CSCA48 Summer 2018 Week 3: Priority Queue, Linked Lists. Marzieh Ahmadzadeh University of Toronto Scarborough

BOSTON UNIVERSITY Metropolitan College MET CS342 Data Structures with Java Dr. V.Shtern (Fall 2011) Course Syllabus

Linked Structures. See Section 3.2 of the text.

Data Structures and Algorithms

CSC148 Week 2. Larry Zhang

STACKS. A stack is defined in terms of its behavior. The common operations associated with a stack are as follows:

LIFO : Last In First Out

DATA STRUCTURE UNIT I

Lecture 4 Stack and Queue

Postfix (and prefix) notation

ADVANCED DATA STRUCTURES USING C++ ( MT-CSE-110 )

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

Day 6. COMP1006/1406 Summer M. Jason Hinek Carleton University

CSE 373: Data Structures and Algorithms

University of Waterloo Department of Electrical and Computer Engineering ECE250 Algorithms and Data Structures Fall 2014

Home Works and Assignments

Programming and Data Structures Prof. N.S. Narayanaswamy Department of Computer Science and Engineering Indian Institute of Technology, Madras

cs Java: lecture #6

CSE373: Data Structures & Algorithms Lecture 28: Final review and class wrap-up. Nicki Dell Spring 2014

CS301 - Data Structures Glossary By

Lecture 3: Stacks & Queues

EEE2020 Data Structures and Algorithms Abstract Data Types: Stacks and Queues

CSE 373: Data Structures and Algorithms

Algorithm Class. C C++ DS JAVA DATA STRUCTURES TRAINING INSTITUTE KPHB HYDERABAD. Mobile:

DATA STRUCTURES THROUGH C++

SCHOOL OF COMPUTER AND COMMUNICATION ENGINEERING. EKT224: ALGORITHM AND DATA STRUCTURES (Stack, Queue, Linked list)

8. Fundamental Data Structures

The Stack and Queue Types

DATA STRUCUTRES. A data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.

! Mon, May 5, 2:00PM to 4:30PM. ! Closed book, closed notes, clean desk. ! Comprehensive (covers entire course) ! 30% of your final grade

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

ECE250: Algorithms and Data Structures Midterm Review

CSE 373 SEPTEMBER 29 STACKS AND QUEUES

DHANALAKSHMI COLLEGE OF ENGINEERING Tambaram, Chennai

Motivation for Queues

Matriculation number:

Lecture Data Structure Stack

Course Review. Cpt S 223 Fall 2009

CS 225. Nov. 13 Introduction to Graphs. Data Structures. Wade Fagen-Ulmschneider

Stacks. stacks of dishes or trays in a cafeteria. Last In First Out discipline (LIFO)

CSCI 136 Data Structures & Advanced Programming. Spring 2018 Instructors Bill Jannen & Jon Park

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid

March 13/2003 Jayakanth Srinivasan,

Abstract Data Types 1

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid. Fall 2018

CSE 373: Data Structures and Algorithms

Stacks. Revised based on textbook author s notes.

Stacks and Queues. CSE Data Structures April 12, 2002

Information Science 2

DATA STRUCTURES AND ALGORITHMS

COMP 250 Midterm #2 March 11 th 2013

Linked List. April 2, 2007 Programming and Data Structure 1

Lists, Stacks, and Queues. (Lists, Stacks, and Queues ) Data Structures and Programming Spring / 50

CMSC 341. Linked Lists, Stacks and Queues. CMSC 341 Lists, Stacks &Queues 1

Stacks, Queues (cont d)

Abstract Data Types. Stack. January 26, 2018 Cinda Heeren / Geoffrey Tien 1

15. Stacks and Queues

CSC2100-Data Structures

Course Review for. Cpt S 223 Fall Cpt S 223. School of EECS, WSU

CSE 230 Intermediate Programming in C and C++

CS24 Week 4 Lecture 2

CISC 3130 Data Structures Spring 2018

Stacks Fall 2018 Margaret Reid-Miller

Algorithm Design and Analysis

Keeping Order:! Stacks, Queues, & Deques. Travis W. Peters Dartmouth College - CS 10

Stacks. Chapter 5. Copyright 2012 by Pearson Education, Inc. All rights reserved

Abstract Data Types. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

Stacks and Queues. CSE 373 Data Structures Lecture 6

BBM 201 DATA STRUCTURES

CS1 Lecture 13 Feb. 13, 2019

COSC160: Data Structures: Lists and Queues. Jeremy Bolton, PhD Assistant Teaching Professor

Transcription:

CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Lauren Milne Summer 2015

Welcome! We will learn fundamental data structures and algorithms for organizing and processing information Classic data structures / algorithms Analyze efficiency When to use them Today in class: Introductions and course mechanics What this course is about Start abstract data types (ADTs), stacks, and queues 2

Course staff Lauren Milne 3rd Year CSE Ph.D. Grad Student Works with Richard Ladner in Accessibility Does triathlons and skijoring in free time milnel2@cs.washington.edu cse373-staff@cs.washington.edu 3

Course staff Jiechen Chen 2 nd Year CSE Ph.D. Grad Student Works in Theory. She moved 7 times Before graduating from college! cse373-staff@cs.washington.edu 4

Course staff Yanling He 5 th Year CSE Masters Student, Who loves climbing and caving. cse373-staff@cs.washington.edu 5

Course staff Naozumi Hiranuma cse373-staff@cs.washington.edu 6

Course staff Mert Saglam 2 nd Year CSE Ph.D. Grad Student Works in Complexity Theory cse373-staff@cs.washington.edu 7

Course staff Mauricio Hernandez Junior majoring in Electrical Engineering With a concentration in Embedded Systems Originally from Tabasco, Mexico! cse373-staff@cs.washington.edu 8

Course Information http://courses.cs.washington.edu/courses/cse373/15su/ Textbook: Weiss 3 rd Edition in Java Course email list: cse373a_15sp@u.washington.edu College of Arts & Sciences Instructional Computing Lab http://depts.washington.edu/aslab/ Or your own machine Will use Java for the programming assignments Eclipse is recommended programming environment 9

Office Hours M 1:30-2:30 (Lauren) Tu 12-1 pm (Jiechen) W 12-1 pm (Nao) W 4-5 pm (Mert) Th 9:30-10:30 am (Yanling) F 12-1 pm (Mauricio) Do these work for everyone? 10

Collaboration and Academic Integrity DON T CHEAT! Seriously, read the policy online, follow Gilligan s Island rule. 11

What this course will cover Introduction to Algorithm Analysis Lists, Stacks, Queues Trees, Hashing, Dictionaries Heaps, Priority Queues Sorting Disjoint Sets Graph Algorithms Introduction to Parallelism and Concurrency 12

Goals Be able to make good design choices as a developer Be able to justify and communicate your design decisions This is not a course about Java! 13

To-do list In next 24-48 hours: Read the web page Read all course policies Read Chapters 3.1 (lists), 3.6 (stacks) and 3.7 (queues) of the Weiss book Relevant to Homework 1, due next week! Set up your Java environment for Homework 1 http://courses.cs.washington.edu/courses/cse373/15su/ 14

Data structures A data structure is a way to organize information to enable efficient computation over that information What are some examples? push pop enqueue dequeue 15

Data structures A data structure is a way to organize information to enable efficient computation over that information push pop It supports certain operations, each with a: Meaning Performance 16

Trade-offs A data structure strives to provide many useful, efficient operations. But there are unavoidable trade-offs: Time vs space One operation s efficiency vs another Generality vs simplicity vs performance So, when should I use different data structures? 17

Terminology Abstract Data Type (ADT) Mathematical description of a thing with set of operations Not concerned with implementation details Data structure A specific organization of data and family of algorithms for implementing an ADT Algorithm A high level, language-independent description of a step-bystep process Implementation of a data structure A specific implementation in a specific language 18

Example: Stacks The Stack ADT supports operations: isempty push pop What else? push pop A Stack data structure could use a linked-list or an array and associated algorithms for the operations One implementation is in the library java.util.stack 19

Why Useful Stack ADT arises all the time in programming Recursive function calls Balancing symbols in programming (parenthesis) Evaluating postfix notation: 3 4 + 5 * Conversion from infix ((3+4)*5) to postfix notation We can code up a reusable library We can communicate in high-level terms 20

Stack Implementations 1. Initially empty 2. Push( a ) 3. Push( b ) 4. Pop() stack as an array stack as a linked list 21

The Queue ADT Operations enqueue dequeue is_empty What else? Back Front Just like a stack except: Stack: LIFO (last-in-first-out) Queue: FIFO (first-in-first-out) enqueue dequeue 22

Circular Array Queue Data Structure Q: 0 size - 1 b c d e f front back // Basic idea only! enqueue(x) { next = (back + 1) % size Q[next] = x; back = next } // Basic idea only! dequeue() { x = Q[front]; front = (front + 1) % size; return x; } What if queue is empty? 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? Why do we use a circular array for a queue vs a standard array for a stack? 23

back In Class Practice front // Basic idea only! enqueue(x) { next = (back + 1) % size Q[next] = x; back = next } // Basic idea only! dequeue() { x = Q[front]; front = (front + 1) % size; return x; } enqueue( A ) enqueue( B ) enqueue( C ) o = dequeue() o = dequeue() enqueue( D ) enqueue( E ) enqueue( F ) enqueue( G ) enqueue( H ) enqueue( I ) 24

b f f b enqueue( A ) A f b enqueue( B ) A f B b enqueue( C ) A B C f b o = dequeue() B C 25

f b o = dequeue C f b enqueue( D ) C f D b enqueue( E ) f C D E b enqueue( F ) b C D E F f enqueue( G ), enqueue( H ) G H C D E F enqueue( i ) 26

Linked List Queue Data Structure b c d e f front // 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; } back 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? 27

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 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 28

Conclusion Abstract data structures allow us to define a new data type and its operations. Each abstraction will have one or more implementations. Which implementation to use depends on the application, the expected operations, the memory and time requirements. Both stacks and queues have array and linked implementations. We ll look at other ordered-queue implementations later. 29