CSE 332: Data Structures Winter 2014 Richard Anderson, Steve Seitz - - PowerPoint PPT Presentation

cse 332 data structures
SMART_READER_LITE
LIVE PREVIEW

CSE 332: Data Structures Winter 2014 Richard Anderson, Steve Seitz - - PowerPoint PPT Presentation

CSE 332: Data Structures Winter 2014 Richard Anderson, Steve Seitz Lecture 1 CSE 332 Team Instructors: Richard Anderson, Steve Seitz TAs: Jacob Hyein Aaron Daniel David Sam Gile Kim Nech Noteboom Swanson Wilson 2


slide-1
SLIDE 1

CSE 332: Data Structures

Winter 2014 Richard Anderson, Steve Seitz Lecture 1

slide-2
SLIDE 2

2

CSE 332 Team

  • Instructors: Richard Anderson, Steve Seitz
  • TAs:

Jacob Gile Hyein Kim Aaron Nech Daniel Noteboom David Swanson Sam Wilson

slide-3
SLIDE 3

3

Today’s Outline

  • Introductions
  • Administrative Info
  • What is this course about?
  • Review: queues and stacks
slide-4
SLIDE 4

4

Course Information

Web page:

http://www.cs.washington.edu/332

Text: Weiss, Data Structures & Algorithm Analysis in Java, 3rd Edition, 2012. (or buy 2nd edition—1/3 price on Amazon!)

slide-5
SLIDE 5

5

Communication

Instructors

› cse332-instr@cs.washington.edu › (or our individual addresses)

Announcements

› cse332a_wi14@u, cse332b_wi14@u › (you are automatically subscribed @u)

Discussion

› Discussion board linked off home page

slide-6
SLIDE 6

6

Written homeworks

Written homeworks (8 total)

› Assigned each Wednesday › Due at the start of class following Wednesday › No late homeworks accepted

slide-7
SLIDE 7

7

Projects

  • Programming projects (3 total, with phases)

› In Java › Eclipse encouraged › Turned in electronically › Can use a “late day” for 1 project of your choice Must email TA in advance

slide-8
SLIDE 8

8

Project 1 out today

  • Soundblaster! Reverse a song

› a.k.a., “backmasking”

  • Use a stack

› Implement as array and as linked list

  • Read the website

› Detailed description of assignment › Detailed description of how programming projects are graded

  • Phase A due Monday, Jan 13 (11:59pm)

› Electronic submission

slide-9
SLIDE 9

9

Overall grading

Grading 25% - Written Homework Assignments 30% - Programming Assignments 20% - Midterm Exam (Feb 10) 25% - Final Exam (March 17)

slide-10
SLIDE 10

10

Collaboration

Read policy on website carefully

› HWs must be done solo

  • But you can discuss problems with others as

long as you follow the Gilligan’s island rule

› Project 1 is solo (out today) › Project 2 & 3 with a partner

slide-11
SLIDE 11

11

Section

Meet on Thursdays What happens there?

› Answer questions about current homework › Previous homeworks returned and discussed › Discuss the project (getting started, getting through it, answering questions) › Finer points of Java, eclipse, etc. › Reinforce lecture material

slide-12
SLIDE 12

12

Homework for Today!!

Reading in Weiss

Chapter 1 – (Review) Mathematics and Java Chapter 2 – (Next lecture) Algorithm Analysis Chapter 3 – (Project #1) Lists, Stacks, & Queues

slide-13
SLIDE 13

13

Today’s Outline

  • Introductions
  • Administrative Info
  • What is this course about?
  • Review: Queues and stacks
slide-14
SLIDE 14

Steve’s view of CSE

  • 100 level courses, some 300 level

› how to do stuff

  • This course

› Really cool ways to do stuff

  • 400 level courses

› How to do really cool stuff

14

slide-15
SLIDE 15

15

Common tasks

slide-16
SLIDE 16

16

Common tasks

  • Many possible solutions

› Choice of algorithm, data structures matters › What properties do we want?

slide-17
SLIDE 17

17

Example: Fibonacci

int fib( int n ) { if( n <= 2 ) return 1; else return fib( n - 1 ) + fib( n - 2 ); }

n 1 2 3 4 5 6 … Fib 1 1 2 3 5 8 …

slide-18
SLIDE 18

18

Why should we care?

  • Computers are getting faster

› No need to optimize

  • Libraries: experts have done it for you
slide-19
SLIDE 19

19

How to be an expert

  • Tricks of the trade

› Knowledge › Analysis › Style

slide-20
SLIDE 20

20

Program Abstraction

Problem defn: Algorithm: Implementation:

slide-21
SLIDE 21

21

Data Abstraction

Abstract Data Type (ADT): Data Structure: Implementation:

slide-22
SLIDE 22

22

Terminology

  • Abstract Data Type (ADT)

› Mathematical description of an object with set of

  • perations on the object. Useful building block.
  • Algorithm

› A high level, language-independent, description of a step-by-step process.

  • Data structure

› A specific organization of the data to accompany algorithms for an abstract data type.

  • Implementation of data structure

› A specific implementation in a specific language.

slide-23
SLIDE 23

23

Today’s Outline

  • Introductions
  • Administrative Info
  • What is this course about?
  • Review: queues and stacks
slide-24
SLIDE 24

24

  • FIFO: First In First Out
  • Queue operations

create destroy enqueue dequeue is_empty

First Example: Queue ADT

F E D C B

enqueue dequeue

G A

slide-25
SLIDE 25

25

  • Print jobs
  • File serving
  • Phone calls and operators

(Later, we will consider “priority queues.”)

Queues in practice

slide-26
SLIDE 26

26

Array Queue Data Structure

enqueue(Object x) { Q[back] = x back = (back + 1)

}

b c d e f

Q

size - 1 back

dequeue() { x = Q[0] shiftLeftOne() Back = (back – 1) return x } What’s missing in these functions? How to find K-th element in the queue?

slide-27
SLIDE 27

27

Circular Array Queue Data Structure

enqueue(Object x) { assert(!is_full()) Q[back] = x back = (back + 1)

}

b c d e f

Q

size - 1 front back

dequeue() { assert(!is_empty()) x = Q[front] front = (front + 1) return x } How test for empty/full list? How to find K-th element in the queue? What to do when full?

slide-28
SLIDE 28

28

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 }

slide-29
SLIDE 29

29

Circular Array vs. Linked List

  • Advantages of circular array?
  • Advantages of linked list?
slide-30
SLIDE 30

30

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

slide-31
SLIDE 31

31

Stacks in Practice

  • Function call stack
  • Removing recursion
  • Balancing symbols (parentheses)
  • Evaluating postfix or “reverse Polish”

notation

slide-32
SLIDE 32

32

Assigned readings

Reading in Weiss

Chapter 1 – (Review) Mathematics and Java Chapter 2 – (Next lecture) Algorithm Analysis Chapter 3 – (Project #1) Lists, Stacks, & Queues

slide-33
SLIDE 33