SlideShare une entreprise Scribd logo
1  sur  16
DESIGN ANALYSIS AND
ALGORITHM
TOPIC : OPTIMAL BINARY SEARCH TREE
BINARY TREE
 Each parent node has atmost two child nodes.
 It has parent node and 2 leaf nodes
 This is called a binary tree.
 Eg:
2
7 5
3 6 3 8
BINARY SEARCH TREE
 EXAMPLE :
8
3 10
1 6
14
BINARY SEARCH TREE ( CONT..)
 Left child values should be less than the parent
node or Root node.
 Right child values should be greater than Root
Node.
 This is called Binary search tree.
 For the purpose of searching we have a different
types of searches.
 Linear search
 Binary search
 Binary tree data structure.
BINARY TREE DATA STRUCTURE
 Binary tree is mainly used for searching purpose
also and it is very easy to identify the elements.
 For searching an element in binary tree,the
maximum time is taken, when the element is
present in a leaf.
 The height of the binary tree is log n.
 In order to rectify the cost of search we are using
optimal binary search tree.
OPTIMAL BINARY SEARCH TREE
 The arrangement of elements in the form of a
binary data structure such that the cost of searching
the elements is minimum.
 This is called optimal binary search tree.
 To reduce the cost of searching we use optimal
binary search tree.
 The word “optimal” means best so , to search an
element we use the best way that is optimal binary
search tree.
 Eg: Consider a set of elements
10,20,30
Cost of searching is 1+2+3=6 ( maximum)
1
2
3
10
20
30
OPTIMAL BINARY TREE:
Cost of searching:
1+2+2 = 5 ( minimum )
1
2 2
20
10 30
0 4 81 203 263
0 2 103 163
0 6 123
0 3
0
0 1 2 3 4
0
1
2
3
4
i
j
 Step 1: Consider the cost of reaching the same node
 c[0,0]=0
 c[1,1]=0
 c[2,2]=0
 c[3,3]=0
 C[4,4]=0
Step2: Consider the cost of reaching one node
• c[0,1]=4
• c[1,2]=2
• c[2,3]=6
• c[3,4]=3
 Step 3: Consider cost of reaching 2 nodes distance
 c[0,2], c[1,3] , c[2,4]
 c[i,j]= min{ c[i,k-1] + c[k,j] + w[i,j]}
 Where k=1 ( rootnode)
 c[0,2]= min { c[0,0]+c[1,2]+w[0,2],c[0,1]+c[2,2]+w[0,2]}
 =min{ 0+2+6, 4+0+6}
 =min{8,10}
 C[0,2]=81
 c[1,3]= min { c[1,1]+c[2,3]+w[1,3],c[1,2]+c[3,3]+w[1,3]}
 =min{ 0+6+8,2+0+8}
 =min{14,10}
 C[1,3]=103
 c[2,4]= min { c[2,2]+c[3,4]+w[2,4],c[2,3]+c[4,4]+w[2,4]}
 =min{ 0+3+9, 6+0+9}
 =min{12,15}
 C[2,4]=123
 Step 4: Consider the cost of reaching 3 nodes.
 c[0,3]= min {
c[0,0]+c[1,3]+w[0,3],c[0,1]+c[2,3]+w[0,3],c[0,2]+c[3,3]+12}
 =min{ 0+10+12,4+6+12,8+0+12}
 =min{22,22,20}
 C[0,3]=203
 c[1,4]= min {
c[1,1]+c[2,4]+w[1,4],c[1,2]+c[3,4]+w[1,4],c[1,3]+
 c[4,4]+w[1,4]}
 =min{ 0+12+11,2+3+11,10+0+11}
 =min{23,16,21}
 C[1,4]=163
 Step 5: Consider the cost of reaching 4 nodes.
 c[0,4]= min {
c[0,0]+c[1,4]+w[0,4],c[0,1]+c[2,4]+w[0,4],c[0,2]+c[3,
4]+w[0,4],c[0,3]+c[4,4]+w[0,4]}
 =min{ 31,31,26,35}
 =min{22,22,20}
 C[0,4]=263
Optimal binary search tree:
10 40
20
30
THANK YOU

Contenu connexe

Tendances (20)

BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.ppt
 
Tree and graph
Tree and graphTree and graph
Tree and graph
 
DBMS Unit - 6 - Transaction Management
DBMS Unit - 6 - Transaction ManagementDBMS Unit - 6 - Transaction Management
DBMS Unit - 6 - Transaction Management
 
Python exception handling
Python   exception handlingPython   exception handling
Python exception handling
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
 
Searching linear & binary search
Searching linear & binary searchSearching linear & binary search
Searching linear & binary search
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Multi ways trees
Multi ways treesMulti ways trees
Multi ways trees
 
