SlideShare a Scribd company logo
1 of 23
SIGNIFICANCE
• PVEB tree is used to reduce the time complexity of operations in a
dynamic array.
• The complexity of finding minimum, maximum, predecessor and
successor are significantly reduced in this tree.
• But the cost of insert, delete and member query is slightly greater than
normal arrays since normal arrays can do these operations in O(1).
• The Time Complexity of the tree is the height of the tree O(log(log(n)).
1
6
summary
u
cluster
Keys
(Initialised only in
leaf nodes)
(Both initialised in non-
leaf nodes)
STRUCTURE OF THE NODE
typedef struct node
{
int u;
struct node *summary;
struct node **cluster;
int *keys;
}node;
node *createNode()
{
node *temp = (node *)malloc(sizeof(node));
temp->u = 0;
temp->summary = NULL;
temp->cluster = NULL;
return temp;
}
CreateNode:
• Creates nodes and attaches with the tree.
• For leaf nodes, summary and cluster pointers are set to NULL and
keys array is initialised.
• For non-leaf nodes, summary and cluster pointers are allocated
space and keys array is not initialised
CreateTree:
node *createTree(int u)
{
if(u == 2)
{
node *temp = createNode();
temp->u = u;
temp->summary = NULL;
temp->cluster = NULL;
temp->keys = (int *)malloc(8);
temp->keys[0] = 0;
temp->keys[1] = 0;
return temp;
}
int i;
node *temp = createNode();
temp->u = u;
temp->summary = createTree((int)sqrt(u));
temp->cluster = (node **)malloc(sizeof(node *) * (int)sqrt(u));
for(i = 0;i < (int)sqrt(u);i++){
temp->cluster[i] = createTree((int)sqrt(u));
}
return temp;
}
16
4
4
4
4
4
2
0 0
2
0 0
2
0 0
2
0 0
2
0 0
2
0 0
2
0 0
2
0 0
2
0 0
2
0 0
2
0 0
2
0 0
2
0 0
2
0 0
2
0 0
summary
u cluster
The Tree after calling
createTree()
int high(int x,int u)
{
return (int)floor(x/sqrt(u));
}
int low(int x,int u)
{
return x%(int)ceil(sqrt(u));
}
• high(x) is used to find the cluster number where the
element is present.
• low(x) is used to find the position at which the element
is present in the particular cluster returned by high(x).
• For ex, in a 16 element array, the clusters are {0,1,2,3},
{4,5,6,7}, {8,9,10,11}, {12,13,14,15}.
• Element 9 is present in cluster number 2 (9/root(16)),
the position of 9 in that cluster is 1 (9%root(16)).
High and Low
• Traverse to the bottom of the tree where u = 2 and set the particular bit to 1 and
recursively call summary pointer and modify it.
• We use high() and low() to find cluster number and offset of the number.
• We pass low(x) instead key in every call because the sub cluster (8,9,10,11) will be
considered as (0,1,2,3). So, the key value differs at every level.
Insert
void insert(node *head,int key)
{
if(head->u == 2)
{
head->keys[key] = 1;
return;
}
insert(head->cluster[high(key,head->u)],low(key,head->u));
insert(head->summary, high(key,head->u));
return;
}
Insert
16
4
4
4
4
4
2
1 1
2
1 1
2
0 1
2
0 1
2
0 0
2
1 1
2
1 1
2
1 1
2
0 1
2
0 0
2
0 0
2
0 0
2
0 1
2
0 0
2
1 1
summary
u cluster
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
The tree after inserting
2,3,4,5,7,14,15
bool isMember(node *head,int key)
{
if(head->u == 2)
{
if(head->keys[key] == 1)
return true;
return false;
}
return isMember(head->cluster[high(key,head->u)],low(key,head->u));
}
• Traverse to the leaf node and check if the bit is set and return.
IsMember
• Traverse to the leaf node and set the bit to 0.
• Check if any other value is set in the same cluster. If yes, no need to
update the summary value.
• If no, change the summary value to 0.
Delete
void del(node *head,int key){
if(head->u == 2){
head->keys[key] = 0;
return;
}
del(head->cluster[high(key,head->u)],low(key,head->u));
int isMemberAvailable = 0,i;
int hi = high(key,head->u);
int sq = (int)sqrt(head->u);
for(i = hi*sq; i < (hi+1)*sq; i++){
if(isMember(head,i))
{
isMemberAvailable = 1;
break;
}
}
if(isMemberAvailable == 0)
{
del(head->summary,high(key,head->u));
}}
Delete
16
4
4
4
4
4
2
1 1
2
1 1
2
0 1
2
0 1
2
0 0
2
1 1
2
1 1
2
1 1
2
0 1
2
0 0
2
0 0
2
0 0
2
0 1
2
0 0
2
0 1
summary
u cluster
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
The tree after deleting
14
• Traverse through summary nodes and check whether the first bit is set i.e. if any number is present in
the first half then check the second bit.
• If first bit is set, move to the cluster which is represented by that bit and repeat the same process until
you reach the leaf node and return the value.
• The expression index + (clust * (int)sqrt(head->u)) is used to calculate the actual value.
• The value 9 is represented as 1 in the leaf node, as 1 in a level above and as 9 in the head node.
• This can be calculated by cluster_no * sqrt(u) + offset. The cluster_no for 9 in the level below head is 0, u
is 4 and index is 1 => 1 + (0 * 2) = 1.
• In the head level, cluster_no = 2, u is 16 and index is the 1 (from the result of the level below). => 1 + (2
* 4) = 9.
Minimum
int minimum(node *head)
{
if(head->u == 2)
{
if(head->keys[0] == 1)
return 0;
else if (head->keys[1] == 1)
return 1;
return -1;
}
int clust = minimum(head->summary);
if(clust != -1)
{
int index = minimum(head->cluster[clust]);
return index + (clust * (int)sqrt(head->u));
}
}
Minimum
int maximum(node *head)
{
if(head->u == 2)
{
if(head->keys[1] == 1)
return 1;
else if (head->keys[0] == 1)
return 0;
return -1;
}
int clust = maximum(head->summary);
if(clust != -1)
{
int index = maximum(head->cluster[clust]);
return index + (clust * (int)sqrt(head->u));
}
}
The same logic as minimum but we check for
the second bit first and then first bit next which
do the traversal from the end.
Maximum
16
4
4
4
4
4
2
1 1
2
1 1
2
0 1
2
0 1
2
0 0
2
1 1
2
1 1
2
1 1
2
0 1
2
0 0
2
0 0
2
0 0
2
0 1
2
0 0
2
0 1
summary
u cluster
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Minimum is 2 and
Maximum is 15
Orange arrow indicates the flow of
minimum function
• We traverse to the leaf node and check whether our key is the second bit and there is a first bit set. If
yes, we need not do any calculation, we just return the value by calculating the value at each level
using the expression (high(key,head->u) * (int)sqrt(head->u)) + pred.
• If no immediate predecessor is found, we find the maximum of the left side clusters.
• Similarly, for successor we find if there are immediate successor else, we find the minimum of the
right-side clusters and return it.
Predecessor and Successor
int predecessor(node *head,int key){
if(head->u == 2){
if(key == 1 && head->keys[0] == 1)
return 0;
return -1;
}
int pred = predecessor(head->cluster[high(key,head->u)],low(key,head->u));
if (pred == -1){
int pred_clust = predecessor(head->summary,high(key,head->u));
if(pred_clust == -1)
{
return -1;
}
int max = maximum(head->cluster[pred_clust]);
return max + (pred_clust * (int)sqrt(head->u));
}
else
{
return (high(key,head->u) * (int)sqrt(head->u)) + pred;
}}
Predecessor
int successor(node *head,int key){
if(head->u == 2){
if(key == 0 && head->keys[1] == 1)
return 1;
return -1;
}
int sucsr = successor(head->cluster[high(key,head->u)],low(key,head->u));
if (sucsr == -1){
int pred_clust = successor(head->summary,high(key,head->u));
if(pred_clust == -1)
{
return -1;
}
int min = minimum(head->cluster[pred_clust]);
return min + (pred_clust * (int)sqrt(head->u));
}
else
{
return (high(key,head->u) * (int)sqrt(head->u)) + sucsr;
}}
Successor
THANK YOU
- Santhosh A

More Related Content

What's hot

Direct Memory Access(DMA)
Direct Memory Access(DMA)Direct Memory Access(DMA)
Direct Memory Access(DMA)Page Maker
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureYaksh Jethva
 
Stack and its usage in assembly language
Stack and its usage in assembly language Stack and its usage in assembly language
Stack and its usage in assembly language Usman Bin Saad
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]Muhammad Hammad Waseem
 
Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure Anand Ingle
 
