Chapter 5
Pointers and Dynamic Memory
1
Main Index
Contents
Our first data structure: Array
int a[10];
0
2
1
2
3
4
5
6
7
8
9
A very useful and basic data structure
What are good and bad about arrays?
Many other data structures have been
designed by overc
Mid-term Exam Solutions
Question 1(a)
Use the sequential search to find a target
value in a vector of 10000 items.
(i) What is the fewest number of comparisons the
search will require?
1
(ii) What is the maximum number of comparisons
the search will re
CS 361: Advanced Data Structures and Algorithms (Spring 2014)
Course Information
Instructor: Dr. Shuiwang Ji
Ofce: ECSB 3325
E-mail: sji@cs.odu.edu
Lecture: T&Th, 16:20-17:35
Ofce Hours: T&Th, 11:00am-12:00pm or by appointment
Lecture Location: DRAG
Chapter 10
Binary Trees
1
Main Index
Contents
Sequence and Associative Containers
Sequence containers access data by position
1. Array (index)
2. Vector (index)
3. List (iterator)
Associate containers access data by value
1. Binary search tree
Arrays
V
Chapter 12
Advanced Associative Structures
http:/www.arl.wustl.edu/projects/fpx/cse535/lecture/cse535_lecture6_Hash_Functions.pdf
Review
The associative containers, sets, multisets,
maps, and multimaps implement their
operations by using a binary search
Chapter 14: heaps
Array-based trees
In Chapter 10, we created trees as a collection of
dynamically generated nodes.
With some simple rules, we can view a directaccess container, such as an array or vector, as a
binary tree.
These trees are referred to
Chapter 9
Linked Lists
1
Main Index
Contents
Insertion Into a List by Shifting
Vector Storage Elements
Ins ert 5 int o lis t 2 7 3 10 at t he 3rd p os it ion
Im p lem ent at ion s hift s lis t Vect or [2] and lis t Vect or [3]
2
7
3
10
R es ult ing lis t
Chapter 11
Associative Containers:
sets and maps
Associative containers
An associative container stores elements based
on a key, which consists of one or more attributes
to uniquely identify each element
The main difference is that associative container
Chapter 3
Introduction to Algorithms
1
Main Index
Contents
Recursion
2
Recursive function: a function that calls itself
A lot of examples in practical applications
Should be used with caution due to efficiency
issues-more later
Examples: power, factorial
Chapter 8
Queues and Priority Queues
1
Main Index
Contents
Grocery Store Checkout: A
Model for a Queue
2
Main Index
Contents
Queues
A queue inserts new elements at the back and removes
elements from the front of the sequence.
Queue: First in, first out,
Chapter 4
The Vector Container
1
Main Index
Contents
Template Class
template <typename T>
class templateClass
cfw_
public:
/ constructor with argument of
/ constant reference type T
templateClass (const T& item);
/ member function returns a value of
/ ty
CS 361: Advanced Data Structures and
Algorithms
Shuiwang Ji
Based on slides accompanying the book
1
About the instructor
2
Assistant Professor of Computer Science
Joined ODU in 2010 after receiving a PhD from
Arizona State University
Research interests: m
Chapter 7
Stacks
1
Main Index
Contents
Container Types
Sequence
Containers
Associative
Containers
Vector
Stack
Set, Multiset
Deque
Queue
Map,
Mutltimap
List
2
Adapter
Containers
Priority Queue
Main Index
ain
Index
Contents
ontent
s
3
Stacks
A stack is a
Chapter 6
The List Container and Iterators
1
Main Index
Contents
Model of a list object with links
to next and previous element
front
2
back
Main Index
Contents
Container classes
Underlying storage structure
The storage structure should be selected so th
CS 361, Final Exam
Open book, open notes, but you are not to communicate with any one else during the
exam. You are to solve 3 of the following problems in C+, using the STL library, each
code should run stand-alone as a simulation, and each code should c