SlideShare a Scribd company logo
1 of 10
Presented by
Sams Uddin Ahamed
&
Najmus Sakib Borson
Scapegoat Tree
(Data Structure)
What is Scapegoat?
 The scapegoat tree is an implementation of a
self-balancing binary tree. This structure is based
on the common wisdom that when something
goes wrong, the first thing people tend to do is
find someone to blame as known as scapegoat.
Once blame is firmly established, we can leave
the scapegoat to fix the problem.
 Time complexity
-Search in O(log n) worst-case time
- Insert/delete in O(log n) amortized(average) time
-Starting with an empty scapegoat tree, a
sequence of m insertions and deletions takes
O(mlog n) .
Theorem
A binary search tree is said to be weight balanced if half
of nodes are on the left of the root and half on the right.
An α weight balanced node is therefore:
size(left) <= α *size(node)
size(right) <= α *size(node)
Value of Alpha
The α for a scapegoat tree can be any number between
0.5 to 1. A high α value results in fewer balances,
making insertion quicker but searching and deletions
slower, and vice versa for a low α .
How It works?
 Step 1
At first we have to find the scapegoat for which
the tree is unbalanced. To find the scapegoat we use
α(.5< α<1) which is the ratio of Parent and child node.
 Step 2
After finding the scapegoat we have to rebuild
the sub-tree rooted at the scapegoat node.
Properties
Insertion (Assuming α = 2/3 =0.67):
To insert value x in a Scapegoat Tree:
 Create a new node u and insert x using the BST
insert algorithm.
 If the depth of u is greater than log3/2n where n is
number of nodes in tree then we need to make
tree balanced. To make balanced, we use below
step to find a scapegoat.
 Walk up from u until we reach a node w with size(w)
> (2/3)*size(w.parent). This node is scapegoat.
 Rebuild the subtree rooted at w.parent.
size(w) > α *size(w.parent).
Delete
To remove the value x from a Scapegoat Tree:
 run the standard deletion algorithm for binary
search trees
 decrement n (where n= number of nodes)
 if n < q/2 (where q is overestimate of n) then
- rebuild the entire tree and set q=n
Search
 The Search operation in Scapegoat tree is done
like regular Search in a binary search tree.
Rebuild
In rebuilding, we simply convert the subtree to the most
possible balanced BST. We first store inorder traversal of
BST in an array, then we build a new BST from array by
recursively dividing it into two halves.
Time complexity of Rebuild
The actual process of re-balancing the tree rooted at
the scapegoat takes O(n)time. However, this is not a
fair analysis because while the scapegoat could be
the root of the tree, it could also be a node very deep
in the tree. That process would much faster because
the vast majority of the tree is left alone. Therefore,
the re-balancing process takes O(log
n) amortized(average) time.
 Advantages
The scapegoat tree is the first binary search
tree to achieve its complexity without storing
extra information at every node. This saves large
amounts of space, making it an attractive
balanced binary search tree.
 Disadvantages
Lazy data structure. Only does work when
search paths get too long.

More Related Content

What's hot

1.9.association mining 1
1.9.association mining 11.9.association mining 1
1.9.association mining 1Krish_ver2
 
Unicast multicast & broadcast
Unicast multicast & broadcastUnicast multicast & broadcast
Unicast multicast & broadcastNetProtocol Xpert
 
ISSUES IN AD HOC WIRELESS NETWORKS
ISSUES IN  AD HOC WIRELESS  NETWORKS ISSUES IN  AD HOC WIRELESS  NETWORKS
ISSUES IN AD HOC WIRELESS NETWORKS Dushhyant Kumar
 
CLUSTERING IN DATA MINING.pdf
CLUSTERING IN DATA MINING.pdfCLUSTERING IN DATA MINING.pdf
CLUSTERING IN DATA MINING.pdfSowmyaJyothi3
 
MANET in Mobile Computing
MANET in Mobile ComputingMANET in Mobile Computing
MANET in Mobile ComputingKABILESH RAMAR
 
Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...
Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...
Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...Simplilearn
 
CSGR(cluster switch gateway routing)
CSGR(cluster switch gateway routing)CSGR(cluster switch gateway routing)
CSGR(cluster switch gateway routing)Gaurav Dalvi
 
Binomial Heap
Binomial HeapBinomial Heap
Binomial HeapGoa App
 
Wireless Sensor Network Routing Protocols
Wireless Sensor Network Routing ProtocolsWireless Sensor Network Routing Protocols
Wireless Sensor Network Routing ProtocolsVirendra Thakur
 
Cloud-Computing-ppt.pptx
Cloud-Computing-ppt.pptxCloud-Computing-ppt.pptx
Cloud-Computing-ppt.pptxMiltonMolla1
 
Perceptron (neural network)
Perceptron (neural network)Perceptron (neural network)
Perceptron (neural network)EdutechLearners
 
