SlideShare una empresa de Scribd logo
1 de 72
Class No.32  Data Structures http://ecomputernotes.com
Tables and Dictionaries http://ecomputernotes.com
Tables: rows & columns of information ,[object Object],[object Object],[object Object],http://ecomputernotes.com Name Address Phone Sohail Aslam 50 Zahoor Elahi Rd, Gulberg-4, Lahore 576-3205 Imran Ahmad 30-T Phase-IV, LCCHS, Lahore 572-4409 Salman Akhtar 131-D Model Town, Lahore 784-3753
Tables: rows & columns of information ,[object Object],[object Object],[object Object],[object Object],http://ecomputernotes.com
Tables: rows & columns of information ,[object Object],[object Object],http://ecomputernotes.com Name Address Phone Sohail Aslam 50 Zahoor Elahi Rd, Gulberg-4, Lahore 576-3205 Imran Ahmad 30-T Phase-IV, LCCHS, Lahore 572-4409 Salman Akhtar 131-D Model Town, Lahore 784-3753
The Table ADT: operations ,[object Object],[object Object],[object Object],http://ecomputernotes.com
How should we implement a table? ,[object Object],[object Object],[object Object],[object Object],[object Object],Our choice of representation for the Table ADT depends on the answers to the following http://ecomputernotes.com
TableNode: a key and its entry ,[object Object],“ Saleem” “ Saleem”, “124 Hawkers Lane”, “9675846” “ Yunus” “ Yunus”, “1 Apple Crescent”, “0044 1970 622455” TableNode http://ecomputernotes.com key entry
Implementation 1: unsorted sequential array ,[object Object],[object Object],[object Object],[object Object],0 … key entry 1 2 3 and so on http://ecomputernotes.com
Implementation 2:sorted sequential array ,[object Object],[object Object],[object Object],[object Object],0 … key entry 1 2 3 We can use binary search because the array elements are sorted and so on http://ecomputernotes.com
Searching an Array: Binary Search ,[object Object],[object Object],[object Object],[object Object],http://ecomputernotes.com
Binary Search ,[object Object],If ( value == middle element )    value is found  else if ( value < middle element )  search left-half of list with the same method  else    search right-half of list with the same method http://ecomputernotes.com
Case 1:   val == a[mid] val = 10 low = 0, high = 8 5 7 9 10 13 17 19 1 27 a: low high Binary Search http://ecomputernotes.com 1 2 3 4 5 6 7 0 8 mid mid = (0 + 8) / 2 = 4 10
Case 2:   val > a[mid] val = 19 low = 0, high = 8 mid = (0 + 8) / 2 = 4 Binary Search -- Example 2 5 7 9 10 1 a: mid low high http://ecomputernotes.com 13 17 19 27 1 2 3 4 5 6 7 0 8 new low new low = mid+1 = 5 13 17 19 27
Case 3:   val < a[mid] val = 7 low = 0, high = 8 mid = (0 + 8) / 2 = 4 Binary Search -- Example 3 10 13 17 19 27 a: mid low high http://ecomputernotes.com 5 7 9 1 1 2 3 4 5 6 7 0 8 new high new high = mid-1 = 3 5 7 9 1
val = 7 Binary Search -- Example 3 (cont) 5 7 9 10 13 17 19 1 27 1 2 3 4 5 6 7 0 8 a: 5 7 9 10 13 17 19 1 27 1 2 3 4 5 6 7 0 8 a: 5 7 9 10 13 17 19 1 27 1 2 3 4 5 6 7 0 8 a:
Binary Search – C++ Code ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],http://ecomputernotes.com
Binary Search:  binary tree ,[object Object],First half First half An entire sorted list First half Second half Second half http://ecomputernotes.com
Binary Search Efficiency ,[object Object],[object Object],[object Object],[object Object],[object Object],http://ecomputernotes.com
Implementation 3: linked list ,[object Object],[object Object],[object Object],[object Object],key entry and so on http://ecomputernotes.com
Implementation 4: Skip List ,[object Object],[object Object],[object Object],[object Object],[object Object],http://ecomputernotes.com
Skip List Representation ,[object Object],http://ecomputernotes.com 20 30 40 50 60 head tail
Skip List Representation ,[object Object],http://ecomputernotes.com 20 30 40 50 60 head tail
Higher Level Chains ,[object Object],[object Object],[object Object],http://ecomputernotes.com 40 50 60 head tail 20 30 26 57 level 1&2 chains
Higher Level Chains ,[object Object],[object Object],40 50 60 head tail 20 30 26 57 level 1&2 chains
Skip List: formally ,[object Object],[object Object],[object Object],[object Object],[object Object]
Lecture No.38 Data Structure Dr. Sohail Aslam
Skip List: formally 56 64 78  31 34 44  12 23 26 S 0 64  31 34  23 S 1  31  S 2   S 3
Skip List: Search ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Skip List: Search ,[object Object],S 0 S 1 S 2 S 3  31  64  31 34  23 56 64 78  31 34 44  12 23 26  
[object Object],[object Object],[object Object],Skip List: Insertion
[object Object],[object Object],[object Object],Skip List: Insertion
[object Object],Skip List: Insertion   10 36   23 23   S 0 S 1 S 2 p 0 p 1 p 2   S 0 S 1 S 2 S 3   10 36 23 15   15   23 15
Randomized Algorithms ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Skip List: Deletion ,[object Object],[object Object],[object Object],[object Object]
Skip List: Deletion ,[object Object],  S 0 S 1 S 2 S 3   45 12 23 34   34   23 34 p 0 p 1 p 2   45 12   23 23   S 0 S 1 S 2
Skip List: Implementation   S 0 S 1 S 2 S 3   45 12 23 34   34   23 34
Implementation: TowerNode ,[object Object],[object Object],[object Object],40 50 60 head tail 20 30 26 57 Tower Node
Implementation: QuadNode ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],x quad-node
Skip Lists with Quad Nodes 56 64 78  31 34 44  12 23 26    31  64  31 34  23 S 0 S 1 S 2 S 3
Performance of Skip Lists ,[object Object],[object Object],[object Object],[object Object]
Implementation 5: AVL tree ,[object Object],[object Object],[object Object],[object Object],and so on key entry key entry key entry key entry
Anything better? ,[object Object],[object Object]
[object Object],[object Object],[object Object],Implementation 6: Hashing key entry Key hash function array index 4 10 123
[object Object],[object Object],[object Object],Hashing key entry 4 10 123 All are constant time (1) !
Hashing ,[object Object],[object Object]
Example: fruits ,[object Object],[object Object],kiwi banana watermelon apple mango cantaloupe grapes strawberry 0 1 2 3 4 5 6 7 8 9
Example ,[object Object],[object Object],kiwi banana watermelon apple mango cantaloupe grapes strawberry 0 1 2 3 4 5 6 7 8 9
Example ,[object Object],[object Object],kiwi banana watermelon apple mango cantaloupe grapes strawberry 0 1 2 3 4 5 6 7 8 9
Example Hash Functions ,[object Object],[object Object],TableSize ABC h Example TableSize i str str h length i )% 67 66 65 ( ) ( : % ] [ ) ( 1 0               
Finding the hash function ,[object Object],[object Object]
Example Hash Functions ,[object Object],T b b b ABC h Example T b i str str h length i i )% 67 66 65 ( ) ( : % ] [ ) ( 2 1 0 1 0                
Example Hash Functions ,[object Object],[object Object],[object Object]
Collision ,[object Object],[object Object],•  Now what? hash(&quot;honeydew&quot;) = 6 kiwi banana watermelon apple mango cantaloupe grapes strawberry 0 1 2 3 4 5 6 7 8 9
Collision ,[object Object],[object Object],[object Object]
Solution for Handling collisions ,[object Object],[object Object],[object Object]
Solution for Handling collisions ,[object Object],[object Object]
Solution for Handling collisions ,[object Object]
Solution 1: Open Addressing ,[object Object],[object Object],[object Object]
Linear Probing ,[object Object],[object Object]
Linear Probing: insert ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],seagull robin sparrow hawk bluejay owl . . . 141 142 143 144 145 146 147 148 . . .
Linear Probing: insert ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],robin sparrow hawk seagull bluejay owl . . . 141 142 143 144 145 146 147 148 . . .
Linear Probing: insert ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],robin sparrow hawk seagull bluejay owl . . . 141 142 143 144 145 146 147 148
Linear Probing: find ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],robin sparrow hawk seagull bluejay owl . . . 141 142 143 144 145 146 147 148 . . .
Linear Probing and Deletion ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Clustering ,[object Object],[object Object],[object Object],[object Object]
Quadratic Probing ,[object Object],[object Object],[object Object],[object Object],[object Object]
Collision resolution: chaining ,[object Object],[object Object],4 10 123 No need to change position! key entry key entry key entry key entry key entry
Collision resolution: chaining ,[object Object],[object Object],[object Object],[object Object],[object Object],4 10 123 key entry key entry key entry key entry key entry
Applications of Hashing ,[object Object],[object Object]
Applications of Hashing ,[object Object],[object Object]
When is hashing suitable? ,[object Object],[object Object],[object Object],[object Object]

