Professional Documents
Culture Documents
Bool Empty : Returns 1 If There Is No Element Stored in The Structure Void Add (Int V) : Adds A New Element Equal To V in The Structure
Bool Empty : Returns 1 If There Is No Element Stored in The Structure Void Add (Int V) : Adds A New Element Equal To V in The Structure
2. You are given the pre-order of a binary tree (missing children are indicated by the symbol null).
Example: 4 1 null 3 null null 7 6 null null null
Decide whether this is a binary search tree.
The running time should be in O(n) /5
//One solution would be to construct the binary tree and to check whether it is a
binary search tree
//We here propose a slightly different solution where we needn’t construct the tree
int value;
bool right;
stack<int> dfs; //in order to simulate the tree
f.close();
return bst;