Sorting
Dr. Bernard Chen Ph.D.
University of Central Arkansas
Insertion Sort I
n
n
The list is assumed to be broken into a
sorted portion and an unsorted portion
Keys will be inserted from the unsorted
portion into the sorted portion.
Sorted
Unsorted
Inse
Algorithm Analysis
Dr. Bernard Chen Ph.D.
University of Central Arkansas
Outline
n
n
Big O notation
Two examples
n
n
Search program
Max. Contiguous Subsequence
Program
n
Algorithms + Data Structure = Programs
n
Algorithms:
n
n
n
Must be definite and unamb
AVL Trees
5
3
1
7
2
8
1
Binary Search Tree
n
Binary search tree, using simple insert and
delete procedures
q
the tree is nearly balance
n
n
n
q
add - fast O(log n)
delete a target - fast O(log n)
search - fast O(log n)
the tree is highly unbalance, it bec
Trees
5
3
1
7
2
8
1
General Trees
q
q
Nonrecursive definition: a
tree consists of a set of
nodes and a set of directed
edges that connect pairs of
nodes.
Recursive definition: Either
a tree is empty or it consists
of a root and zero or more
nonempty subtr
Chapter 16 Stack and Queues
part2
Dr. Bernard Chen Ph.D.
University of Central Arkansas
Introduction to Queues
n
A queue is a waiting line
n
Its in daily life:
n
n
n
n
A line of persons waiting to check out at a
supermarket
A line of persons waiting to pu
Stack and Queue
Dr. Bernard Chen Ph.D.
University of Central Arkansas
Introduction to Stacks
n
Consider the following problems:
Problem 1:
For a poker game; on any turn, a player may
discard a single card from his hand to the top
of the pile, or he may re
BST Trees
5
3
1
8
4
9
1
Binary search tree (BST)
A binary search tree is a binary tree in
which every node satisfies the
following:
5
the key of every node in the left
subtree is smaller than the key of this
node
the key of every node in the right
subtree
Hash table
1
A basic problem
n
We have to store some records and perform
the following:
q
q
q
n
add new record
delete record
search a record by key
Find a way to do these efficiently!
2
Array as table
studid
0012345
0033333
0056789
.
9801010
9802020
.
990
Recursion
Dr. Bernard Chen Ph.D.
University of Central Arkansas
1
Mathemetical Induction
To prove
Let p(n) denote the statement involving the integer
variable n. The Principle of Mathematical Induction states:
If p(1) is true and, for some integer K >=1
Huffman Encoding
Dr. Bernard Chen Ph.D.
University of Central Arkansas
Text Compression (Zip)
n
n
On a computer: changing the
representation of a file so that it takes
less space to store or/and less time to
transmit.
Original file can be reconstructed
ex
Graph
Dr. Bernard Chen Ph.D.
University of Central Arkansas
Graph Algorithms
Graphs and Theorems about
Graphs
n Graph Algorithms
n
n
minimum spanning tree
What can graphs model?
n
n
n
Cost of wiring electronic components
together.
Shortest route between t
The Binary Heap
Dr. Bernard Chen Ph.D.
University of Central Arkansas
Whats priority queue
Problem: find MIN and Delete
n
1.
2.
3.
Possible methods:
unsorted array
sorted array
Binary Search tree
Whats Binary Heap
n
n
n
The Binary Heap supports the insert
Course Policy
CSCI 2320 Data Structure
Spring 2016
Catalog description
This class is a required course for majors and minors. The fundamental data structures including sets, lists, trees, and graphs
are studied. Various methods of implementing these struc