CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues. Nicki Dell Spring 2014

Similar documents
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues. Linda Shapiro Spring 2016

Class Overview. CSE 326: Data Structures. Goals. Goals. Data Structures. Goals. Introduction

DATA STRUCTURES USING C

CS 2302 Data Structures Spring 2015

Chapter 3: Restricted Structures Page 1

CHAPTER 4 ESSENTIAL DATA STRUCTRURES

Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C

CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team

Data Structures and Algorithms Stacks and Queues

Introduction to Data Structures

7.1 Our Current Model

This lecture. Abstract data types Stacks Queues. ADTs, Stacks, Queues Goodrich, Tamassia

Dynamic Programming Problem Set Partial Solution CMPSC 465

CSE373: Data Structures & Algorithms Lecture 14: Hash Collisions. Linda Shapiro Spring 2016

Module 2 Stacks and Queues: Abstract Data Types

Analysis of a Search Algorithm

Introduction to Programming System Design. CSCI 455x (4 Units)

Sequential Data Structures

Common Data Structures

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

MAX = 5 Current = 0 'This will declare an array with 5 elements. Inserting a Value onto the Stack (Push)

Data Structure [Question Bank]

Java Software Structures

Introduction to Data Structures and Algorithms

Data Structures. Chapter 8

AP Computer Science AB Syllabus 1

Sample Syllabus (C++) CSCI 1301 Introduction to Programming Principles

Data Structures and Algorithm Analysis (CSC317) Intro/Review of Data Structures Focus on dynamic sets

DATA STRUCTURE - QUEUE

Computer Science 210: Data Structures. Introduction

02-201: Programming for Scientists

Data Structures. Jaehyun Park. CS 97SI Stanford University. June 29, 2015

Queues Outline and Required Reading: Queues ( 4.2 except 4.2.4) COSC 2011, Fall 2003, Section A Instructor: N. Vlajic

QUEUES. Primitive Queue operations. enqueue (q, x): inserts item x at the rear of the queue q

Questions 1 through 25 are worth 2 points each. Choose one best answer for each.

St S a t ck a ck nd Qu Q eue 1

CompuScholar, Inc. Alignment to Utah's Computer Programming II Standards

Universidad Carlos III de Madrid

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

Big O and Limits Abstract Data Types Data Structure Grand Tour.

CS 301 Course Information

Algorithms and Data Structures

Lecture 2: Data Structures Steven Skiena. skiena

STACKS,QUEUES, AND LINKED LISTS

Linked Lists Linked Lists, Queues, and Stacks

Course: Programming II - Abstract Data Types. The ADT Stack. A stack. The ADT Stack and Recursion Slide Number 1

PES Institute of Technology-BSC QUESTION BANK

Stacks. Stacks (and Queues) Stacks. q Stack: what is it? q ADT. q Applications. q Implementation(s) CSCU9A3 1

A bigger family, a better future.

The 2014 Ultimate Career Guide

Algorithms and Data Structures Written Exam Proposed SOLUTION

CS 300 Data Structures Syllabus - Fall 2014

1.00 Lecture 35. Data Structures: Introduction Stacks, Queues. Reading for next time: Big Java: Data Structures

Data Structures and Algorithms V Otávio Braga

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

A TOOL FOR DATA STRUCTURE VISUALIZATION AND USER-DEFINED ALGORITHM ANIMATION

POL 204b: Research and Methodology

Data Structures and Algorithms

Section IV.1: Recursive Algorithms and Recursion Trees

FIELD GUIDE TO LEAN EXPERIMENTS

CIS Information and Database Systems I. Course Syllabus Spring 2015

Linked Lists, Stacks, Queues, Deques. It s time for a chainge!

Node-Based Structures Linked Lists: Implementation

Eastern Washington University Department of Computer Science. Questionnaire for Prospective Masters in Computer Science Students

DATA STRUCTURE - STACK

How To Teach C++ Data Structure Programming

269 Business Intelligence Technologies Data Mining Winter (See pages 8-9 for information about 469)

1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders

Class Registration 101

SYLLABUS MAC 1105 COLLEGE ALGEBRA Spring 2011 Tuesday & Thursday 12:30 p.m. 1:45 p.m.

DIVISION OF INFORMATION TECHNOLOGY PROGRAMS AND SYSTEMS SUPPORT FALL 2015 / Spring 2016

Data Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010

Tennessee Educator Acceleration Model (TEAM) TEAM Evaluation Supplemental Materials 2014

Queues and Stacks. Atul Prakash Downey: Chapter 15 and 16

Thought for the Day Master Lesson

22c:31 Algorithms. Ch3: Data Structures. Hantao Zhang Computer Science Department

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015

Data Structures Using C++ 2E. Chapter 5 Linked Lists

STAT 1403 College Algebra Dr. Myron Rigsby Fall 2013 Section 0V2 crn 457 MWF 9:00 am

When I think about using an advanced scientific or graphing calculator, I feel:

Stacks. Data Structures and Data Types. Collections

Cpt S 223. School of EECS, WSU

Eastern Washington University Department of Computer Science. Questionnaire for Prospective Masters in Computer Science Students

Binary Search Trees CMPSC 122

Ordered Lists and Binary Trees

Administrative Issues

Programming with Data Structures

n Introduction n Art of programming language design n Programming language spectrum n Why study programming languages? n Overview of compilation

Lecture 1: Course Introduction"

CNT5412/CNT4406 Network Security. Course Introduction. Zhenhai Duan

Contents. 1 Introduction. CS 15 Collaboration Policy Fall Introduction Motivation Enforcement... 2

Multimedia & the World Wide Web

