Question

In: Computer Science

Beginning with an empty binary search tree, what binary search tree is formed when you insert...

Beginning with an empty binary search tree, what binary search tree is formed when you insert the following values in the given order – consider there alphabetical position for comparison.

a. W, T, N, J, E, B, A

b. W, T, N, A, B, E, J

c. A, B, W, J, N, T, E

d. B, T, E, A, N, W, J

Alphabetical positions: A-1, B-2, E-5, J-10, N-14,T-20,W-23

Solutions

Expert Solution

a. W, T, N, J, E, B, A

W is root

T < W , add in left

N<W , N<T  add in left

J<W , J<T , J<N add in left

E<W , E<T, E<N,E<J add in left

B<W , B<T , B<N , B<J , add in left

A<W , A<T , A<N , A<J , A<B add in left

b. W, T, N, A, B, E, J

W is root

T<W add in left

N<W , N<T add in left

A<W , A<T , A<N add in left

B<W , B<T , B<N , B>A add in right

E<W , E<T , E<N , E>A , E>B  add in right

J<W , J<T , J<N , J>A , J>B , J>E add in right

c. A, B, W, J, N, T, E

A is root

B>A add in right

W>A , W>B add in right

J>A , J>B , J<W add in left

N>A , N>B , N<W , N>J add in right

T>A , T>B , T<W , T>J , T>N , add in right

E>A , E>B , E<W , E<J go left , add in left

d. B, T, E, A, N, W, J

B is root

T>B add in right

E>B ,E<T add in left

A<B add in left

N>B , go right , N<T , N>E add in right

W>B , go right , W>T , add in right

J>B , go right , J<T , go left , J<N add in left


Related Solutions

c++ Binary Search Tree: find parent of a node please insert comment to explain what the...
c++ Binary Search Tree: find parent of a node please insert comment to explain what the code do. Use struct Node{ int data; Node* left; Node* right};
In MobaXterm, with the use of the binary search tree. Implement four operations of insert, in-order...
In MobaXterm, with the use of the binary search tree. Implement four operations of insert, in-order traversal, preorder traversal, and find. Please separate the code in the four parts and explain in detail what is happening. Also, if you can please basic C language. If not, then I understand. Thank you for your time. The test cases are 'm', 'd', 'g', 'r', 'p', 'b', and 'x'. Output: Enter choice (lower case is also acceptable) --- (I)nsert, (F)ind, (Q)uit: i Enter...
/** * This class implements a basic Binary Search Tree that supports insert and get operations....
/** * This class implements a basic Binary Search Tree that supports insert and get operations. In * addition, the implementation supports traversing the tree in pre-, post-, and in-order. Each node * of the tree stores a key, value pair. * * @param <K> The key type for this tree. Instances of this type are used to look up key, value * pairs in the tree. * @param <V> The value type for this tree. An instance of this...
Prerequisite Knowledge Understand binary search tree structure Understand binary search tree operations Understand binary search tree...
Prerequisite Knowledge Understand binary search tree structure Understand binary search tree operations Understand binary search tree worst case and best case time. Learning Outcomes Describe AVL tree structure Trace and implement AVL tree operations Explain and prove AVL tree performance
​Define a tree. Distinguish between a tree and a binary tree. Distinguish between a binary tree and a binary search tree.
Define a tree. Distinguish between a tree and a binary tree. Distinguish between a binary tree and a binary search tree.
Lab 5: Binary Search Tree Implement operations for a Binary Search Tree class starting from the...
Lab 5: Binary Search Tree Implement operations for a Binary Search Tree class starting from the template provided under the PolyLearn assignment, using the class TreeNode that is also provided. You may (should) implement helper methods that make your code easier to write, read, and understand. You will also need to write test cases of your own as you develop the methods. You may use iterative and/or recursive functions in your implementation. The following starter files are available . •...
Binary Tree Create a binary search tree using the given numbers in the order they’re presented....
Binary Tree Create a binary search tree using the given numbers in the order they’re presented. State if the resulting tree is FULL and/or BALANCED. 37, 20, 18, 56, 40, 42, 12, 5, 6, 77, 20, 54
In this assignment you will create a Binary Search Tree to storeand retrieve objects of...
In this assignment you will create a Binary Search Tree to store and retrieve objects of type ItemType. The purpose of this assignment is for you to become familiar with basic tree operations, and understand the efficiency of trees compared to previously studied data structures. Binary Tree nodes have only two children, left and right. Nodes are compared based on their Key instance variable, which in this assignment is of type ItemType. All elements in the left subtree of a...
You are given a reference to the root node of a binary search tree, that implements...
You are given a reference to the root node of a binary search tree, that implements a dictionary data structure. Please print all the elements in depths 500 through 510, all in sorted order. A node in a binary search tree is at depth x, if it takes x hops to get from the root. So the root is at depth 0, the children of the root are at depth 1, and so on. The class TreeNode defines a single...
Some questions about Binary Tree's What a binary search tree is and what its advantages/disadvantages are?...
Some questions about Binary Tree's What a binary search tree is and what its advantages/disadvantages are? What trees and binary trees are? How data is inserted into a binary tree? What full and complete binary trees look like? How to perform pre, in, and post-order traversals of a tree?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT