9 Dsa
9 Dsa
#include <vector>
#include <limits>
struct Node {
int key;
Node* left;
Node* right;
int r = root[i][j];
Node* node = new Node(keys[r]);
return node;
}
if (c < cost[i][j]) {
cost[i][j] = c;
root[i][j] = r;
}
}
}
}
int main() {
int n;
cout << "Enter the number of keys: ";
cin >> n;
vector<int> keys(n);
vector<double> prob(n);
double minCost;
int rootKey;
cout << "\nOptimal BST constructed with minimum search cost: " << minCost <<
endl;
cout << "and the root of the tree: " << rootKey << endl;
return 0;
}