Your SlideShare is downloading. ×
0
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
E25obstb
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

E25obstb

90

Published on

jntu qualitative visual algorithms

jntu qualitative visual algorithms

Published in: Entertainment & Humor
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
90
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1.  Let us say the management of the college would like to start a zoo in the vacant land. They acquire three animals:- Animal set = {elephant, lion, zebra} We have:- elephant<lion<zebra The partial order may be lexicographic or some other criteria. We assume the lexicographic order.
  • 2.  Now the zoo is thrown open to the public. Let us now trace the scenario on a typical day at the zoo. Children will come to the zoo. A child will ask for a particular animal. A child will ask for an animal which may not be there in the zoo. We will assume that the child will ask for some animal.
  • 3.  ..p(1) = .5 is the probability that the child will ask for the elephant. ..p(2) = .1 is the probability that the child will ask for the lion. ..p(3) = .05 is the probability that the child will ask for the zebra.
  • 4.  ..q(0) = .15 is the probability that the child will ask for an animal less than the elephant. ..q(1) = .1 is the probability that the child will ask for an animal greater than the elephant but less than the lion. ..q(2) = .05 is the probability that the child will ask for an animal greater than the lion but less than the zebra. ..q(3) = .05 is the probability that the child will ask for an animal greater than the zebra.
  • 5. DISTRIBUTION OF THE PROBABILITIES Elephant Lion Zebra P(1)=.5 P(2)= P(3)=. .1 05 >Elephant but <Lion=Q(1)=.1 >Zebra= Q(3)=.05<Elephant=q(0)=. >Lion but15 <Zebra=Q(2)=.05
  • 6. DISTRIBUTION OF THE PROBABILITIES The sum of all the P(i) for i=1 to 3 and Q(j) for j=0 to 3 is 1. This means the child will ask for some animal and not perversely for a chocolate.
  • 7. ORGANISATION OF THE ZOO The zoo is to be organised as a binary search tree. This allows animals to be added easily and found easily in log(n) time. We have to assume the zoo takes care of its animals and none of them die, for deletion is an expensive task in a binary search tree.
  • 8. OBST The Optimal binary search tree problem is to find the best organisation of the zoo so that the amount the children will have to walk is minimised. The popular animals should be higher up in the tree and the less popular animals lower down in the tree.
  • 9. THE TREES The animals can be entered in the zoo in various orders--- 1. (elephant, lion, zebra) 2. (elephant, zebra, lion) 3. (lion, elephant, zebra) 4. (lion, zebra, elephant) 5. (zebra, lion, elephant) 6. (zebra, elephant, lion)
  • 10. COST OF TREE 1 1. (elephant, lion, zebra) elephantFirst the elephant is entered into the zoo, so it occupies the root node of the binary search tree.
  • 11. COST OF TREE 1 1. (elephant, lion, zebra) Next the lion is entered. It is greater than the elephant and so comes to the right. elephant lion
  • 12. COST OF TREE 1 1. (elephant, lion, zebra) Next the zebra is entered. It is greater than the lion and so comes to the right of the lion. elephant lion zebra
  • 13. FAILURE NODES elephant lion zebraASK FORAN ANIMALLESS THAN ASK FOR ASK FOR AN ANTHE ANIMAL THAT IS ASK FOR AN ANIMALELEPHANT GREATER THAN ANIMAL THAT IS GREATE R THANQ(0) THE ELEPHANT BUT GREATER THAN ZEBRA LESS THAN THE THE ELEPHANT Q(2) LION Q(1) BUT LESS THAN THE LION Q(1)
  • 14. Elephant.5 Lion Zebra COST OF FINDING THE ELEPHANT = 1 COMPARISON =1*.5=.5
  • 15. Elephant.5 Lion .2 zebra COST OF FINDING THE LION = 2 COMPARISONS =2*.1=.2
  • 16. Elephant.5 Lion .2 Zebra .15 COST OF FINDING THE ZEBRA = 3 COMPARISONS =3*.05=.15
  • 17. Elephant.5 Lion .2 Zebra .15.15 COST OF FINDING AN ANIMAL THAT IS LESS THAN THE ELEPHANT = 1 COMPARISON =1*.1.15
  • 18. Elephant.5 Lion .2 Zebra .15.15 .2 COST OF FINDING AN ANIMAL THAT IS GREATER THAN THE ELEPHANT BUT LESS THAN THE LION = 2 COMPARISON =2*.1=.2
  • 19. Elephant.5 Lion .2 Zebra .15.15 .2 .15 COST OF FINDING AN ANIMAL THAT IS GREATER THAN THE LION BUT LESS THAN THE ZEBRA = 3 COMPARISON =3*.05=.15
  • 20. Elephant.5 Lion .2 Zebra .15.15 .2 .15 .15 COST OF FINDING AN ANIMAL THAT IS GREATER THAN THE THE ZEBRA = 3 COMPARISON =3*.05=.15
  • 21. Elephant.5 Lion .2 Zebra .15.15 .2 .15 .15 TOTAL COST =.85 FOR FINDING AN ANIMAL IN THE ZOO + .65 FOR DECLARING AN ANIMAL AS NOT PREENT IN THE ZOO = 1.5
  • 22. THE TREES The animals can be entered in the zoo in various orders--- 1. (elephant, lion, zebra) OVER=1.5 2. (elephant, zebra, lion) 3. (lion, elephant, zebra) 4. (lion, zebra, elephant) 5. (zebra, lion, elephant) 6. (zebra, elephant, lion)
  • 23. TREE 2 2. (elephant, zebra, lion) elephant THE ELEPHANT IS THE FIRST ANIMAL TO BE ENTERED INTO THE ZOO SO IT OCCUPIES THE ROOT NODE.
  • 24. TREE 2 2. (elephant, zebra, lion) elephant zebra THE ZEBRA IS THE SECOND ANIMAL TO BE ENTERED INTO THE ZOO SO IT OCCUPIES THE NODE TO THE RIGHT OF THE ELPHANT, AS ZEBRA>ELEPHANT.
  • 25. TREE 2 2. (elephant, zebra, lion) elephant zebra lion THE LION IS THE THIRD ANIMAL TO BE ENTERED INTO THE ZOO SO IT OCCUPIES THE NODE TO THE RIGHT OF THE ELPHANT AND LEFT OF THE ZEBRA.
  • 26. TREE 2 2. (elephant, zebra, lion) elephant zebra lion THE LION IS THE THIRD ANIMAL TO BE ENTERED INTO THE ZOO SO IT OCCUPIES THE NODE TO THE RIGHT OF THE ELPHANT AND LEFT OF THE ZEBRA.
  • 27. TREE 2 WITH FAILURE NODES  2. (elephant, zebra, lion) elephant zebraQ(0): ANANIMALLESS THANELEPHANT lion Q(3): GREATER THAN THE ZEBRA Q(1): BETWEEN Q(2): ELEPHANT AND BETWEEN LION LION AND ZEBRA
  • 28. TREE 2 WITH COSTS COST OF ELEPHANT=.5  2. (elephant, zebra, lion) Elephant 1/7 zebraQ(0): ANANIMALLESS THANELEPHANT lion Q(3): GREATER THAN THE ZEBRA Q(1): BETWEEN Q(2): ELEPHANT AND BETWEEN LION LION AND ZEBRA
  • 29. TREE 2 WITH COSTS COST OF ZEBRA=.1  2. (elephant, zebra, lion) Elephant 1/7 ZebraQ(0): AN 2/7ANIMALLESS THANELEPHANT lion Q(3): GREATER THAN THE ZEBRA Q(1): BETWEEN Q(2): ELEPHANT AND BETWEEN LION LION AND ZEBRA
  • 30. TREE 2 WITH COSTS COST OF LION=.3  2. (elephant, zebra, lion) Elephant 1/7 ZebraQ(0): AN 2/7ANIMALLESS THANELEPHANT Lion Q(3): 3/7 GREATER THAN THE ZEBRA Q(1): BETWEEN Q(2): ELEPHANT AND BETWEEN LION LION AND ZEBRA
  • 31. TREE 2 WITH COSTS COST OF ANIMAL LESS  2. (elephant, zebra, lion) THAN ELEPHANT=.15 Elephant 1/7 ZebraQ(0): AN 2/7ANIMALLESS THANELEPHANT Lion Q(3): GREATER.15 3/7 THAN THE ZEBRA Q(1): BETWEEN Q(2): ELEPHANT AND BETWEEN LION LION AND ZEBRA
  • 32. TREE 2 WITH COSTS COST OF ANIMAL  2. (elephant, zebra, lion) GREATER THAN ELEPHANT AND LESS Elephant THAN ZEBRA OR LION 1/7 ELEPHANT=.3 ZebraQ(0): AN 2/7ANIMALLESS THANELEPHANT Lion Q(3): GREATER.15 3/7 THAN THE ZEBRA Q(1): .3 Q(2): BETWEEN BETWEEN ELEPHANT AND LION AND LION ZEBRA
  • 33. TREE 2 WITH COSTS COST OF ANIMAL  2. (elephant, zebra, lion) GREATER THAN ELEPHANT AND LESS Elephant THAN ZEBRA AND 1/7 GREATER THAN LION=Q(2)*3=.15 ZebraQ(0): AN 2/7ANIMALLESS THANELEPHANT Lion Q(3): GREATER.15 3/7 THAN THE .15 Q(2): ZEBRA Q(1): .3 BETWEEN BETWEEN LION AND ELEPHANT AND ZEBRA LION
  • 34. TREE 2 WITH COSTS COST OF ANIMAL  2. (elephant, zebra, lion) GREATER THAN ZEBRA=Q(3)* 2=.1 Elephant 1/7 ZebraQ(0): AN 2/7ANIMALLESS THANELEPHANT.15 Lion 3/7 Q(3):.1 GREATER THAN Q(1): .2 .15 Q(2): THE ZEBRA BETWEEN BETWEEN LION AND ELEPHANT AND ZEBRA LION
  • 35. TREE 2 WITH COSTS  2. (elephant, zebra, lion) TOTAL COST OF TREE = 1.6 Elephant 1/7 ZebraQ(0): AN 2/7ANIMALLESS THANELEPHANT.15 Lion 3/7 .1 Q(3): GREATER THAN Q(1): .3 .15 Q(2): THE ZEBRA BETWEEN BETWEEN LION AND ELEPHANT AND ZEBRA LION
  • 36. THE TREES The animals can be entered in the zoo in various orders--- 1. (elephant, lion, zebra) COST=1.5 2. (elephant, zebra, lion) COST=1.6 3. (lion, elephant, zebra) 4. (lion, zebra, elephant) 5. (zebra, lion, elephant) 6. (zebra, elephant, lion)
  • 37. TREE 3 3. (lion, elephant, zebra) lion THE FIRST ANIMAL TO ENTER THE ZOO IS THE LION SO IT OCCUPIES THE ROOT NODE
  • 38. TREE 3 3. (lion, elephant, zebra) lion elephant THE SECOND ANIMAL TO ENTER THE ZOO IS THE ELEPHANT AND IT OCCUPIES THE NODE TO THE LEFT OF THE LION AS ELEPHANT<LION.
  • 39. TREE 3 3. (lion, elephant, zebra) lion elephant zebra THE THIRD ANIMAL TO ENTER THE ZOO IS THE ZEBRA AND IT OCCUPIES THE NODE TO THE RIGHT OF THE LION AS LION<ZEBRA.
  • 40. TREE 3 WITH FAILURE NODES  3. (lion, elephant, zebra) lion elephant zebraANIMALLESS THANELEPHANT
  • 41. TREE 3 WITH FAILURE NODES  3. (lion, elephant, zebra) lion elephant zebraANIMAL ANIMALLESS THAN BETWEENELEPHANT ELEPHANT AND LION
  • 42. TREE 3 WITH FAILURE NODES  3. (lion, elephant, zebra) lion elephant zebraANIMAL ANIMAL ANIMALLESS THAN BETWEEN BETWEENELEPHANT ELEPHANT AND THE LION AND LION ZEBRA
  • 43. TREE 3 WITH FAILURE NODES  3. (lion, elephant, zebra) lion elephant zebra ANIMALANIMAL ANIMAL ANIMAL GREATERLESS THAN BETWEEN BETWEEN THAN THEELEPHANT ELEPHANT AND THE LION AND ZEBRA LION ZEBRA
  • 44. TREE 3 WITH COSTS COST OF FINDING THE  3. (lion, elephant, zebra) LION= 1 COMPARISON =.2 lion .2 elephant zebra ANIMALANIMAL ANIMAL ANIMAL GREATERLESS THAN BETWEEN BETWEEN THAN THEELEPHANT ELEPHANT AND THE LION AND ZEBRA LION ZEBRA
  • 45. TREE 3 WITH COSTS COST OF FINDING THE  3. (lion, elephant, zebra) ELEPHANT= 2 COMPARISONS=2*.5=1 lion .2 elephant zebra 1 ANIMALANIMAL ANIMAL ANIMAL GREATERLESS THAN BETWEEN BETWEEN THAN THEELEPHANT ELEPHANT AND THE LION AND ZEBRA LION ZEBRA
  • 46. TREE 3 WITH COSTS COST OF FINDING THE  3. (lion, elephant, zebra) LION= 2 COMPARISONS=2*.05=. 1 lion .2 elephant 1 zebra .1 ANIMALANIMAL ANIMAL ANIMAL GREATERLESS THAN BETWEEN BETWEEN THAN THEELEPHANT ELEPHANT AND THE LION AND ZEBRA LION ZEBRA
  • 47. TREE 3 WITH COSTS COST OF FINDING AN  3. (lion, elephant, zebra) ANIMAL LESS THAN THE ELEPHANT= 2 COMPARISONS=2*.15=. 3 lion .2 elephant 1 zebra .1 ANIMALANIMAL ANIMAL ANIMAL GREATERLESS THAN BETWEEN BETWEEN .3 THAN THEELEPHANT ELEPHANT AND THE LION AND ZEBRA LION ZEBRA
  • 48. TREE 3 WITH COSTS COST OF FINDING AN  3. (lion, elephant, zebra) ANIMAL BETWEEN THE ELEPHANT AND THE LION= 2 COMPARISONS=2*.1=.2 lion .1 elephant 1 zebra .1 ANIMALANIMAL ANIMAL .2 ANIMAL GREATERLESS THAN BETWEEN BETWEEN .3 THAN THEELEPHANT ELEPHANT AND THE LION AND ZEBRA LION ZEBRA
  • 49. TREE 3 WITH COSTS COST OF FINDING AN 3. (lion, elephant, zebra) ANIMAL BETWEEN THE LION AND THE ZEBRA= 2 COMPARISONS=2*.05=. 1 lion .1 elephant 1 zebra .1 ANIMALANIMAL ANIMAL .2 ANIMAL .1 GREATERLESS .3 BETWEEN BETWEEN THAN THETHAN 2/7 ELEPHANT AND THE LION AND ZEBRAELEPHANT LION ZEBRA
  • 50. TREE 3 WITH COSTS COST OF FINDING AN  3. (lion, elephant, zebra) ANIMAL GREATER THAN THE ZEBRA= 2 COMPARISONS=2*.05= .1 lion .1 elephant 1 zebra .1 ANIMAL .1ANIMAL ANIMAL .2 ANIMAL .1 GREATERLESS THAN BETWEEN BETWEEN .3 THAN THEELEPHANT ELEPHANT AND THE LION AND ZEBRA LION ZEBRA
  • 51. TREE 3 WITH COSTS  3. (lion, elephant, zebra) COST OF TREE =1.9 lion .1 elephant 1 zebra .1 ANIMAL .1ANIMAL ANIMAL .2 ANIMAL .1 GREATERLESS THAN BETWEEN BETWEEN .3 THAN THEELEPHANT ELEPHANT AND THE LION AND ZEBRA LION ZEBRA
  • 52. THE TREES The animals can be entered in the zoo in various orders--- 1. (elephant, lion, zebra) COST=1.5 2. (elephant, zebra, lion) COST=1.6 3. (lion, elephant, zebra) COST=1.9 4. (lion, zebra, elephant) 5. (zebra, lion, elephant) 6. (zebra, elephant, lion)
  • 53. TREE 4 4. (lion, zebra, elephant)
  • 54. TREE 4 4. (lion, zebra, elephant)
  • 55. TREE 4 4. (lion, zebra, elephant)
  • 56. TREE 4 WITH FAILURE NODES 4. (lion, zebra, elephant)
  • 57. TREE 4 WITH FAILURE NODES 4. (lion, zebra, elephant)
  • 58. TREE 4 WITH FAILURE NODES 4. (lion, zebra, elephant)
  • 59. TREE 4 WITH FAILURE NODES 4. (lion, zebra, elephant)
  • 60. TREE 4 WITH FAILURE NODES TREE 3 IS 4. (lion, zebra, elephant) IDENTICAL TO TREE 3 AND HENCE ITS COST IS 1.9
  • 61. THE TREES The animals can be entered in the zoo in various orders--- 1. (elephant, lion, zebra) COST=1.5 2. (elephant, zebra, lion) COST=1.6 3. (lion, elephant, zebra) COST=1.9 4. (lion, zebra, elephant) COST=1.9 5. (zebra, lion, elephant) 6. (zebra, elephant, lion)
  • 62. TREE 5 5. (zebra, lion, elephant)
  • 63. TREE 5 5. (zebra, lion, elephant)
  • 64. TREE 5 5. (zebra, lion, elephant)
  • 65. TREE 5 WITH FAILURE NODES 5. (zebra, lion, elephant)
  • 66. TREE 5 WITH FAILURE NODES 5. (zebra, lion, elephant)
  • 67. TREE 5 WITH FAILURE NODES 5. (zebra, lion, elephant)
  • 68. TREE 5 WITH FAILURE NODES 5. (zebra, lion, elephant)
  • 69. TREE 5 WITH COSTS 5. (zebra, lion, elephant)
  • 70. TREE 5 WITH COSTS 5. (zebra, lion, elephant)
  • 71. TREE 5 WITH COSTS 5. (zebra, lion, elephant)
  • 72. TREE 5 WITH COSTS 5. (zebra, lion, elephant)
  • 73. TREE 5 WITH COSTS 5. (zebra, lion, elephant)
  • 74. TREE 5 WITH COSTS 5. (zebra, lion, elephant)
  • 75. TREE 5 WITH COSTS 5. (zebra, lion, elephant)
  • 76. TREE 5 COST 5. (zebra, lion, elephant)
  • 77. THE TREES The animals can be entered in the zoo in various orders--- 1. (elephant, lion, zebra) COST=1.5 2. (elephant, zebra, lion) COST=1.6 3. (lion, elephant, zebra) COST=1.9 4. (lion, zebra, elephant) COST=1.9 5. (zebra, lion, elephant) COST=2.65 6. (zebra, elephant, lion)
  • 78. TREE 6 6. (zebra, elephant, lion)
  • 79. TREE 6 6. (zebra, elephant, lion)
  • 80. TREE 6 6. (zebra, elephant, lion)
  • 81. TREE 6 WITH FAILURE NODES 6. (zebra, elephant, lion)
  • 82. TREE 6 WITH FAILURE NODES 6. (zebra, elephant, lion)
  • 83. TREE 6 WITH FAILURE NODES 6. (zebra, elephant, lion)
  • 84. TREE 6 WITH FAILURE NODES 6. (zebra, elephant, lion)
  • 85. TREE 6 WITH COSTS 6. (zebra, elephant, lion)
  • 86. TREE 6 WITH COSTS 6. (zebra, elephant, lion)
  • 87. TREE 6 WITH COSTS 6. (zebra, elephant, lion)
  • 88. TREE 6 WITH COSTS 6. (zebra, elephant, lion)
  • 89. TREE 6 WITH COSTS 6. (zebra, elephant, lion)
  • 90. TREE 6 WITH COSTS 6. (zebra, elephant, lion)
  • 91. TREE 6 WITH COSTS 6. (zebra, elephant, lion)
  • 92. TREE 6 FINAL COST 6. (zebra, elephant, lion)
  • 93. THE TREES The animals can be entered in the zoo in various orders--- 1. (elephant, lion, zebra) COST=1.5 2. (elephant, zebra, lion) COST=1.6 3. (lion, elephant, zebra) COST=1.9 4. (lion, zebra, elephant) COST=1.9 5. (zebra, lion, elephant) COST=2.65 6. (zebra, elephant, lion) COST=2.0
  • 94. OPTIMAL TREE THE OPTIMAL BINARY SEARCH TREE IS 1. (elephant, lion, zebra)

×