Skip to content

Commit 1a880aa

Browse files
authored
Update README.md
1 parent 527fc25 commit 1a880aa

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

Skip-List/README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,41 @@ Skip List is a probablistic data-structure with same efficiency as AVL tree or R
44

55
![Schematic view](Images/Intro.png
66
)
7-
#TODO
8-
- finish readme
7+
8+
9+
#Inserting
10+
11+
1. Inserting a new element in initial state where no prior layer is created yet begins by construction of a Head node with a reference to data node (just like regular lists). After this operation coin-flipping starts to determine wether a new layer must be created. When positive, a new layer containing Head and data node ( similar to previous layer ) is created and head is updated to reference the new layer and the head node underneath. Subsequently data node is also updated to reference the node below; until coin-flip function return a negative value to terminate this process.
12+
13+
2. After initial state, we start at top most layer to find a node where its value is less than the new value and its next node value is greater-equal/nil than new value. Then we use this node to travel to layer underneath until we reach the layer 0 where the element must be inserted first, after this node. Node references must be updated accordingly by back tracing the path to the top. If the first element in the layer does not meet the criteria, same procedure is used to travel to the layer below using the head node.
14+
15+
16+
**Example**
17+
18+
19+
1 - Inserting 10 in initial state with coin flips (0)
20+
21+
![Inserting first element](Images/Insert1.png)
22+
23+
24+
2 - 12 inserted with coin flips (1,1,0)
25+
26+
27+
3 - Inserting 13. with coin flips (0)
28+
29+
![Inserting first element](Images/Insert5.png)
30+
![Inserting first element](Images/Insert6.png)
31+
![Inserting first element](Images/insert7.png)
32+
![Inserting first element](Images/Insert8.png)
33+
![Inserting first element](Images/Insert9.png)
34+
35+
36+
#Searching
37+
38+
TODO
39+
40+
#See also
41+
42+
[Skip List on Wikipedia](https://en.wikipedia.org/wiki/Skip_list)
43+
44+
Written for Swift Algorithm Club by [Mike Taghavi](https://github.com/mitghi)

0 commit comments

Comments
 (0)