0% found this document useful (0 votes)
54 views

CSE 326: Data Structures Lecture #0: Steve Wolfman Winter Quarter 2000

This document provides an introduction and overview of the CSE 326: Data Structures course. It outlines the course policies, mechanics, and goals which include becoming familiar with fundamental data structures and improving algorithm analysis skills. It also introduces common data structures like queues, stacks, and their applications. Sample queue and stack implementations using arrays and linked lists are presented along with their properties and efficiency.

Uploaded by

Nahid Hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

CSE 326: Data Structures Lecture #0: Steve Wolfman Winter Quarter 2000

This document provides an introduction and overview of the CSE 326: Data Structures course. It outlines the course policies, mechanics, and goals which include becoming familiar with fundamental data structures and improving algorithm analysis skills. It also introduces common data structures like queues, stacks, and their applications. Sample queue and stack implementations using arrays and linked lists are presented along with their properties and efficiency.

Uploaded by

Nahid Hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 27

CSE 326: Data Structures

Lecture #0
Introduction
Steve Wolfman
Winter Quarter 2000
Come up and say hello!
Today’s Outline
• Administrative Cruft
• Overview of the Course
• Queues
• Stacks
• Survey
Course Information
• Instructor: Steve Wolfman
226D Sieg Hall
[email protected]
Office hours: M 11:30-12:30, F 3:30-4:30
• TAs:
Zasha Weinberg zasha@cs
Nic Bone bone@cs
Office hours: TBA
• Text: Data Structures & Algorithm Analysis in C++, 2nd
edition, by Mark Allen Weiss
Course Policies
• Weekly written homework due at the start of class on the
due date
• Projects (4 total) due by 10PM on the due date
– you have 4 late days for projects
• Grading
– homework: 15%
– projects: 25%
– midterm: 20%
– final: 30%
– best of these: 10%
Course Mechanics
• 326 Web page: www/education/courses/326
• 326 course directory: /cse/courses/cse326
• 326 mailing list: cse326@cs
– subscribe to the mailing list using majordomo, see
homepage
• Course laboratory is 329 Sieg Hall
– lab has NT machines w/X servers to access UNIX
• All programming projects graded on UNIX/g++
What is a Data Structure?
data structure -
Observation
• All programs manipulate data
– programs process, store, display, gather
– data can be information, numbers, images, sound
• Each program must decide how to store data
• Choice influences program at every level
– execution speed
– memory requirements
– maintenance (debugging, extending, etc.)
Goals of the Course
• Become familiar with some of the fundamental data
structures in computer science
• Improve ability to solve problems abstractly
– data structures are the building blocks
• Improve ability to analyze your algorithms
– prove correctness
– gauge (and improve) time complexity
• Become modestly skilled with the UNIX operating
system and X-windows (you’ll need this in upcoming courses)
What is an Abstract Data Type?
Abstract Data Type (ADT) -

1) An opportunity for an acronym

2) Mathematical description of an object and the set


of operations on the object
Data Structures as Algorithms
• Algorithm
– A high level, language independent description of a
step-by-step process for solving a problem
• Data Structure
– A set of algorithms which implement an ADT
Why so many data structures?
Ideal data structure: Dictionary ADT
fast, elegant, memory – list
efficient – binary search tree
– AVL tree
– Splay tree
Generates tensions: – Red-Black tree
– time vs. space
– hash table
– performance vs. elegance
– generality vs. simplicity
– one operation’s
performance vs. another’s
Code Implementation
• Theoretically
– abstract base class describes ADT
– inherited implementations implement data structures
– can change data structures transparently (to client code)
• Practice
– different implementations sometimes suggest different
interfaces (generality vs. simplicity)
– performance of a data structure may influence form of
client code (time vs. space, one operation vs. another)
ADT Presentation Algorithm
• Present an ADT
• Motivate with some applications
• Repeat until browned entirely through
– develop a data structure for the ADT
– analyze its properties
• efficiency
• correctness
• limitations
• ease of programming
• Contrast data structure’s strengths and weaknesses
– understand when to use each one
Queue ADT
• Queue operations
– create
– destroy enqueue dequeue

G FEDCB A
enqueue
– dequeue
– is_empty
• Queue property: if x is enQed before y is enQed,
then x will be deQed before y is deQed
FIFO: First In First Out
Applications of the Q
• Hold jobs for a printer
• Store packets on network routers
• Hold memory “freelists”
• Make waitlists fair
• Breadth first search
Circular Array Q Data Structure
0
Q size - 1
b c d e f

front back

void enqueue(Object x) { bool is_empty() {


Q[back] = x return (front == back)
back = (back + 1) % size }
}
Object dequeue() { bool is_full() {
x = Q[front] return front ==
front = (front + 1) % size (back + 1) % size
return x }
}

This is pseudocode. Do not correct my semicolons.


Q Example
enqueue R
enqueue O
dequeue
enqueue T
enqueue A
enqueue T
dequeue
dequeue
enqueue E
dequeue
Linked List Q Data Structure
b c d e f

front back

void enqueue(Object x) { Object dequeue() {


assert(!is_empty)
if (is_empty())
return_data = front->data
front = back = new Node(x) temp = front
else front = front->next
back->next = new Node(x) delete temp
return temp->data
back = back->next }
} bool is_empty() {
return front == null
}
Circular Array vs. Linked List
LIFO Stack ADT
• Stack operations A EDCBA
– create
– destroy B
– push C
– pop D
– top E
– is_empty F F
• Stack property: if x is on the stack before y is pushed,
then x will be popped after y is popped
LIFO: Last In First Out
Stacks in Practice
• Function call stack
• Removing recursion
• Balancing symbols (parentheses)
• Evaluating Reverse Polish Notation
• Depth first search
Array Stack Data Structure
0
S size - 1
f e d c b

back

void push(Object x) { Object pop() {


assert(!is_full()) back--
S[back] = x return S[back]
}
back++
bool is_empty() {
}
return back == 0
Object top() { }
assert(!is_empty()) bool is_full() {
return S[back - 1] return back == size
} }
Linked List Stack Data Structure
b c d e f

back

void push(Object x) { Object pop() {


temp = back assert(!is_empty())
back = new Node(x) return_data = back->data
temp = back
back->next = temp
back = back->next
}
return return_data
Object top() { }
assert(!is_empty()) bool is_empty() {
return back->data return back == null
} }
Data structures you should
already know
• Arrays
• Linked lists
• Trees
• Queues
• Stacks
To Do
• Sign up on the cse326 mailing list
• Check out the web page
• Log on to the PCs in room 329 and access an
instructional UNIX server
• Read Chapters 1 and 3 in the book
Coming Up
• Multi-Lists
• Asymptotic Analysis
• Project I (solving mazes with stacks and queues)
• First homework

You might also like