CSCE 3110 Data Structures & Algorithm Analysis. Rada Mihalcea http://www.cs.unt.edu/~rada/CSCE3110 Dictionaries. Reading Weiss Chap. 5, Sec. 10.4.2. Dictionaries. A dictionary is a collection of elements each of which has a unique search key Uniqueness criteria may be relaxed (multiset)
Related searches for CSCE 3110 Data Structures Algorithm Analysis
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Rada Mihalcea
http://www.cs.unt.edu/~rada/CSCE3110
Dictionaries. Reading Weiss Chap. 5, Sec. 10.4.2
Dictionary
Member
Record
key
student name
hw1
123
Stan Smith
49
...
124
Sue Margolin
56
...
125
Billie King
34
...
...
167
Roy Miller
39
...
isEmpty()
elements()
findAllElements(k)
removeElement(k)
removeAllElements(k)
S3

S2

18
S1

18
25
74
S0

12
18
25
28
72
74
1. if below(p) is null then stop
2. while key(p) < K move to the right
go back to 1
Algorithm SkipSearch(k)
Input: Search key k
Output: Position p in S such that p has the largest key less than or equal to k
p = topmost, left node in S
while below(p) != null do
p below(p)
while(key (after(p)) k do
p after(p)
return p
S3

S2

18
S1

18
25
29
74
S0

12
18
25
28
29
72
74
Algorithm SkipInsert(k,e)
Input: Item (k,e)
Output: 
p SkipSearch(k)
q insertAfterAbove(p, null, Item (k,e))
while random( ) 50% do
while(above(p) == null) do
p before(p)
p above(p)
q insertAfterAbove(p, q, Item(k,e))
S3

S2

18
S1

18
25
74
S0

12
18
25
28
72
74