2. Describe how the concept of a Binary Search Tree (BST) is an example of both a greedy algorithm and a divide & conquer algorithm?
Greedy Binary Search Tree
are not destined to be ideal, yet they are destined to be almost ideal. Other unmistakable, almost ideal, tree developments are found in Mehlhorn [1975, 1977] and in Horibe and Nemetz [1979]. An examination of all these and different calculations for the age of almost ideal twofold inquiry trees shows up in Korsh [1982]. The verification that the accompanying voracious strategy yields almost ideal trees is in Korsh [1981].
In building an almost ideal double hunt tree by the ravenous technique, the software engineer should guarantee that the arrangement is a paired pursuit tree. Taking a gander at the ideal tree found by the previous segment's calculation will give the thought behind the ravenous tree development. Think about the tree being produced by making the subtrees , consistently, beginning with the subtree with k4 at its root and finishing with the last ideal tree. Each subtree has its worth (the amount of its loads) related with it.
Example - Activity Selection
Issue: for a given arrangement of exercises a1 ... an, every ai utilizing an asset solely in span [si, fi), discover a timetable that boost the quantity of viable exercises.
Dynamic programming arrangement: think about Sij, the arrangement of all exercises viable with ai and aj where fi < sj, at that point at last choose the size of the greatest viable subset of S0,n+1. For each Sij, the size of the greatest viable subset can be acquired by experiencing all ak in the set, so to recursively diminish the issue to Sik and Skj.
Avaricious arrangement: recursively discover the movement that is viable with the current timetable while having the most punctual completion time, and add it into the timetable.
The arrangement can be end up being ideal: the most punctual completed movement should be in the ideal arrangement.
A recursive calculation at first called as Recursively-Activity-Selector(s, f, 0, n+1), with the exercises arranged by finish time.
Step by step
Solved in 2 steps