Más contenido relacionado

La actualidad más candente

Top down and botttom up 2 LATEST.
Top down     and botttom up 2 LATEST.Top down     and botttom up 2 LATEST.
Top down and botttom up 2 LATEST.
Gerwin Ocsena
 
Lecture 2 coding_principles
Lecture 2 coding_principlesLecture 2 coding_principles
Lecture 2 coding_principles
moduledesign
 
23 stacks-queues-deques
23 stacks-queues-deques23 stacks-queues-deques
23 stacks-queues-deques
Rishabh Jindal
 

La actualidad más candente (20)

Top down and botttom up 2 LATEST.
Top down     and botttom up 2 LATEST.Top down     and botttom up 2 LATEST.
Top down and botttom up 2 LATEST.
 
Left factor put
Left factor putLeft factor put
Left factor put
 
Skip lists (Advance Data structure)
Skip lists (Advance Data structure)Skip lists (Advance Data structure)
Skip lists (Advance Data structure)
 
Top down parsing(sid) (1)
Top down parsing(sid) (1)Top down parsing(sid) (1)
Top down parsing(sid) (1)
 
1. 4 Singly linked list deletion
1. 4 Singly linked list deletion1. 4 Singly linked list deletion
1. 4 Singly linked list deletion
 
6
66
6
 
