RB-Insert(T, z)
(Pre: key[z] has been set)
1. ynil
2. xroot[T]
3. while x nil
4.
yx
5.
if key[z]<key[x]
6.
xleft[x]
7.
else
8.
xright[x]
9. p[z]y
10. if y = nil
11.
root[T]z
12. else if key[z]<key[y]
Review: Map (Dictionary) ADT
Map ADT operations
CS515
!
!
!
Insert
Find
erase
Store entries of data value associated with keys
! Data Values : any type
! Keys : any comparable type
Hashing
2
Map Imple
Binary Search Tree - Review
All BST operations are O(h), where h is tree height
Minimum height is h = !log N#
"
$
!
CS515
!
2
for a binary tree with N nodes.
What is the best and worse case for h ?
Th
Summary of the performance of symbol-table implementations
Performance comparison
Order of growth of the frequency of operations.
typical case
CS515
implementation
search
red-black BST
Tries
insert
de
Threaded Binary Tree
Threaded Binary Tree
In a linked representation of a binary tree, the number
of null links (null pointers) are actually more than nonnull pointers.
Consider the following binary t
Heap Sort
You may have noticed that in a max heap, the largest value can easily be removed
from the top of the heap and in the ensuing siftDown() a 'free' slot is made available at
what was the end of
CSCI-1200 Data Structures Spring 2015
Lecture 21 Operators & Friends
Review from Lecture 20
Last piece of ds_set: removing an item, erase
Tree height & tree height order notation
Todays Lecture
Fin
Classes
The fundamental ideas behind classes are
data abstraction and encapsulation.; A class
using data abstraction and encapsulation
denes an Abstract Data Type (ADT).
Classes are often called use
Optimization problems
CS515
!
!
Greedy Algorithm
Divide and Conquer
And
Dynamic Programming
An optimization problem is one in which
you want to find, not just a solution, but the
best solution
E.g. Hu
ZYNELEME
(RECURSION)
1
2
ZYNELEME(RECURSION)
Kendi kendisini dorudan veya dolayl olarak aran
fonksiyonlara zyineli (recursive) fonksiyonlar ad verilir.
zyineleme bir problemi benzer ekilde olan daha b