is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
1.find the max and min of the given tree, in BST its the right most and left most elements,so thorugh findmax() and findmin() we get the same
- underdog October 12, 20112.we increment the minnode and decrement maxnode ,so that the checking we are doing won't fail at the leftmost and rightmost nodes
3.traverse through each node and check wheteher they lie in the suiatable range or not
4.revert back the change we made
typedef struct node
{
int data;
struct node *right;
struct node *left;
}node;
void findmax(node *root,node **maxnode);
void findmin(node *root, node **minnode);
int check_BST(node *root, int min, int max);
int main()
{
int min,max;
node *root,**maxnode,**minnode;
findmax(root);
findmin(root);
if(*maxnode == NULL || *minnode ==NULL)
return -1;
min=(*min)->data++;
max=(*max)->node--;
if(check_BST(root,min,max));
printf("\n valid BST");
else
printf("\n non-valid BST");
(*min)->data++;
(*max)->data--;
}
void findmin(node *root, node **minnode)
{
if(root== NULL)
return NULL;
while(root->left)
root=root->left;
*minnode=root;
}
void findmax(node *root,node **maxnode)
{
if(root== NULL)
return NULL;
while(root->right)
root=root->right;
*maxnode=root;
}
int check_BST( node *root, int min, int max)
{
if(root == NULL)
return 1;
if(root->data < max && root->data >min)
{
return( check_bst(root->left,min,root->data) && check_BST(root->right,root->data, max));
}
else
return 0;
}