3.9 external sorting
3.9 external sorting3.9 external sorting
3.9 external sortingKrish_ver2
 
Microprocessor 8086 instructions
Microprocessor 8086 instructionsMicroprocessor 8086 instructions
Microprocessor 8086 instructionsRavi Anand
 
Stack_Application_Infix_Prefix.pptx
Stack_Application_Infix_Prefix.pptxStack_Application_Infix_Prefix.pptx
Stack_Application_Infix_Prefix.pptxsandeep54552
 
Addressing mode Computer Architecture
Addressing mode  Computer ArchitectureAddressing mode  Computer Architecture
Addressing mode Computer ArchitectureHaris456
 
Selection sort
Selection sortSelection sort
Selection sortstella D
 
Pipeline hazards | Structural Hazard, Data Hazard & Control Hazard
Pipeline hazards | Structural Hazard, Data Hazard & Control HazardPipeline hazards | Structural Hazard, Data Hazard & Control Hazard
Pipeline hazards | Structural Hazard, Data Hazard & Control Hazardbabuece
 

What's hot (20)

Direct Memory Access(DMA)
Direct Memory Access(DMA)Direct Memory Access(DMA)
Direct Memory Access(DMA)
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data Structure
 
Heaps
HeapsHeaps
Heaps
 
Stack and its usage in assembly language
Stack and its usage in assembly language Stack and its usage in assembly language
Stack and its usage in assembly language
 