A topic 2.1.2 classification of network
A topic 2.1.2 classification of networkA topic 2.1.2 classification of network
A topic 2.1.2 classification of networkhazirma
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplicationRespa Peter
 
Selection in Evolutionary Algorithm
Selection in Evolutionary AlgorithmSelection in Evolutionary Algorithm
Selection in Evolutionary AlgorithmRiyad Parvez
 
Directed diffusion for wireless sensor networking
Directed diffusion for wireless sensor networkingDirected diffusion for wireless sensor networking
Directed diffusion for wireless sensor networkingHabibur Rahman
 

What's hot (20)

1.9.association mining 1
1.9.association mining 11.9.association mining 1
1.9.association mining 1
 
Unicast multicast & broadcast
Unicast multicast & broadcastUnicast multicast & broadcast
Unicast multicast & broadcast
 
ISSUES IN AD HOC WIRELESS NETWORKS
ISSUES IN  AD HOC WIRELESS  NETWORKS ISSUES IN  AD HOC WIRELESS  NETWORKS
ISSUES IN AD HOC WIRELESS NETWORKS
 
Wlan wireless network
Wlan wireless networkWlan wireless network
Wlan wireless network
 
CLUSTERING IN DATA MINING.pdf
CLUSTERING IN DATA MINING.pdfCLUSTERING IN DATA MINING.pdf
CLUSTERING IN DATA MINING.pdf
 
MANET in Mobile Computing
MANET in Mobile ComputingMANET in Mobile Computing
MANET in Mobile Computing
 
Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...
Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...
Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...
 
CSGR(cluster switch gateway routing)
CSGR(cluster switch gateway routing)CSGR(cluster switch gateway routing)
CSGR(cluster switch gateway routing)
 
Binomial Heap
Binomial HeapBinomial Heap
Binomial Heap
 
Wireless Sensor Network Routing Protocols
Wireless Sensor Network Routing ProtocolsWireless Sensor Network Routing Protocols
Wireless Sensor Network Routing Protocols
 
GSM channels
GSM channelsGSM channels
GSM channels
 
Decision theory
Decision theoryDecision theory
Decision theory
 
Cloud-Computing-ppt.pptx
Cloud-Computing-ppt.pptxCloud-Computing-ppt.pptx
Cloud-Computing-ppt.pptx
 
Perceptron (neural network)
Perceptron (neural network)Perceptron (neural network)
Perceptron (neural network)
 
A topic 2.1.2 classification of network
A topic 2.1.2 classification of networkA topic 2.1.2 classification of network
A topic 2.1.2 classification of network
 
Network And Topology
Network And TopologyNetwork And Topology
Network And Topology
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplication
 
Selection in Evolutionary Algorithm
Selection in Evolutionary AlgorithmSelection in Evolutionary Algorithm
Selection in Evolutionary Algorithm
 
Directed diffusion for wireless sensor networking
Directed diffusion for wireless sensor networkingDirected diffusion for wireless sensor networking
Directed diffusion for wireless sensor networking
 
Clustering
ClusteringClustering
Clustering
 

Similar to Scapegoat Tree

Chapter 8 advanced sorting and hashing for print
Chapter 8 advanced sorting and hashing for printChapter 8 advanced sorting and hashing for print
Chapter 8 advanced sorting and hashing for printAbdii Rashid
 
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNNsplaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNNratnapatil14
 
Chapter 12 - Heaps.ppt
Chapter 12 - Heaps.pptChapter 12 - Heaps.ppt
Chapter 12 - Heaps.pptMouDhara1
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.pptLegesseSamuel
 
Parallel kmeans clustering in Erlang
Parallel kmeans clustering in ErlangParallel kmeans clustering in Erlang
Parallel kmeans clustering in ErlangChinmay Patel
 
algorithm assignmenteeeeeee.pptx
algorithm assignmenteeeeeee.pptxalgorithm assignmenteeeeeee.pptx
algorithm assignmenteeeeeee.pptxkassahungebrie
 
Sienna 4 divideandconquer
Sienna 4 divideandconquerSienna 4 divideandconquer
Sienna 4 divideandconquerchidabdu
 
Sorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha MajumderSorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha MajumderAshin Guha Majumder
 
Machine Learning Algorithms (Part 1)
Machine Learning Algorithms (Part 1)Machine Learning Algorithms (Part 1)
Machine Learning Algorithms (Part 1)Zihui Li
 
Distance Based Indexing
Distance Based IndexingDistance Based Indexing
Distance Based Indexingketan533
 
Time complexity of union find
Time complexity of union findTime complexity of union find
Time complexity of union findWei (Terence) Li
 
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...Amrinder Arora
 

Similar to Scapegoat Tree (20)

Algorithms Exam Help
Algorithms Exam HelpAlgorithms Exam Help
Algorithms Exam Help
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
 