1. 5 Circular singly linked list
1. 5 Circular singly linked list1. 5 Circular singly linked list
1. 5 Circular singly linked list
 
Python for Scientific Computing
Python for Scientific ComputingPython for Scientific Computing
Python for Scientific Computing
 
LR Parsing
LR ParsingLR Parsing
LR Parsing
 
Lecture 2 coding_principles
Lecture 2 coding_principlesLecture 2 coding_principles
Lecture 2 coding_principles
 
Linked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory AllocationLinked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory Allocation
 
Lecture 2 coding_principles
Lecture 2 coding_principlesLecture 2 coding_principles
Lecture 2 coding_principles
 
ALF 5 - Parser Top-Down
ALF 5 - Parser Top-DownALF 5 - Parser Top-Down
ALF 5 - Parser Top-Down
 
1. 2 Singly Linked List
1. 2 Singly Linked List1. 2 Singly Linked List
1. 2 Singly Linked List
 
List
ListList
List
 
Operation on stack
Operation on stackOperation on stack
Operation on stack
 
Phpcompilerinternals 090824022750-phpapp02
Phpcompilerinternals 090824022750-phpapp02Phpcompilerinternals 090824022750-phpapp02
Phpcompilerinternals 090824022750-phpapp02
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Java 8, lambdas, generics: How to survive? - NYC Java Meetup Group
Java 8, lambdas, generics: How to survive? - NYC Java Meetup GroupJava 8, lambdas, generics: How to survive? - NYC Java Meetup Group
Java 8, lambdas, generics: How to survive? - NYC Java Meetup Group
 