Heapsort ppt
Heapsort pptHeapsort ppt
Heapsort ppt
 
Direct memory access
Direct memory accessDirect memory access
Direct memory access
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 
Quick sort
Quick sortQuick sort
Quick sort
 
Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure
 
3.9 external sorting
3.9 external sorting3.9 external sorting
3.9 external sorting
 
DS ppt
DS pptDS ppt
DS ppt
 
Microprocessor 8086 instructions
Microprocessor 8086 instructionsMicroprocessor 8086 instructions
Microprocessor 8086 instructions
 
Singly & Circular Linked list
Singly & Circular Linked listSingly & Circular Linked list
Singly & Circular Linked list
 
Linked list
Linked listLinked list
Linked list
 
Stack_Application_Infix_Prefix.pptx
Stack_Application_Infix_Prefix.pptxStack_Application_Infix_Prefix.pptx
Stack_Application_Infix_Prefix.pptx
 
Addressing mode Computer Architecture
Addressing mode  Computer ArchitectureAddressing mode  Computer Architecture
Addressing mode Computer Architecture
 
Selection sort
Selection sortSelection sort
Selection sort
 
Pipeline hazards | Structural Hazard, Data Hazard & Control Hazard
Pipeline hazards | Structural Hazard, Data Hazard & Control HazardPipeline hazards | Structural Hazard, Data Hazard & Control Hazard
Pipeline hazards | Structural Hazard, Data Hazard & Control Hazard
 
Selection sort
Selection sortSelection sort
Selection sort
 

Similar to PVEB Tree.pptx

