Professional Documents
Culture Documents
optimal binary search tree
optimal binary search tree
optimal binary search tree
h>
#include <limits.h>
if (j < i)
return 0;
if (j == i)
return freq[i];
int main()
{
int keys[] = {10, 12};
int freq[] = {34,50};
int n = sizeof(keys)/sizeof(keys[0]);
printf("Cost of Optimal BST is %d ",
optimalSearchTree(keys, freq, n));
return 0;
}
/*
ryk@pc216:~/DAA_12$ cc optimal_binary.c
ryk@pc216:~/DAA_12$ ./a.out
Cost of Optimal BST is 142
*/