23 stacks-queues-deques
23 stacks-queues-deques23 stacks-queues-deques
23 stacks-queues-deques
 

Similar a Computer notes - Binary Search

computer notes - Data Structures - 34
computer notes - Data Structures - 34computer notes - Data Structures - 34
computer notes - Data Structures - 34
ecomputernotes
 
computer notes - Data Structures - 35
computer notes - Data Structures - 35computer notes - Data Structures - 35
computer notes - Data Structures - 35
ecomputernotes
 

Similar a Computer notes - Binary Search (20)

computer notes - Data Structures - 34
computer notes - Data Structures - 34computer notes - Data Structures - 34
computer notes - Data Structures - 34
 
List,Stacks and Queues.pptx
List,Stacks and Queues.pptxList,Stacks and Queues.pptx
List,Stacks and Queues.pptx
 
Skip list vinay khimsuriya_200430723005
Skip list vinay khimsuriya_200430723005Skip list vinay khimsuriya_200430723005
Skip list vinay khimsuriya_200430723005
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queue
 
Address calculation-sort
Address calculation-sortAddress calculation-sort
Address calculation-sort
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queue
 
Stacks,queues,linked-list
Stacks,queues,linked-listStacks,queues,linked-list
Stacks,queues,linked-list
 
Data Structure and Algorithm Lesson 2.pptx
Data Structure and Algorithm Lesson 2.pptxData Structure and Algorithm Lesson 2.pptx
Data Structure and Algorithm Lesson 2.pptx
 
Chapter 15 Lists
Chapter 15 ListsChapter 15 Lists
Chapter 15 Lists
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
 
Data structure
Data  structureData  structure
Data structure
 
Lecture 02: Preliminaries of Data structure
Lecture 02: Preliminaries of Data structureLecture 02: Preliminaries of Data structure
Lecture 02: Preliminaries of Data structure
 
Computer notes - Hashing
Computer notes - HashingComputer notes - Hashing
Computer notes - Hashing
 
1 D Arrays in C++
1 D Arrays in C++1 D Arrays in C++
1 D Arrays in C++
 
computer notes - Data Structures - 35
computer notes - Data Structures - 35computer notes - Data Structures - 35
computer notes - Data Structures - 35
 
Operations on linked list
Operations on linked listOperations on linked list
Operations on linked list
 
GE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_NotesGE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_Notes
 
Data Structures Design Notes.pdf
Data Structures Design Notes.pdfData Structures Design Notes.pdf
Data Structures Design Notes.pdf
 
Unit ii(dsc++)
Unit ii(dsc++)Unit ii(dsc++)
Unit ii(dsc++)
 

Más de ecomputernotes

computer notes - Data Structures - 30
computer notes - Data Structures - 30computer notes - Data Structures - 30
computer notes - Data Structures - 30
ecomputernotes
 
computer notes - Data Structures - 39
computer notes - Data Structures - 39computer notes - Data Structures - 39
computer notes - Data Structures - 39
ecomputernotes
 
computer notes - Data Structures - 11
computer notes - Data Structures - 11computer notes - Data Structures - 11
computer notes - Data Structures - 11
ecomputernotes
 
computer notes - Data Structures - 20
computer notes - Data Structures - 20computer notes - Data Structures - 20
computer notes - Data Structures - 20
ecomputernotes
 
computer notes - Data Structures - 15
computer notes - Data Structures - 15computer notes - Data Structures - 15
computer notes - Data Structures - 15
ecomputernotes
 