TRIES_data_structure
TRIES_data_structureTRIES_data_structure
TRIES_data_structure
 
Python tuples and Dictionary
Python   tuples and DictionaryPython   tuples and Dictionary
Python tuples and Dictionary
 
Python
PythonPython
Python
 
Binary search
Binary searchBinary search
Binary search
 
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Balanced Tree (AVL Tree & Red-Black Tree)
Balanced Tree (AVL Tree & Red-Black Tree)Balanced Tree (AVL Tree & Red-Black Tree)
Balanced Tree (AVL Tree & Red-Black Tree)
 
Namespaces
NamespacesNamespaces
Namespaces
 
Optimal binary search tree
Optimal binary search treeOptimal binary search tree
Optimal binary search tree
 

Similaire à Optimal Binary Search tree ppt seminar.pptx

Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Treesagar yadav
 
PYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUES
PYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUESPYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUES
PYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUESvanithasivdc
 
Basics in algorithms and data structure
Basics in algorithms and data structure Basics in algorithms and data structure
Basics in algorithms and data structure Eman magdy
 
Introduction to Search Systems - ScaleConf Colombia 2017
Introduction to Search Systems - ScaleConf Colombia 2017Introduction to Search Systems - ScaleConf Colombia 2017
Introduction to Search Systems - ScaleConf Colombia 2017Toria Gibbs
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary treeKrish_ver2
 
Lecture 7-BinarySearchTrees.ppt
Lecture 7-BinarySearchTrees.pptLecture 7-BinarySearchTrees.ppt
Lecture 7-BinarySearchTrees.pptDrBashirMSaad
 
Interval intersection
Interval intersectionInterval intersection
Interval intersectionAabida Noman
 
Lo27
Lo27Lo27
Lo27lksoo
 
Array 2
Array 2Array 2
Array 2Abbott
 
B TREE ( a to z concept ) in data structure or DBMS
B TREE ( a to z concept ) in data structure  or DBMSB TREE ( a to z concept ) in data structure  or DBMS
B TREE ( a to z concept ) in data structure or DBMSMathkeBhoot
 
PPT Lecture 2.2.1 onn c++ data structures
PPT Lecture 2.2.1 onn c++ data structuresPPT Lecture 2.2.1 onn c++ data structures
PPT Lecture 2.2.1 onn c++ data structuresmidtushar
 
Data Structure and Algorithms Arrays
Data Structure and Algorithms ArraysData Structure and Algorithms Arrays
Data Structure and Algorithms ArraysManishPrajapati78
 

Similaire à Optimal Binary Search tree ppt seminar.pptx (20)

Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
PYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUES
PYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUESPYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUES
PYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUES
 
Associative Learning
Associative LearningAssociative Learning
Associative Learning
 
Basics in algorithms and data structure
Basics in algorithms and data structure Basics in algorithms and data structure
Basics in algorithms and data structure
 
E2
E2E2
E2
 
Introduction to Search Systems - ScaleConf Colombia 2017
Introduction to Search Systems - ScaleConf Colombia 2017Introduction to Search Systems - ScaleConf Colombia 2017
Introduction to Search Systems - ScaleConf Colombia 2017
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
Lecture 7-BinarySearchTrees.ppt
Lecture 7-BinarySearchTrees.pptLecture 7-BinarySearchTrees.ppt
Lecture 7-BinarySearchTrees.ppt
 
Chapter-2.pptx
Chapter-2.pptxChapter-2.pptx
Chapter-2.pptx
 
A41001011
A41001011A41001011
A41001011
 
1st lecture.ppt
1st lecture.ppt1st lecture.ppt
1st lecture.ppt
 
Interval intersection
Interval intersectionInterval intersection
Interval intersection
 
Indexing Data Structure
Indexing Data StructureIndexing Data Structure
Indexing Data Structure
 
Lo27
Lo27Lo27
Lo27
 
05
0505
05
 
Array 2
Array 2Array 2
Array 2
 
B TREE ( a to z concept ) in data structure or DBMS
B TREE ( a to z concept ) in data structure  or DBMSB TREE ( a to z concept ) in data structure  or DBMS
B TREE ( a to z concept ) in data structure or DBMS
 
PPT Lecture 2.2.1 onn c++ data structures
PPT Lecture 2.2.1 onn c++ data structuresPPT Lecture 2.2.1 onn c++ data structures
PPT Lecture 2.2.1 onn c++ data structures
 
Binary tree
Binary treeBinary tree
Binary tree
 
Data Structure and Algorithms Arrays
Data Structure and Algorithms ArraysData Structure and Algorithms Arrays
Data Structure and Algorithms Arrays
 

Dernier