Eastern Washington University Department of Computer Science. Questionnaire for Prospective Masters in Computer Science Students

How to get started on research in economics? Steve Pischke June 2012

What Is Recursion? Recursion. Binary search example postponed to end of lecture

Application of Stacks: Postfix Expressions Calculator (cont d.)

CMSC 152: Introduction to Computer Science II

CSE 326: Data Structures B-Trees and B+ Trees

Transcription:

CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Nicki Dell Spring 2014

Registration We have 140 students registered and 140+ on the wait list! If you re thinking of dropping the course please decide soon! Wait listed students If you don t absolutely have to take the course this quarter, it s unlikely you ll get in. If you think you absolutely have to take the course this quarter, speak to the CSE undergraduate advisors. They will decide who gets added to the course. UW Employees, Auditors, etc. I will not make individual decisions about registration! 2

Welcome! We have 10 weeks to learn fundamental data structures and algorithms for organizing and processing information Classic data structures / algorithms How to rigorously analyze their efficiency How to decide when to use them Queues, dictionaries, graphs, sorting, etc. Today in class: Introductions and course mechanics What this course is about Start abstract data types (ADTs), stacks, and queues Largely review 3

To-do list In next 24-48 hours: Adjust class email-list settings Read all course policies Read Chapters 3.1, 3.6 and 3.7 of Weiss book Relevant to Homework 1, due next week Set up your Java environment for Homework 1 http://courses.cs.washington.edu/courses/cse373/14sp/ 4

Course staff Nicki Dell 5 th year CSE PhD grad student (loves teaching!) Works with Gaetano Borriello and the Change Group Fun fact: Grew up in Zimbabwe. Office hours, email, etc. on course web-page 5

Communication Course email list: cse373a_sp14@u.washington.edu Students and staff already subscribed You must get announcements sent there Fairly low traffic Course staff: cse373-staff@cs.washington.edu plus individual emails Discussion board For appropriate discussions; TAs will monitor Encouraged, but won t use for important announcements Anonymous feedback link For good and bad: if you don t tell me, I don t know 6

Course meetings Lecture (Nicki) Materials posted, but take notes Ask questions, focus on key ideas (rarely coding details) Optional sections on Tuesday/Thursday afternoons Will post rough agenda a few days in advance Help on programming/tool background Helpful math review and example problems Again, optional but helpful May cancel some later in course (experimental) Office hours Use them: please visit me Ideally not just for homework questions (but that s great too) 7

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 3 rd Edition in Java A good Java reference of your choosing Don t struggle Googling for features you don t understand 8

Computer Lab 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

Course Work 6 homeworks (60%) Most involve programming, but also written questions Higher-level concepts than just code it up First programming assignment due week from Wednesday Midterm Wednesday May 7, in class (15%) Final exam: Tuesday June 10, 2:30-4:20PM (25%) 10

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 When it happens, when you submit, not when asked I take academic integrity extremely seriously I offer great trust but with little sympathy for violations Honest work is a vital feature of a university 11

Some details You are expected to do your own work Exceptions (group work), if any, will be clearly announced Sharing solutions, doing work for, or accepting work from others is cheating Referring to solutions from this or other courses from previous quarters is cheating But you can learn from each other: see the policy 12

Advice on how to succeed in 373 Get to class on time! I will start and end promptly First 2 minutes are much more important than last 2! Midterms will prove beyond any doubt you are able to do so Learn this stuff It is at the absolute core of computing and software Falling behind only makes more work for you Do the work and try hard This stuff is powerful and fascinating, so have fun with it! 13

Today in Class Course mechanics: Did I forget anything? What this course is about Start abstract data types (ADTs), stacks, and queues Largely review 14

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 15

Assumed background Prerequisite is CSE143 Topics you should have a basic understanding of: Variables, conditionals, loops, methods, fundamentals of defining classes and inheritance, arrays, single linked lists, simple binary trees, recursion, some sorting and searching algorithms, basic algorithm analysis (e.g., O(n) vs O(n 2 ) and similar things) We can fill in gaps as needed, but if any topics are new, plan on some extra studying 16

Goals Deeply understand the basic structures used in all software Understand the data structures and their trade-offs 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 CSE143 (plus more new topics) Practice design, analysis, and implementation The mix of theory and engineering at the core of computer science More programming experience (as a way to learn) 17

Goals 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 Be able to justify and communicate your design decisions You will learn the key abstractions used almost every day in just about anything related to computing and software. 18

Data structures A data structure is a (often non-obvious) way to organize information to enable efficient computation over that information 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 19

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 We ask ourselves questions like: Does this support the operations I need efficiently? Will it be easy to use (and reuse), implement, and debug? What assumptions am I making about how my software will be used? (E.g., more lookups or more inserts?) 20

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

Example: Stacks The Stack ADT supports operations: isempty: have there been same number of pops as pushes push: takes an item pop: raises an error if empty, else returns most-recently pushed item not yet returned by a pop (possibly 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 22

Why useful The Stack ADT is a useful abstraction because: It arises all the time in programming (e.g., see Weiss 3.6.3) Recursive function calls Balancing symbols in programming (parentheses) Evaluating postfix notation: 3 4 + 5 * 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 an array and keep indices to the 23

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

Circular Array Queue Data Structure Q: 0 size - 1 b c d e f front back // 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; } 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? 25

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? 26

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 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 shift all later elements Not in Queue ADT For operation insertatposition must traverse all earlier elements Not in Queue ADT This is stuff you should know after being awakened in the dark 27

The Stack ADT Operations: create destroy push pop top is_empty A B C D E F F E D C B A Can also be implemented with an array or a linked list This is Homework 1 (which is posted)! Like queues, type of elements is irrelevant 28