Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
Loading in …5
×

# E25obstb

298 views

Published on

jntu qualitative visual algorithms

Published in: Entertainment & Humor
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

• Be the first to like this

### E25obstb

1. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 14. Elephant.5 Lion Zebra COST OF FINDING THE ELEPHANT = 1 COMPARISON =1*.5=.5
15. 15. Elephant.5 Lion .2 zebra COST OF FINDING THE LION = 2 COMPARISONS =2*.1=.2
16. 16. Elephant.5 Lion .2 Zebra .15 COST OF FINDING THE ZEBRA = 3 COMPARISONS =3*.05=.15
17. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 40. TREE 3 WITH FAILURE NODES  3. (lion, elephant, zebra) lion elephant zebraANIMALLESS THANELEPHANT
41. 41. TREE 3 WITH FAILURE NODES  3. (lion, elephant, zebra) lion elephant zebraANIMAL ANIMALLESS THAN BETWEENELEPHANT ELEPHANT AND LION
42. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 53. TREE 4 4. (lion, zebra, elephant)
54. 54. TREE 4 4. (lion, zebra, elephant)
55. 55. TREE 4 4. (lion, zebra, elephant)
56. 56. TREE 4 WITH FAILURE NODES 4. (lion, zebra, elephant)
57. 57. TREE 4 WITH FAILURE NODES 4. (lion, zebra, elephant)
58. 58. TREE 4 WITH FAILURE NODES 4. (lion, zebra, elephant)
59. 59. TREE 4 WITH FAILURE NODES 4. (lion, zebra, elephant)
60. 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. 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. 62. TREE 5 5. (zebra, lion, elephant)
63. 63. TREE 5 5. (zebra, lion, elephant)
64. 64. TREE 5 5. (zebra, lion, elephant)
65. 65. TREE 5 WITH FAILURE NODES 5. (zebra, lion, elephant)
66. 66. TREE 5 WITH FAILURE NODES 5. (zebra, lion, elephant)
67. 67. TREE 5 WITH FAILURE NODES 5. (zebra, lion, elephant)
68. 68. TREE 5 WITH FAILURE NODES 5. (zebra, lion, elephant)
69. 69. TREE 5 WITH COSTS 5. (zebra, lion, elephant)
70. 70. TREE 5 WITH COSTS 5. (zebra, lion, elephant)
71. 71. TREE 5 WITH COSTS 5. (zebra, lion, elephant)
72. 72. TREE 5 WITH COSTS 5. (zebra, lion, elephant)
73. 73. TREE 5 WITH COSTS 5. (zebra, lion, elephant)
74. 74. TREE 5 WITH COSTS 5. (zebra, lion, elephant)
75. 75. TREE 5 WITH COSTS 5. (zebra, lion, elephant)
76. 76. TREE 5 COST 5. (zebra, lion, elephant)
77. 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. 78. TREE 6 6. (zebra, elephant, lion)
79. 79. TREE 6 6. (zebra, elephant, lion)
80. 80. TREE 6 6. (zebra, elephant, lion)
81. 81. TREE 6 WITH FAILURE NODES 6. (zebra, elephant, lion)
82. 82. TREE 6 WITH FAILURE NODES 6. (zebra, elephant, lion)
83. 83. TREE 6 WITH FAILURE NODES 6. (zebra, elephant, lion)
84. 84. TREE 6 WITH FAILURE NODES 6. (zebra, elephant, lion)
85. 85. TREE 6 WITH COSTS 6. (zebra, elephant, lion)
86. 86. TREE 6 WITH COSTS 6. (zebra, elephant, lion)
87. 87. TREE 6 WITH COSTS 6. (zebra, elephant, lion)
88. 88. TREE 6 WITH COSTS 6. (zebra, elephant, lion)
89. 89. TREE 6 WITH COSTS 6. (zebra, elephant, lion)
90. 90. TREE 6 WITH COSTS 6. (zebra, elephant, lion)
91. 91. TREE 6 WITH COSTS 6. (zebra, elephant, lion)
92. 92. TREE 6 FINAL COST 6. (zebra, elephant, lion)
93. 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. 94. OPTIMAL TREE THE OPTIMAL BINARY SEARCH TREE IS 1. (elephant, lion, zebra)