Advanced data structure
Advanced data structureAdvanced data structure
Advanced data structureShakil Ahmed
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithmspppepito86
 
Classical programming interview questions
Classical programming interview questionsClassical programming interview questions
Classical programming interview questionsGradeup
 
linkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxlinkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxMeghaKulkarni27
 
(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sortingFadhil Ismail
 
Answers withexplanations
Answers withexplanationsAnswers withexplanations
Answers withexplanationsGopi Saiteja
 
pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqPradeep Bisht
 
3.8 quick sort
3.8 quick sort3.8 quick sort
3.8 quick sortKrish_ver2
 
Ee693 sept2014quizgt1
Ee693 sept2014quizgt1Ee693 sept2014quizgt1
Ee693 sept2014quizgt1Gopi Saiteja
 
VCE Unit 02 (1).pptx
VCE Unit 02 (1).pptxVCE Unit 02 (1).pptx
VCE Unit 02 (1).pptxskilljiolms
 
(a) There are three ways to traverse a binary tree pre-order, in-or.docx
(a) There are three ways to traverse a binary tree pre-order, in-or.docx(a) There are three ways to traverse a binary tree pre-order, in-or.docx
(a) There are three ways to traverse a binary tree pre-order, in-or.docxajoy21
 
ICPC 2015, Tsukuba : Unofficial Commentary
ICPC 2015, Tsukuba: Unofficial CommentaryICPC 2015, Tsukuba: Unofficial Commentary
ICPC 2015, Tsukuba : Unofficial Commentaryirrrrr
 
Selection sort
Selection sortSelection sort
Selection sortasra khan
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.pptLegesseSamuel
 

Similar to PVEB Tree.pptx (20)

Advanced data structure
Advanced data structureAdvanced data structure
Advanced data structure
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
 
Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
 
Classical programming interview questions
Classical programming interview questionsClassical programming interview questions
Classical programming interview questions
 
linkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxlinkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptx
 
(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting
 
Answers withexplanations
Answers withexplanationsAnswers withexplanations
Answers withexplanations
 
Singly linked list
Singly linked listSingly linked list
Singly linked list
 
pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conq
 
3.8 quick sort
3.8 quick sort3.8 quick sort
3.8 quick sort
 
Sorting
SortingSorting
Sorting
 
Ee693 sept2014quizgt1
Ee693 sept2014quizgt1Ee693 sept2014quizgt1
Ee693 sept2014quizgt1
 
Unit II Data Structure 2hr topic - List - Operations.pptx
Unit II  Data Structure 2hr topic - List - Operations.pptxUnit II  Data Structure 2hr topic - List - Operations.pptx
Unit II Data Structure 2hr topic - List - Operations.pptx
 
VCE Unit 02 (1).pptx
VCE Unit 02 (1).pptxVCE Unit 02 (1).pptx
VCE Unit 02 (1).pptx
 
Trees
TreesTrees
Trees
 
(a) There are three ways to traverse a binary tree pre-order, in-or.docx
(a) There are three ways to traverse a binary tree pre-order, in-or.docx(a) There are three ways to traverse a binary tree pre-order, in-or.docx
(a) There are three ways to traverse a binary tree pre-order, in-or.docx
 
ICPC 2015, Tsukuba : Unofficial Commentary
ICPC 2015, Tsukuba: Unofficial CommentaryICPC 2015, Tsukuba: Unofficial Commentary
ICPC 2015, Tsukuba : Unofficial Commentary
 
Selection sort
Selection sortSelection sort
Selection sort
 
Linked list
Linked listLinked list
Linked list
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.ppt
 

Recently uploaded

Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Recently uploaded (20)

Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

PVEB Tree.pptx

  • 1.
  • 2. SIGNIFICANCE • PVEB tree is used to reduce the time complexity of operations in a dynamic array. • The complexity of finding minimum, maximum, predecessor and successor are significantly reduced in this tree. • But the cost of insert, delete and member query is slightly greater than normal arrays since normal arrays can do these operations in O(1). • The Time Complexity of the tree is the height of the tree O(log(log(n)).
  • 3. 1 6 summary u cluster Keys (Initialised only in leaf nodes) (Both initialised in non- leaf nodes) STRUCTURE OF THE NODE
  • 4. typedef struct node { int u; struct node *summary; struct node **cluster; int *keys; }node; node *createNode() { node *temp = (node *)malloc(sizeof(node)); temp->u = 0; temp->summary = NULL; temp->cluster = NULL; return temp; } CreateNode:
  • 5. • Creates nodes and attaches with the tree. • For leaf nodes, summary and cluster pointers are set to NULL and keys array is initialised. • For non-leaf nodes, summary and cluster pointers are allocated space and keys array is not initialised CreateTree:
  • 6. node *createTree(int u) { if(u == 2) { node *temp = createNode(); temp->u = u; temp->summary = NULL; temp->cluster = NULL; temp->keys = (int *)malloc(8); temp->keys[0] = 0; temp->keys[1] = 0; return temp; } int i; node *temp = createNode(); temp->u = u; temp->summary = createTree((int)sqrt(u)); temp->cluster = (node **)malloc(sizeof(node *) * (int)sqrt(u)); for(i = 0;i < (int)sqrt(u);i++){ temp->cluster[i] = createTree((int)sqrt(u)); } return temp; }
  • 7. 16 4 4 4 4 4 2 0 0 2 0 0 2 0 0 2 0 0 2 0 0 2 0 0 2 0 0 2 0 0 2 0 0 2 0 0 2 0 0 2 0 0 2 0 0 2 0 0 2 0 0 summary u cluster The Tree after calling createTree()
  • 8. int high(int x,int u) { return (int)floor(x/sqrt(u)); } int low(int x,int u) { return x%(int)ceil(sqrt(u)); } • high(x) is used to find the cluster number where the element is present. • low(x) is used to find the position at which the element is present in the particular cluster returned by high(x). • For ex, in a 16 element array, the clusters are {0,1,2,3}, {4,5,6,7}, {8,9,10,11}, {12,13,14,15}. • Element 9 is present in cluster number 2 (9/root(16)), the position of 9 in that cluster is 1 (9%root(16)). High and Low
  • 9. • Traverse to the bottom of the tree where u = 2 and set the particular bit to 1 and recursively call summary pointer and modify it. • We use high() and low() to find cluster number and offset of the number. • We pass low(x) instead key in every call because the sub cluster (8,9,10,11) will be considered as (0,1,2,3). So, the key value differs at every level. Insert
  • 10. void insert(node *head,int key) { if(head->u == 2) { head->keys[key] = 1; return; } insert(head->cluster[high(key,head->u)],low(key,head->u)); insert(head->summary, high(key,head->u)); return; } Insert
  • 11. 16 4 4 4 4 4 2 1 1 2 1 1 2 0 1 2 0 1 2 0 0 2 1 1 2 1 1 2 1 1 2 0 1 2 0 0 2 0 0 2 0 0 2 0 1 2 0 0 2 1 1 summary u cluster 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 The tree after inserting 2,3,4,5,7,14,15
  • 12. bool isMember(node *head,int key) { if(head->u == 2) { if(head->keys[key] == 1) return true; return false; } return isMember(head->cluster[high(key,head->u)],low(key,head->u)); } • Traverse to the leaf node and check if the bit is set and return. IsMember
  • 13. • Traverse to the leaf node and set the bit to 0. • Check if any other value is set in the same cluster. If yes, no need to update the summary value. • If no, change the summary value to 0. Delete
  • 14. void del(node *head,int key){ if(head->u == 2){ head->keys[key] = 0; return; } del(head->cluster[high(key,head->u)],low(key,head->u)); int isMemberAvailable = 0,i; int hi = high(key,head->u); int sq = (int)sqrt(head->u); for(i = hi*sq; i < (hi+1)*sq; i++){ if(isMember(head,i)) { isMemberAvailable = 1; break; } } if(isMemberAvailable == 0) { del(head->summary,high(key,head->u)); }} Delete
  • 15. 16 4 4 4 4 4 2 1 1 2 1 1 2 0 1 2 0 1 2 0 0 2 1 1 2 1 1 2 1 1 2 0 1 2 0 0 2 0 0 2 0 0 2 0 1 2 0 0 2 0 1 summary u cluster 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 The tree after deleting 14
  • 16. • Traverse through summary nodes and check whether the first bit is set i.e. if any number is present in the first half then check the second bit. • If first bit is set, move to the cluster which is represented by that bit and repeat the same process until you reach the leaf node and return the value. • The expression index + (clust * (int)sqrt(head->u)) is used to calculate the actual value. • The value 9 is represented as 1 in the leaf node, as 1 in a level above and as 9 in the head node. • This can be calculated by cluster_no * sqrt(u) + offset. The cluster_no for 9 in the level below head is 0, u is 4 and index is 1 => 1 + (0 * 2) = 1. • In the head level, cluster_no = 2, u is 16 and index is the 1 (from the result of the level below). => 1 + (2 * 4) = 9. Minimum
  • 17. int minimum(node *head) { if(head->u == 2) { if(head->keys[0] == 1) return 0; else if (head->keys[1] == 1) return 1; return -1; } int clust = minimum(head->summary); if(clust != -1) { int index = minimum(head->cluster[clust]); return index + (clust * (int)sqrt(head->u)); } } Minimum
  • 18. int maximum(node *head) { if(head->u == 2) { if(head->keys[1] == 1) return 1; else if (head->keys[0] == 1) return 0; return -1; } int clust = maximum(head->summary); if(clust != -1) { int index = maximum(head->cluster[clust]); return index + (clust * (int)sqrt(head->u)); } } The same logic as minimum but we check for the second bit first and then first bit next which do the traversal from the end. Maximum
  • 19. 16 4 4 4 4 4 2 1 1 2 1 1 2 0 1 2 0 1 2 0 0 2 1 1 2 1 1 2 1 1 2 0 1 2 0 0 2 0 0 2 0 0 2 0 1 2 0 0 2 0 1 summary u cluster 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Minimum is 2 and Maximum is 15 Orange arrow indicates the flow of minimum function
  • 20. • We traverse to the leaf node and check whether our key is the second bit and there is a first bit set. If yes, we need not do any calculation, we just return the value by calculating the value at each level using the expression (high(key,head->u) * (int)sqrt(head->u)) + pred. • If no immediate predecessor is found, we find the maximum of the left side clusters. • Similarly, for successor we find if there are immediate successor else, we find the minimum of the right-side clusters and return it. Predecessor and Successor
  • 21. int predecessor(node *head,int key){ if(head->u == 2){ if(key == 1 && head->keys[0] == 1) return 0; return -1; } int pred = predecessor(head->cluster[high(key,head->u)],low(key,head->u)); if (pred == -1){ int pred_clust = predecessor(head->summary,high(key,head->u)); if(pred_clust == -1) { return -1; } int max = maximum(head->cluster[pred_clust]); return max + (pred_clust * (int)sqrt(head->u)); } else { return (high(key,head->u) * (int)sqrt(head->u)) + pred; }} Predecessor
  • 22. int successor(node *head,int key){ if(head->u == 2){ if(key == 0 && head->keys[1] == 1) return 1; return -1; } int sucsr = successor(head->cluster[high(key,head->u)],low(key,head->u)); if (sucsr == -1){ int pred_clust = successor(head->summary,high(key,head->u)); if(pred_clust == -1) { return -1; } int min = minimum(head->cluster[pred_clust]); return min + (pred_clust * (int)sqrt(head->u)); } else { return (high(key,head->u) * (int)sqrt(head->u)) + sucsr; }} Successor