SlideShare a Scribd company logo
SkipList
Searching a key in a Sorted linked list Searching an element  x cell *p =head ; while (p->next->key < x )  p=p->next ;  return p ; Note: we return  the element proceeding either the element containing  x , or the smallest element with a key larger than  x  (if  x  does not exists)  7 14 21 32 37 71 85 117 - 1 1 head find(71)
inserting a key into a Sorted linked list To insert 35 -  p=find(35); CELL *p1 = (CELL *) malloc(sizeof(CELL)); p1->key=35; p1->next = p->next ;  p->next  = p1 ;  7 14 21 32 37 71 85 117 - 1 1 head p 35
deleteing a key from a sorted list To delete 37 -  p=find(37); CELL *p1 =p->next;  p->next = p1->next ;  free(p1);  7 14 21 32 37 71 85 117 - 1 1 head p p1
A data structure for maintaing a set of keys in a sorted order --- SKIP LIST Consists of several  levels.  All keys appear in level 1 Each level is a sorted list.  If key  x  appears in level  i , then it also appears in all levels below  i 7 14 21 32 37 71 85 117 71 37 21 7 37 21 Level 1 Level 2 Level 3  Top - 1 - 1 - 1 1 1 1
More rules  An element in level  i  points (via down pointer) to the element with the same key in the level below.   In each level the keys - 1  and  1  appear. (In our implementation, INT_MIN and INT_MAX Top points to the smallest element in the highest level. 7 14 21 32 37 71 85 117 71 37 21 7 37 21 Level 1 Level 2 Level 3  Top - 1 - 1 - 1 1 1 1 next-pointer Down-pointer
An empty SkipList  Level 1 Top - 1 1
Finding an element  with key  x p=top While(1){ while (p->next->key < x ) p=p->next; If (p->down == NULL ) return p->next  p=p->down ;  } Observe that we return  x , if exists, or  succ(x)  if  x  is not in the SkipList 7 14 21 32 37 71 85 117 71 37 21 7 37 21 Level 1 Level 2 Level 3  Top - 1 - 1 - 1 1 1 1 next-pointer down-pointer find(117), find(118)
Inserting new element  X Determine  k  the number of levels in which  x  participates (explained later) Do find(x), and insert x to the appropriate places in the lowest  k  levels. (after the elements at which the search path turns down or terminates) Example - inserting 119.  k =2 7 14 21 32 37 71 85 71 37 21 7 37 21 Level 1 Level 2 Level 3  Top - 1 - 1 - 1 1 1 1 next-pointer Down-pointer 119 119
Inserting an element - cont.  If  k  is larger than the current number of levels, add new levels (and update top) Example - inser(119) when  k=4   7 14 21 32 37 71 85 71 37 21 7 37 21 Level 1 Level 2 Level 3  Top - 1 - 1 - 1 1 1 1 119 119 119 119 1 - 1
Determining  k  k -  the number of levels at which an element x participate.  Use a random function  OurRnd() ---  returns  1 or 0 (True/False) with equal probability.  k=1 ;  While( OurRnd() ) k++ ;
Deleteing a key  x   Find x in all the levels it participates, and delete it using the standard ' delete from a linked list'  method. If one or more of the upper levels are empty, remove them (and update top) 7 14 21 32 37 71 85 117 71 37 21 7 37 21 Level 1 Level 2 Level 3  Top - 1 - 1 - 1 1 1 1 next-pointer down-pointer delete(71)
Facts about SL The expected number of levels is  O( log  n  )   (here  n   is the numer of elements) The expected time for insert/delete/find is  O( log  n  ) The expected size (number of cells) is  O( n  )

More Related Content

PPTX
Skip lists (Advance Data structure)
Shubham Shukla
 
PDF
14 Skip Lists
Andres Mendez-Vazquez
 
PPTX
Quick Sort
Shweta Sahu
 
PPT
Algorithm: Quick-Sort
Tareq Hasan
 
PPTX
Quick sort
Dhruv Sabalpara
 
PPTX
Quicksort Presentation
irdginfo
 
PPT
Heaps
Hafiz Atif Amin
 
Skip lists (Advance Data structure)
Shubham Shukla
 
14 Skip Lists
Andres Mendez-Vazquez
 
Quick Sort
Shweta Sahu
 
Algorithm: Quick-Sort
Tareq Hasan
 
Quick sort
Dhruv Sabalpara
 
Quicksort Presentation
irdginfo
 

What's hot (20)

PPTX
Quick sort
Jehat Hassan
 
PPTX
Quick sort
amar kakde
 
PPTX
Insertion sort
almaqboli
 
PPTX
Selection sort
Jay Patel
 
PPT
Selection sort
stella D
 
PPTX
Data Structures - Lecture 8 [Sorting Algorithms]
Muhammad Hammad Waseem
 
PPTX
Sorting Algorithms
Pranay Neema
 
PPTX
Linked List - Insertion & Deletion
Afaq Mansoor Khan
 
PPTX
Merge sort and quick sort
Shakila Mahjabin
 
PPTX
Asymptotic Notation
Protap Mondal
 
PPTX
Sorting algorithms
Trupti Agrawal
 
PDF
Heap and heapsort
Amit Kumar Rathi
 
PDF
Trees, Binary Search Tree, AVL Tree in Data Structures
Gurukul Kangri Vishwavidyalaya - Faculty of Engineering and Technology
 
PPTX
Quick sort
Afaq Mansoor Khan
 
PDF
Quick sort algorithn
Kumar
 
PPTX
Binary Heap Tree, Data Structure
Anand Ingle
 
PPTX
Dijkstra
jagdeeparora86
 
PPT
Master method
Rajendran
 
PPTX
Linked List
Ashim Lamichhane
 
PPTX
Quick sort-Data Structure
Jeanie Arnoco
 
Quick sort
Jehat Hassan
 
Quick sort
amar kakde
 
Insertion sort
almaqboli
 
Selection sort
Jay Patel
 
Selection sort
stella D
 
Data Structures - Lecture 8 [Sorting Algorithms]
Muhammad Hammad Waseem
 
Sorting Algorithms
Pranay Neema
 
Linked List - Insertion & Deletion
Afaq Mansoor Khan
 
Merge sort and quick sort
Shakila Mahjabin
 
Asymptotic Notation
Protap Mondal
 
Sorting algorithms
Trupti Agrawal
 
Heap and heapsort
Amit Kumar Rathi
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Gurukul Kangri Vishwavidyalaya - Faculty of Engineering and Technology
 
Quick sort
Afaq Mansoor Khan
 
Quick sort algorithn
Kumar
 
Binary Heap Tree, Data Structure
Anand Ingle
 
Dijkstra
jagdeeparora86
 
Master method
Rajendran
 
Linked List
Ashim Lamichhane
 
Quick sort-Data Structure
Jeanie Arnoco
 
Ad

Similar to skip list (20)

DOCX
Stack q ll algo
parthpatel9694
 
PPTX
Data strutcure and annalysis topic stack
MihirMishra36
 
PDF
Data structures stacks
maamir farooq
 
PPTX
Address calculation-sort
Vasim Pathan
 
PPT
Sorting
Saurabh Mishra
 
PPTX
Computer Network Assignment Help
Computer Network Assignment Help
 
PPT
2.ppt
ArifKamal36
 
PPTX
Searching and Sorting algorithms and working
RitikaLohiya2
 
PDF
Stacks,queues,linked-list
pinakspatel
 
DOCX
PPS 7.7 RECURSION, AS A DIFFERENT WAY OF SOLVING PROBLEMS. EXAMPLE PROGRAMS
Sitamarhi Institute of Technology
 
PDF
Polynomial Function and Synthetic Division
AleczQ1414
 
PDF
Unit - 2.pdf
AravindAnand21
 
PDF
Scilab help book 2 of 2
Arun Umrao
 
PDF
Think Like Scilab and Become a Numerical Programming Expert- Notes for Beginn...
ssuserd6b1fd
 
PPT
DAA-Divide and Conquer methodology, DAA 2024
RUHULAMINHAZARIKA
 
PPT
Data Structure and Algorithms Stacks
ManishPrajapati78
 
PPTX
Implementation of stacks and queues in C
HarishKrishnanP
 
PPT
Sorting and Searching in Data Structures.ppt
Vivekananda Gn
 
PPT
chapter7.ppt
Preetiverma538521
 
Stack q ll algo
parthpatel9694
 
Data strutcure and annalysis topic stack
MihirMishra36
 
Data structures stacks
maamir farooq
 
Address calculation-sort
Vasim Pathan
 
Computer Network Assignment Help
Computer Network Assignment Help
 
Searching and Sorting algorithms and working
RitikaLohiya2
 
Stacks,queues,linked-list
pinakspatel
 
PPS 7.7 RECURSION, AS A DIFFERENT WAY OF SOLVING PROBLEMS. EXAMPLE PROGRAMS
Sitamarhi Institute of Technology
 
Polynomial Function and Synthetic Division
AleczQ1414
 
Unit - 2.pdf
AravindAnand21
 
Scilab help book 2 of 2
Arun Umrao
 
Think Like Scilab and Become a Numerical Programming Expert- Notes for Beginn...
ssuserd6b1fd
 
DAA-Divide and Conquer methodology, DAA 2024
RUHULAMINHAZARIKA
 
Data Structure and Algorithms Stacks
ManishPrajapati78
 
Implementation of stacks and queues in C
HarishKrishnanP
 
Sorting and Searching in Data Structures.ppt
Vivekananda Gn
 
chapter7.ppt
Preetiverma538521
 
Ad

More from iammutex (20)

PDF
Scaling Instagram
iammutex
 
PPT
Redis深入浅出
iammutex
 
PDF
深入了解Redis
iammutex
 
PDF
NoSQL误用和常见陷阱分析
iammutex
 
PDF
MongoDB 在盛大大数据量下的应用
iammutex
 
PPT
8 minute MongoDB tutorial slide
iammutex
 
PDF
Thoughts on Transaction and Consistency Models
iammutex
 
PPTX
Rethink db&tokudb调研测试报告
iammutex
 
PDF
redis 适用场景与实现
iammutex
 
PDF
Introduction to couchdb
iammutex
 
PPTX
What every data programmer needs to know about disks
iammutex
 
PDF
Ooredis
iammutex
 
PDF
Ooredis
iammutex
 
PDF
redis运维之道
iammutex
 
PDF
Realtime hadoopsigmod2011
iammutex
 
PDF
[译]No sql生态系统
iammutex
 
PDF
Couchdb + Membase = Couchbase
iammutex
 
PDF
Redis cluster
iammutex
 
PDF
Redis cluster
iammutex
 
PDF
Hadoop introduction berlin buzzwords 2011
iammutex
 
Scaling Instagram
iammutex
 
Redis深入浅出
iammutex
 
深入了解Redis
iammutex
 
NoSQL误用和常见陷阱分析
iammutex
 
MongoDB 在盛大大数据量下的应用
iammutex
 
8 minute MongoDB tutorial slide
iammutex
 
Thoughts on Transaction and Consistency Models
iammutex
 
Rethink db&tokudb调研测试报告
iammutex
 
redis 适用场景与实现
iammutex
 
Introduction to couchdb
iammutex
 
What every data programmer needs to know about disks
iammutex
 
Ooredis
iammutex
 
Ooredis
iammutex
 
redis运维之道
iammutex
 
Realtime hadoopsigmod2011
iammutex
 
[译]No sql生态系统
iammutex
 
Couchdb + Membase = Couchbase
iammutex
 
Redis cluster
iammutex
 
Redis cluster
iammutex
 
Hadoop introduction berlin buzzwords 2011
iammutex
 

Recently uploaded (20)

PDF
STEM Education in Rural Maharashtra by Abhay Bhutada Foundation
Heera Yadav
 
PPTX
PUrposive-commmunicatuon112uospptxyynsns
yunaselle7
 
PDF
Asia’s Top 10 Hospital CEOs Transforming Healthcare in 2025
Gorman Bain Capital
 
PPT
CHAPTER 1-INTRODUCTION TO MACROECONOMICS
MurshedulArafin3
 
PPTX
d and f block elements chapter 4 in class 12
dynamicplays04
 
PPTX
Accounting for fixed ASSETS AND INTANGIBLE ASSETS
Adugna37
 
DOCX
The Political Era of Accountability: A Reflection on South Africa's Past Self...
Matthews Bantsijang
 
PDF
The Future of Electricity Pricing in South Africa by Matthews Mooketsane Bant...
Matthews Bantsijang
 
PDF
Tran Quoc Bao named in Fortune - Asia Healthcare Leadership Index 2025
Gorman Bain Capital
 
PDF
Illuminating the Future: Universal Electrification in South Africa by Matthew...
Matthews Bantsijang
 
PPTX
Judaism-group-1.pptx for reporting grade 11
ayselprettysomuch
 
PPTX
Scalping_vs_Swing_Core_Differences.at a glance pptx
Telegram Signal Copier
 
PPTX
Internal-Controls powerpoint presentation
GamePro14
 
PDF
[Cameron] Robust Inference for Regression with Clustered Data - slides (2015)...
soarnagi1
 
PPTX
LongTermDiscountRates_PensionPlaypen_JonSpain_22Jul2025_NotPW.pptx
Henry Tapper
 
PPTX
Session 1 FTP 2023 25th June 25 TRADE FINANCE
NarinderKumarBhasin
 
PPT
financial system chapter 1 overview of FS
kumlachewTegegn1
 
PPTX
Principles of Management buisness sti.pptx
CarToonMaNia5
 
PDF
Stormy Decade - A Ten-Year Retrospective on the Ukrainian Investment Landscape
Ukrainian Venture Capital and Private Equity Association
 
PPTX
Unit1_Managerial_Economics_SEM 1-PPT.pptx
RISHIRISHI87
 
STEM Education in Rural Maharashtra by Abhay Bhutada Foundation
Heera Yadav
 
PUrposive-commmunicatuon112uospptxyynsns
yunaselle7
 
Asia’s Top 10 Hospital CEOs Transforming Healthcare in 2025
Gorman Bain Capital
 
CHAPTER 1-INTRODUCTION TO MACROECONOMICS
MurshedulArafin3
 
d and f block elements chapter 4 in class 12
dynamicplays04
 
Accounting for fixed ASSETS AND INTANGIBLE ASSETS
Adugna37
 
The Political Era of Accountability: A Reflection on South Africa's Past Self...
Matthews Bantsijang
 
The Future of Electricity Pricing in South Africa by Matthews Mooketsane Bant...
Matthews Bantsijang
 
Tran Quoc Bao named in Fortune - Asia Healthcare Leadership Index 2025
Gorman Bain Capital
 
Illuminating the Future: Universal Electrification in South Africa by Matthew...
Matthews Bantsijang
 
Judaism-group-1.pptx for reporting grade 11
ayselprettysomuch
 
Scalping_vs_Swing_Core_Differences.at a glance pptx
Telegram Signal Copier
 
Internal-Controls powerpoint presentation
GamePro14
 
[Cameron] Robust Inference for Regression with Clustered Data - slides (2015)...
soarnagi1
 
LongTermDiscountRates_PensionPlaypen_JonSpain_22Jul2025_NotPW.pptx
Henry Tapper
 
Session 1 FTP 2023 25th June 25 TRADE FINANCE
NarinderKumarBhasin
 
financial system chapter 1 overview of FS
kumlachewTegegn1
 
Principles of Management buisness sti.pptx
CarToonMaNia5
 
Stormy Decade - A Ten-Year Retrospective on the Ukrainian Investment Landscape
Ukrainian Venture Capital and Private Equity Association
 
Unit1_Managerial_Economics_SEM 1-PPT.pptx
RISHIRISHI87
 

skip list

  • 2. Searching a key in a Sorted linked list Searching an element x cell *p =head ; while (p->next->key < x ) p=p->next ; return p ; Note: we return the element proceeding either the element containing x , or the smallest element with a key larger than x (if x does not exists) 7 14 21 32 37 71 85 117 - 1 1 head find(71)
  • 3. inserting a key into a Sorted linked list To insert 35 - p=find(35); CELL *p1 = (CELL *) malloc(sizeof(CELL)); p1->key=35; p1->next = p->next ; p->next = p1 ; 7 14 21 32 37 71 85 117 - 1 1 head p 35
  • 4. deleteing a key from a sorted list To delete 37 - p=find(37); CELL *p1 =p->next; p->next = p1->next ; free(p1); 7 14 21 32 37 71 85 117 - 1 1 head p p1
  • 5. A data structure for maintaing a set of keys in a sorted order --- SKIP LIST Consists of several levels. All keys appear in level 1 Each level is a sorted list. If key x appears in level i , then it also appears in all levels below i 7 14 21 32 37 71 85 117 71 37 21 7 37 21 Level 1 Level 2 Level 3 Top - 1 - 1 - 1 1 1 1
  • 6. More rules An element in level i points (via down pointer) to the element with the same key in the level below. In each level the keys - 1 and 1 appear. (In our implementation, INT_MIN and INT_MAX Top points to the smallest element in the highest level. 7 14 21 32 37 71 85 117 71 37 21 7 37 21 Level 1 Level 2 Level 3 Top - 1 - 1 - 1 1 1 1 next-pointer Down-pointer
  • 7. An empty SkipList Level 1 Top - 1 1
  • 8. Finding an element with key x p=top While(1){ while (p->next->key < x ) p=p->next; If (p->down == NULL ) return p->next p=p->down ; } Observe that we return x , if exists, or succ(x) if x is not in the SkipList 7 14 21 32 37 71 85 117 71 37 21 7 37 21 Level 1 Level 2 Level 3 Top - 1 - 1 - 1 1 1 1 next-pointer down-pointer find(117), find(118)
  • 9. Inserting new element X Determine k the number of levels in which x participates (explained later) Do find(x), and insert x to the appropriate places in the lowest k levels. (after the elements at which the search path turns down or terminates) Example - inserting 119. k =2 7 14 21 32 37 71 85 71 37 21 7 37 21 Level 1 Level 2 Level 3 Top - 1 - 1 - 1 1 1 1 next-pointer Down-pointer 119 119
  • 10. Inserting an element - cont. If k is larger than the current number of levels, add new levels (and update top) Example - inser(119) when k=4 7 14 21 32 37 71 85 71 37 21 7 37 21 Level 1 Level 2 Level 3 Top - 1 - 1 - 1 1 1 1 119 119 119 119 1 - 1
  • 11. Determining k k - the number of levels at which an element x participate. Use a random function OurRnd() --- returns 1 or 0 (True/False) with equal probability. k=1 ; While( OurRnd() ) k++ ;
  • 12. Deleteing a key x Find x in all the levels it participates, and delete it using the standard ' delete from a linked list' method. If one or more of the upper levels are empty, remove them (and update top) 7 14 21 32 37 71 85 117 71 37 21 7 37 21 Level 1 Level 2 Level 3 Top - 1 - 1 - 1 1 1 1 next-pointer down-pointer delete(71)
  • 13. Facts about SL The expected number of levels is O( log n ) (here n is the numer of elements) The expected time for insert/delete/find is O( log n ) The expected size (number of cells) is O( n )