Algorithm SkipInsert(k, v): Input: Key k and value v Output: Topmost position of the entry inserted in the skip list p = SkipSearch(k) q = null i = −1 repeat i=i+1 {position in bottom list with largest key less than k} {current node of new entry's tower} {current height of new entry's tower} {increase height of new entry's tower}

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please send me answer within 10 min!! I will rate you good for sure!! Please send me explanation for your solution!! 

implement insertAfterAbove for this Pseudocode below in java

Algorithm SkipInsert(k, v):
Input: Key k and value v
Output: Topmost position of the entry inserted in the skip list
p = SkipSearch(k)
q = null
i = −1
repeat
i=i+1
if i ≥h then
h = h +1
{position in bottom list with largest key less than k}
{current node of new entry's tower}
{current height of new entry's tower}
{increase height of new entry's tower}
{add a new level to the skip list}
{grow leftmost tower}
{grow rightmost tower}
{add node to new entry's tower}
t =
next(s)
s insert AfterAbove(null, s, (-∞, null))
insert AfterAbove(s, t, (+∞, null))
q= insertAfterAbove(p, q, (k, v))
while above(p) == null do
p = prev(p)
p = above(p)
until coinFlip() == tails
n = n +1
return q
{scan backward}
{jump up to higher level}
{top node of new entry's tower}
Code Fragment 10.15: Insertion in a skip list of entry (k, v) We assume the skip list
does not have an entry with key k. Method coinFlip() returns "heads" or "tails",
each with probability 1/2. Instance variables n, h, and s respectively hold the
number of entries, the height, and the start node of the skip list.
Transcribed Image Text:Algorithm SkipInsert(k, v): Input: Key k and value v Output: Topmost position of the entry inserted in the skip list p = SkipSearch(k) q = null i = −1 repeat i=i+1 if i ≥h then h = h +1 {position in bottom list with largest key less than k} {current node of new entry's tower} {current height of new entry's tower} {increase height of new entry's tower} {add a new level to the skip list} {grow leftmost tower} {grow rightmost tower} {add node to new entry's tower} t = next(s) s insert AfterAbove(null, s, (-∞, null)) insert AfterAbove(s, t, (+∞, null)) q= insertAfterAbove(p, q, (k, v)) while above(p) == null do p = prev(p) p = above(p) until coinFlip() == tails n = n +1 return q {scan backward} {jump up to higher level} {top node of new entry's tower} Code Fragment 10.15: Insertion in a skip list of entry (k, v) We assume the skip list does not have an entry with key k. Method coinFlip() returns "heads" or "tails", each with probability 1/2. Instance variables n, h, and s respectively hold the number of entries, the height, and the start node of the skip list.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY