Datastructures - Binary Search Tree

page 1 out of 4

page 1 out of 4


Question 1     

Preorder of a BST is 23,7,5,19,8,95,67. What can you say about it's post order?







Question 3     

 There must be no duplicate nodes in Binary Search Tree





Question 5     

What of the following statements is correct about time complexities of finding maximum element in Binary Tree Vs Binary Search Tree in Worst Case?





Question 6     

What of the following statements is correct about the time complexities of finding the maximum element in Binary Tree Vs Binary Search Tree in Average  Case?






Question 7     

What of the following statements is correct about the time complexities of finding maximum element in Binary Tree Vs Binary Search Tree in Best  Case?







Question 8     

What does the following code snippet do?

Node find(Node node, int key) {
    if (node == null) {
        node = new Node(key);
        return node;
    }
    if (key < node.key)
        node.left = find(node.left, key);
    else if (key > node.key)
        node.right = find(node.right, key);
    return node;
}





Question 9     

What does the following code snippet do?

public Node find(Node node, int key)
{
    if (node==null || node.key==key)
        return node;
    if (node.key > key)
        return find(node.left, key);
    return find(node.right, key);
}





Question 10     

What does the following code snippet do?

Node find(Node node, int key)
{
    if (node == null)  return node;
    if (key < node.key)
        node.left = find(node.left, key);
    else if (key > node.key)
        node.right = find(node.right, key);
    else
    {
        if (node.left == null)
            return node.right;
        else if (node.right == null)
            return node.left;
        node.key = minValue(node.right);
        node.right = find(node.right, node.key);
    }
    return node;
}




page 1 out of 4

page 1 out of 4


Sign Up Page

Oops!!

To view the solution need to Login



Score : 0 / 0
L
o
a
d
i
n
g
.
.
.