Chapter 8 advanced sorting and hashing for print
Chapter 8 advanced sorting and hashing for printChapter 8 advanced sorting and hashing for print
Chapter 8 advanced sorting and hashing for print
 
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNNsplaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
 
Splay tree
Splay treeSplay tree
Splay tree
 
DS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and ConquerDS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and Conquer
 
Chapter 12 - Heaps.ppt
Chapter 12 - Heaps.pptChapter 12 - Heaps.ppt
Chapter 12 - Heaps.ppt
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.ppt
 
Parallel kmeans clustering in Erlang
Parallel kmeans clustering in ErlangParallel kmeans clustering in Erlang
Parallel kmeans clustering in Erlang
 
algorithm assignmenteeeeeee.pptx
algorithm assignmenteeeeeee.pptxalgorithm assignmenteeeeeee.pptx
algorithm assignmenteeeeeee.pptx
 
Sienna 4 divideandconquer
Sienna 4 divideandconquerSienna 4 divideandconquer
Sienna 4 divideandconquer
 
Sorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha MajumderSorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha Majumder
 
Linear sorting
Linear sortingLinear sorting
Linear sorting
 
Machine Learning Algorithms (Part 1)
Machine Learning Algorithms (Part 1)Machine Learning Algorithms (Part 1)
Machine Learning Algorithms (Part 1)
 
Distance Based Indexing
Distance Based IndexingDistance Based Indexing
Distance Based Indexing
 
Sorting2
Sorting2Sorting2
Sorting2
 
Materi Searching
Materi Searching Materi Searching
Materi Searching
 
Algorithm Exam Help
Algorithm Exam HelpAlgorithm Exam Help
Algorithm Exam Help
 
Time complexity of union find
Time complexity of union findTime complexity of union find
Time complexity of union find
 
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...
 

Recently uploaded

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 

Recently uploaded (20)

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 

Scapegoat Tree

  • 1. Presented by Sams Uddin Ahamed & Najmus Sakib Borson Scapegoat Tree (Data Structure)
  • 2. What is Scapegoat?  The scapegoat tree is an implementation of a self-balancing binary tree. This structure is based on the common wisdom that when something goes wrong, the first thing people tend to do is find someone to blame as known as scapegoat. Once blame is firmly established, we can leave the scapegoat to fix the problem.  Time complexity -Search in O(log n) worst-case time - Insert/delete in O(log n) amortized(average) time -Starting with an empty scapegoat tree, a sequence of m insertions and deletions takes O(mlog n) .
  • 3. Theorem A binary search tree is said to be weight balanced if half of nodes are on the left of the root and half on the right. An α weight balanced node is therefore: size(left) <= α *size(node) size(right) <= α *size(node) Value of Alpha The α for a scapegoat tree can be any number between 0.5 to 1. A high α value results in fewer balances, making insertion quicker but searching and deletions slower, and vice versa for a low α .
  • 4. How It works?  Step 1 At first we have to find the scapegoat for which the tree is unbalanced. To find the scapegoat we use α(.5< α<1) which is the ratio of Parent and child node.  Step 2 After finding the scapegoat we have to rebuild the sub-tree rooted at the scapegoat node.
  • 5. Properties Insertion (Assuming α = 2/3 =0.67): To insert value x in a Scapegoat Tree:  Create a new node u and insert x using the BST insert algorithm.  If the depth of u is greater than log3/2n where n is number of nodes in tree then we need to make tree balanced. To make balanced, we use below step to find a scapegoat.  Walk up from u until we reach a node w with size(w) > (2/3)*size(w.parent). This node is scapegoat.  Rebuild the subtree rooted at w.parent.
  • 6. size(w) > α *size(w.parent).
  • 7.
  • 8. Delete To remove the value x from a Scapegoat Tree:  run the standard deletion algorithm for binary search trees  decrement n (where n= number of nodes)  if n < q/2 (where q is overestimate of n) then - rebuild the entire tree and set q=n Search  The Search operation in Scapegoat tree is done like regular Search in a binary search tree.
  • 9. Rebuild In rebuilding, we simply convert the subtree to the most possible balanced BST. We first store inorder traversal of BST in an array, then we build a new BST from array by recursively dividing it into two halves. Time complexity of Rebuild The actual process of re-balancing the tree rooted at the scapegoat takes O(n)time. However, this is not a fair analysis because while the scapegoat could be the root of the tree, it could also be a node very deep in the tree. That process would much faster because the vast majority of the tree is left alone. Therefore, the re-balancing process takes O(log n) amortized(average) time.
  • 10.  Advantages The scapegoat tree is the first binary search tree to achieve its complexity without storing extra information at every node. This saves large amounts of space, making it an attractive balanced binary search tree.  Disadvantages Lazy data structure. Only does work when search paths get too long.