Computer notes - Including Constraints
Computer notes - Including ConstraintsComputer notes - Including Constraints
Computer notes - Including Constraints
ecomputernotes
 
Computer notes - Date time Functions
Computer notes - Date time FunctionsComputer notes - Date time Functions
Computer notes - Date time Functions
ecomputernotes
 
Computer notes - Subqueries
Computer notes - SubqueriesComputer notes - Subqueries
Computer notes - Subqueries
ecomputernotes
 
Computer notes - Other Database Objects
Computer notes - Other Database ObjectsComputer notes - Other Database Objects
Computer notes - Other Database Objects
ecomputernotes
 
computer notes - Data Structures - 28
computer notes - Data Structures - 28computer notes - Data Structures - 28
computer notes - Data Structures - 28
ecomputernotes
 
computer notes - Data Structures - 19
computer notes - Data Structures - 19computer notes - Data Structures - 19
computer notes - Data Structures - 19
ecomputernotes
 
computer notes - Data Structures - 31
computer notes - Data Structures - 31computer notes - Data Structures - 31
computer notes - Data Structures - 31
ecomputernotes
 
computer notes - Data Structures - 4
computer notes - Data Structures - 4computer notes - Data Structures - 4
computer notes - Data Structures - 4
ecomputernotes
 
computer notes - Data Structures - 13
computer notes - Data Structures - 13computer notes - Data Structures - 13
computer notes - Data Structures - 13
ecomputernotes
 
Computer notes - Advanced Subqueries
Computer notes -   Advanced SubqueriesComputer notes -   Advanced Subqueries
Computer notes - Advanced Subqueries
ecomputernotes
 
Computer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group FunctionsComputer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group Functions
ecomputernotes
 
computer notes - Data Structures - 16
computer notes - Data Structures - 16computer notes - Data Structures - 16
computer notes - Data Structures - 16
ecomputernotes
 
computer notes - Data Structures - 22
computer notes - Data Structures - 22computer notes - Data Structures - 22
computer notes - Data Structures - 22
ecomputernotes
 
computer notes - Data Structures - 36
computer notes - Data Structures - 36computer notes - Data Structures - 36
computer notes - Data Structures - 36
ecomputernotes
 
Computer notes - Enhancements to the GROUP BY Clause
Computer notes - Enhancements to the GROUP BY ClauseComputer notes - Enhancements to the GROUP BY Clause
Computer notes - Enhancements to the GROUP BY Clause
ecomputernotes
 

Más de ecomputernotes (20)

computer notes - Data Structures - 30
computer notes - Data Structures - 30computer notes - Data Structures - 30
computer notes - Data Structures - 30
 
computer notes - Data Structures - 39
computer notes - Data Structures - 39computer notes - Data Structures - 39
computer notes - Data Structures - 39
 
computer notes - Data Structures - 11
computer notes - Data Structures - 11computer notes - Data Structures - 11
computer notes - Data Structures - 11
 
computer notes - Data Structures - 20
computer notes - Data Structures - 20computer notes - Data Structures - 20
computer notes - Data Structures - 20
 
computer notes - Data Structures - 15
computer notes - Data Structures - 15computer notes - Data Structures - 15
computer notes - Data Structures - 15
 
Computer notes - Including Constraints
Computer notes - Including ConstraintsComputer notes - Including Constraints
Computer notes - Including Constraints
 
Computer notes - Date time Functions
Computer notes - Date time FunctionsComputer notes - Date time Functions
Computer notes - Date time Functions
 
Computer notes - Subqueries
Computer notes - SubqueriesComputer notes - Subqueries
Computer notes - Subqueries
 
Computer notes - Other Database Objects
Computer notes - Other Database ObjectsComputer notes - Other Database Objects
Computer notes - Other Database Objects
 
computer notes - Data Structures - 28
computer notes - Data Structures - 28computer notes - Data Structures - 28
computer notes - Data Structures - 28
 
