Question

In: Computer Science

What is a binary search tree or BST? Discuss its characteristics. What are other types of...

What is a binary search tree or BST? Discuss its characteristics. What are other types of binary trees as well?

Solutions

Expert Solution

Binary Search Tree: It is one of the data structures. And it is node-based.

Characteristics of Binary Search tree:

  1. The left subtree of a node contains only nodes with keys lesser than the node’s key.
  2. The right subtree of a node contains only nodes with keys greater than the node’s key.
  3. The left and right subtree each must also be a binary search tree.

Example:

Explanation :

Here the root node is 8.And Left of 8 is 3 which is less than the root node.And Right of 8 is 10 which is greater than root node.So,here 1st and 2nd characteristics are true.

Now , Take the node 3.Left of 3 is 1 which is less than the 3.And Right of 3 is 6 which is greater than the 3.

Types of Binary Tree :

1. Full Binary Tree : The binary tree is called full binary tree if every node has 0 or 2 children.

Example:

Here every node has 2 childrens except leaf nodes.Leaf nodes are nothing but the left and right child nodes are null.Null means 0 children.Here 3 ,6,7 are leaf nodes.

2.Complete Binary Tree : A Binary Tree is a Complete Binary Tree if all the levels are completely filled except possibly the last level and the last level has all keys as left as possible.

Example :

Here all the levels are filled but not the last level and in last level the more nodes are in left.

3.Perfect Binary Tree : A Binary tree is a Perfect Binary Tree in which all the internal nodes have two children and all leaf nodes are at the same level.

Here each node has 2 childrens and all the lead nodes are at same level i.e.,level-5.

4. A degenerate tree : A Tree where every internal node has one child.It is also called pathological tree.

Here every internal node has one child.


Related Solutions

I was trying to implement a simple binary search tree using this given class of bst...
I was trying to implement a simple binary search tree using this given class of bst in c++ public: BST(); ~BST(); void insertKey(int newKey); bool hasKey(int searchKey); std::vector<int> inOrder(); int getHeight(); however; i am still required to use another class for the nodes as a pointer and i need to manage memory leak. in main we should ask for the numbers we need to insert in the binary search tree and also let the user end it with a letter...
Show how to augment the ordinary Binary Search Tree (BST) data structure so that it supports...
Show how to augment the ordinary Binary Search Tree (BST) data structure so that it supports an efficient procedure which, on input (x, k) where x is the root of a BST and k an integer, output the k-th smallest number store in the BST. Let n denote the total number of elements stored in the BST, what is the running time of your efficient procedure? How does your modification of the BST data structure affect the performance of other...
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
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
​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.
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?
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 . •...
What does the level of a binary search tree mean in relation to its searching efficiency?...
What does the level of a binary search tree mean in relation to its searching efficiency? In your response discuss what the maximum number of levels to implement a search tree with 100 nodes and what is the minimum number of levels for 100 nodes. In your response to other students discuss if you agree with the other student’s number of levels, how the number of levels was determined and the Big-O efficiency of the maximum and a minimum number...
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
PLEASE READ CAREFULY AND EXPLAIN YOUR WORK: (JavaScript) only Search the Tree: A binary search tree...
PLEASE READ CAREFULY AND EXPLAIN YOUR WORK: (JavaScript) only Search the Tree: A binary search tree is a data structure that consists of JavaScript objects called "nodes". A tree always has a root node which holds its own integer value property and can have up to two child nodes (or leaf nodes), a left and right property. A leaf node holds a value attribute and, likewise, a left and right attribute each potentially pointing to another node in the binary...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT