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

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

ADVANCED DATA STRUCTURES AND ALGORITHM ANALYSIS Chapter 3 Lists, Stacks, and Queues.
Stacks and Queues CSC220 Data Structure Winter
 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 2011W2 2.
Review. What to know You are responsible for all material covered in lecture, the readings, or the programming assignments There will also be some questions.
Come up and say hello! 1. CPSC 221: Algorithms and Data Structures Lecture #0: Introduction Steve Wolfman 2009W1 2.
CSE332: Data Abstractions Lecture 1: Introduction; Stacks/Queues Dan Grossman Spring 2010.
Administrivia- Introduction CSE 373 Data Structures.
COMP171 Data Structures and Algorithm Qiang Yang Lecture 1 ( Fall 2006)
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.
Data Structures and Programming.  John Edgar2.
Data Structures Lecture-1:Introduction
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.
Teaching Teaching Discrete Mathematics and Algorithms & Data Structures Online G.MirkowskaPJIIT.
DS.L.1 Lists, Stacks, and Queues (Review) Chapter 3 Overview Abstract Data Types Linked Lists, Headers, Circular Links Cursor (Array) Implementation Stacks.
Data Structures and Programming.  Today:  Administrivia  Introduction to 225, Stacks  Course website: 
CHAPTER 05 Compiled by: Dr. Mohammad Omar Alhawarat Stacks & Queues.
ISOM MIS 215 Module 3 – Stacks and Queues. ISOM Where are we? 2 Intro to Java, Course Java lang. basics Arrays Introduction NewbieProgrammersDevelopersProfessionalsDesigners.
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.
CSE 332 Data Abstractions: Introduction and ADTs Kate Deibel Summer 2012 June 18, 2012CSE 332 Data Abstractions, Summer
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Review Midterm.
CSE332: Data Abstractions Lecture 1: Introduction; ADTs; Stacks/Queues Dan Grossman Spring 2012.
Data Structures (Second Part) Lecture 1 Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University.
1/ 124 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 18 Programming Fundamentals using Java 1.
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.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 18 Stacks and Queues.
Data Structures and Algorithms – using JAVA Boro Jakimovski University of Sts Cyril and Methodius, Skopje.
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 and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Catie Baker Spring 2015.
Foundation of Computing Systems Lecture 3 Stacks and Queues.
Stacks And Queues Chapter 18.
ICS202 Data Structures King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science Department.
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.
CSE 373: Data Structures and Algorithms Lecture 2: Queues.
Data Structures and Algorithms in Java AlaaEddin 2012.
3/3/20161 Stacks and Queues Introduction to Data Structures Ananda Gunawardena.
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.
1 Lecture 15: Big O Notation (Wednesday) Lecturer: Santokh Singh CompSci 105 SS 2005 Principles of Computer Science Test See Web for Details Don’t be deleted!
COMP9024: Data Structures and Algorithms Course Outline Hui Wu Session 1, 2016
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Hunter Zahn Summer 2016 CSE373: Data Structures and Algorithms1.
CSE373: Data Structures & Algorithms Priority Queues
COMP9024: Data Structures and Algorithms
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
Cse 373 April 26th – Exam Review.
structures and their relationships." - Linus Torvalds
Introduction CSE 373 Data Structures.
Ben Lerner Summer Quarter 2007 Lecture 1
Spring 2016 Richard Anderson Lecture 1
Stacks and Queues 1.
Administrivia- Introduction
Administrivia- Introduction
structures and their relationships." - Linus Torvalds
Presentation transcript:

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 3 Lauren Milne 3 rd Year CSE Ph.D. Grad Student Works with Richard Ladner in Accessibility Does triathlons and skijoring in free time

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

Course staff 5 Yanling He 5 th Year CSE Masters Student, Who loves climbing and caving.

Course staff 6 Naozumi Hiranuma

Course staff 7 Mert Saglam 2 nd Year CSE Ph.D. Grad Student Works in Complexity Theory

Course staff 8 Mauricio Hernandez Junior majoring in Electrical Engineering With a concentration in Embedded Systems Originally from Tabasco, Mexico!

Course Information Textbook: Weiss 3 rd Edition in Java Course list: College of Arts & Sciences Instructional Computing Lab – –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 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

Data structures A data structure is a way to organize information to enable efficient computation over that information What are some examples? 15 pushpop enqueuedequeue

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

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-by- step 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? 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 pushpop

Why Useful Stack ADT arises all the time in programming Recursive function calls Balancing symbols in programming (parenthesis) Evaluating postfix notation: * 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 stack as an array stack as a linked list 21 1.Initially empty 2.Push(‘a’) 3.Push(‘b’) 4.Pop()

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

Circular Array Queue Data Structure 23 // 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; } bcdef Q: 0size - 1 front back 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?

In Class Practice 24 enqueue(‘A’) enqueue(‘B’) enqueue(‘C’) o = dequeue() enqueue(‘D’) enqueue(‘E’) enqueue(‘F’) enqueue(‘G’) enqueue(‘H’) enqueue(‘I’) frontback // 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; }

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

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

Linked List Queue Data Structure 27 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 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