The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfSenaatti-kiinteistöt
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaKayode Fayemi
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatmentnswingard
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalFabian de Rijk
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Baileyhlharris
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoKayode Fayemi
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lodhisaajjda
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxraffaeleoman
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfSkillCertProExams
 
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfSOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfMahamudul Hasan
 
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...David Celestin
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...amilabibi1
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar TrainingKylaCullinane
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIINhPhngng3
 

Dernier (15)

The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatment
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of Drupal
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Bailey
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.
 
ICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdfICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdf
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
 
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfSOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
 
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar Training
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio III
 

Optimal Binary Search tree ppt seminar.pptx

  • 1. DESIGN ANALYSIS AND ALGORITHM TOPIC : OPTIMAL BINARY SEARCH TREE
  • 2. BINARY TREE  Each parent node has atmost two child nodes.  It has parent node and 2 leaf nodes  This is called a binary tree.  Eg: 2 7 5 3 6 3 8
  • 3. BINARY SEARCH TREE  EXAMPLE : 8 3 10 1 6 14
  • 4. BINARY SEARCH TREE ( CONT..)  Left child values should be less than the parent node or Root node.  Right child values should be greater than Root Node.  This is called Binary search tree.
  • 5.  For the purpose of searching we have a different types of searches.  Linear search  Binary search  Binary tree data structure.
  • 6. BINARY TREE DATA STRUCTURE  Binary tree is mainly used for searching purpose also and it is very easy to identify the elements.  For searching an element in binary tree,the maximum time is taken, when the element is present in a leaf.  The height of the binary tree is log n.  In order to rectify the cost of search we are using optimal binary search tree.
  • 7. OPTIMAL BINARY SEARCH TREE  The arrangement of elements in the form of a binary data structure such that the cost of searching the elements is minimum.  This is called optimal binary search tree.  To reduce the cost of searching we use optimal binary search tree.  The word “optimal” means best so , to search an element we use the best way that is optimal binary search tree.
  • 8.  Eg: Consider a set of elements 10,20,30 Cost of searching is 1+2+3=6 ( maximum) 1 2 3 10 20 30
  • 9. OPTIMAL BINARY TREE: Cost of searching: 1+2+2 = 5 ( minimum ) 1 2 2 20 10 30
  • 10. 0 4 81 203 263 0 2 103 163 0 6 123 0 3 0 0 1 2 3 4 0 1 2 3 4 i j
  • 11.  Step 1: Consider the cost of reaching the same node  c[0,0]=0  c[1,1]=0  c[2,2]=0  c[3,3]=0  C[4,4]=0 Step2: Consider the cost of reaching one node • c[0,1]=4 • c[1,2]=2 • c[2,3]=6 • c[3,4]=3
  • 12.  Step 3: Consider cost of reaching 2 nodes distance  c[0,2], c[1,3] , c[2,4]  c[i,j]= min{ c[i,k-1] + c[k,j] + w[i,j]}  Where k=1 ( rootnode)  c[0,2]= min { c[0,0]+c[1,2]+w[0,2],c[0,1]+c[2,2]+w[0,2]}  =min{ 0+2+6, 4+0+6}  =min{8,10}  C[0,2]=81  c[1,3]= min { c[1,1]+c[2,3]+w[1,3],c[1,2]+c[3,3]+w[1,3]}  =min{ 0+6+8,2+0+8}  =min{14,10}  C[1,3]=103
  • 13.  c[2,4]= min { c[2,2]+c[3,4]+w[2,4],c[2,3]+c[4,4]+w[2,4]}  =min{ 0+3+9, 6+0+9}  =min{12,15}  C[2,4]=123  Step 4: Consider the cost of reaching 3 nodes.  c[0,3]= min { c[0,0]+c[1,3]+w[0,3],c[0,1]+c[2,3]+w[0,3],c[0,2]+c[3,3]+12}  =min{ 0+10+12,4+6+12,8+0+12}  =min{22,22,20}  C[0,3]=203
  • 14.  c[1,4]= min { c[1,1]+c[2,4]+w[1,4],c[1,2]+c[3,4]+w[1,4],c[1,3]+  c[4,4]+w[1,4]}  =min{ 0+12+11,2+3+11,10+0+11}  =min{23,16,21}  C[1,4]=163  Step 5: Consider the cost of reaching 4 nodes.  c[0,4]= min { c[0,0]+c[1,4]+w[0,4],c[0,1]+c[2,4]+w[0,4],c[0,2]+c[3, 4]+w[0,4],c[0,3]+c[4,4]+w[0,4]}  =min{ 31,31,26,35}  =min{22,22,20}  C[0,4]=263
  • 15. Optimal binary search tree: 10 40 20 30