Algorithm 1 - Constructing the BST
ConstructBST
{
foreach flyer // n flyers
{
insert flyer in the BST // O(log n) or O(n) worst case
}
}
---------------------------------------------------------
Algorithm 2 - Picking
input: array A[1..n] with elements sorted in non-crescent oreder
N, the number of elements in the array
output: array B[1..log n] with (log n) higher flyers
Picking
{
total = log N
for i =1 to total
{
B[i] = A[i]
}
}
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
15 Experts available now in Live!