computer notes - Data Structures - 19
computer notes - Data Structures - 19computer notes - Data Structures - 19
computer notes - Data Structures - 19
 
computer notes - Data Structures - 31
computer notes - Data Structures - 31computer notes - Data Structures - 31
computer notes - Data Structures - 31
 
computer notes - Data Structures - 4
computer notes - Data Structures - 4computer notes - Data Structures - 4
computer notes - Data Structures - 4
 
computer notes - Data Structures - 13
computer notes - Data Structures - 13computer notes - Data Structures - 13
computer notes - Data Structures - 13
 
Computer notes - Advanced Subqueries
Computer notes -   Advanced SubqueriesComputer notes -   Advanced Subqueries
Computer notes - Advanced Subqueries
 
Computer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group FunctionsComputer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group Functions
 
computer notes - Data Structures - 16
computer notes - Data Structures - 16computer notes - Data Structures - 16
computer notes - Data Structures - 16
 
computer notes - Data Structures - 22
computer notes - Data Structures - 22computer notes - Data Structures - 22
computer notes - Data Structures - 22
 
computer notes - Data Structures - 36
computer notes - Data Structures - 36computer notes - Data Structures - 36
computer notes - Data Structures - 36
 
Computer notes - Enhancements to the GROUP BY Clause
Computer notes - Enhancements to the GROUP BY ClauseComputer notes - Enhancements to the GROUP BY Clause
Computer notes - Enhancements to the GROUP BY Clause
 

Último

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Último (20)

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 

Computer notes - Binary Search

  • 1. Class No.32 Data Structures http://ecomputernotes.com
  • 2. Tables and Dictionaries http://ecomputernotes.com
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. Case 1: val == a[mid] val = 10 low = 0, high = 8 5 7 9 10 13 17 19 1 27 a: low high Binary Search http://ecomputernotes.com 1 2 3 4 5 6 7 0 8 mid mid = (0 + 8) / 2 = 4 10
  • 14. Case 2: val > a[mid] val = 19 low = 0, high = 8 mid = (0 + 8) / 2 = 4 Binary Search -- Example 2 5 7 9 10 1 a: mid low high http://ecomputernotes.com 13 17 19 27 1 2 3 4 5 6 7 0 8 new low new low = mid+1 = 5 13 17 19 27
  • 15. Case 3: val < a[mid] val = 7 low = 0, high = 8 mid = (0 + 8) / 2 = 4 Binary Search -- Example 3 10 13 17 19 27 a: mid low high http://ecomputernotes.com 5 7 9 1 1 2 3 4 5 6 7 0 8 new high new high = mid-1 = 3 5 7 9 1
  • 16. val = 7 Binary Search -- Example 3 (cont) 5 7 9 10 13 17 19 1 27 1 2 3 4 5 6 7 0 8 a: 5 7 9 10 13 17 19 1 27 1 2 3 4 5 6 7 0 8 a: 5 7 9 10 13 17 19 1 27 1 2 3 4 5 6 7 0 8 a:
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27. Lecture No.38 Data Structure Dr. Sohail Aslam
  • 28. Skip List: formally 56 64 78  31 34 44  12 23 26 S 0 64  31 34  23 S 1  31  S 2   S 3
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37. Skip List: Implementation   S 0 S 1 S 2 S 3   45 12 23 34   34   23 34
  • 38.
  • 39.
  • 40. Skip Lists with Quad Nodes 56 64 78  31 34 44  12 23 26    31  64  31 34  23 S 0 S 1 S 2 S 3
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.

Notas del editor

  1. Start of lecture 38.
  2. End of Lecture 38
  3. Start lecture 39
  4. End of lecture 39, Start of lecture 40.
  5. End of lecture 40.
  6. Start of 41.
  7. Start lecture 41
  8. End of lecture 41. Start of lecture 42.
  9. End of Lecture 42.
  10. Start of lecture 43 after animation.