Question

In: Computer Science

Research the topic of binary search trees. Write a brief summary of your understanding of this....

Research the topic of binary search trees. Write a brief summary of your understanding of this. Design a simple program, using pseudocode, that performs a search of a binary search tree.. In your own words, explain how a binary search tree works using graph theory terminology. Construct a binary search tree for any alphabetically ordered list of five words. Represent it visually as a graph. Discuss any characteristics you note about the graph you created in part (d). In your discussion, make sure to address the following: What are the degrees of each vertex? Is it a complete graph? Is the graph planar?

Solutions

Expert Solution

Binary Search Tree is a node-based binary tree data structure which has the following properties:

· The left subtree of a node contains only nodes with keys lesser than the node’s key.

· The right subtree of a node contains only nodes with keys greater than the node’s key.

· The left and right subtree each must also be a binary search tree.

               

Pseudo code(algorithm)

If root == NULL

    return NULL;

If number == root->data

    return root->data;

If number < root->data

    return search(root->left)

If number > root->data

    return search(root->right)

Explanation in words

4 is not found so, traverse through the left subtree of 8

4 is not found so, traverse through the right subtree of 3

4 is not found so, traverse through the left subtree of 6 And then it found after 6

If the value is found, we return the value so that it gets propagated in each recursion step as shown in the image below.

If you might have noticed, we have called return search(struct node*) four times. When we return either the new node or NULL, the value gets returned again and again until search(root) returns the final result.

If the value is not found, we eventually reach the left or right child of a leaf node which is NULL and it gets propagated and returned.

Degrees of each vertex

Complete graph

Planar graph


Related Solutions

Considering the following different search trees, binary search trees, AVL trees, red-black trees, and others. Compare...
Considering the following different search trees, binary search trees, AVL trees, red-black trees, and others. Compare their advantages and disadvantages, running times, etc
Binary Search Trees with Lazy Deletion Implement binary search tree class with lazy deletion that has...
Binary Search Trees with Lazy Deletion Implement binary search tree class with lazy deletion that has TreeNode as nested class in Java. Design the class, TreeNode to have following class variables: int key; // All Keys are in the range 1 to 99 TreeNode leftChild; TreeNode rightChild; boolean deleted; Your program method must have routines to do the following operations. 1. insert //Should insert a new element to a leaf node. If new element is aduplicatethen do nothing. If the...
using empirical research checklist search for empirical article and write an annotation concise summary in your...
using empirical research checklist search for empirical article and write an annotation concise summary in your own words and APA format (1) Does breastfeeding help to reduce the risk of childhood obesity (2) a systematic review and meta-analysis of the effect of lifestyle modification on metabolic control in overweight children?
Please give a brief written summary of your Mead . What is your basic understanding of...
Please give a brief written summary of your Mead . What is your basic understanding of what Mead had to say about "The Self"? how does this relate or not to other theorists you've read so far?
In C++, dealing with Binary Search trees. Implement search, insert, removeLeaf, and removeNodeWithOneChild methods in BST.h....
In C++, dealing with Binary Search trees. Implement search, insert, removeLeaf, and removeNodeWithOneChild methods in BST.h. BST.h code below. CPP code also provided for reference, nothing to be changed on cpp code. #include #include "BSTNode.h" using namespace std; #ifndef BST_H_ #define BST_H_ class BST { public: BSTNode *root; int size; BST() { root = NULL; size = 0; } ~BST() { if (root != NULL) deepClean(root); } BSTNode *search(int key) { // complete this method } BSTNode *insert(int val) {...
In C++, dealing with Binary Search trees. Implement search, insert, removeLeaf, and removeNodeWithOneChild methods in BST.h....
In C++, dealing with Binary Search trees. Implement search, insert, removeLeaf, and removeNodeWithOneChild methods in BST.h. BST.h code below #include <iostream> #include "BSTNode.h" using namespace std; #ifndef BST_H_ #define BST_H_ class BST { public: BSTNode *root; int size; BST() { root = NULL; size = 0; } ~BST() { if (root != NULL) deepClean(root); } BSTNode *search(int key) { // complete this method } BSTNode *insert(int val) { // complete this method } bool remove(int val) { // complete this...
In C++, dealing with Binary Search trees. Implement search, insert, removeLeaf, and removeNodeWithOneChild methods in BST.h....
In C++, dealing with Binary Search trees. Implement search, insert, removeLeaf, and removeNodeWithOneChild methods in BST.h. BST.h code below #include <iostream> #include "BSTNode.h" using namespace std; #ifndef BST_H_ #define BST_H_ class BST { public: BSTNode *root; int size; BST() { root = NULL; size = 0; } ~BST() { if (root != NULL) deepClean(root); } BSTNode *search(int key) { // complete this method } BSTNode *insert(int val) { // complete this method } bool remove(int val) { // complete this...
(The topic about citation) . Write a summary of a scientific topic at your choice in...
(The topic about citation) . Write a summary of a scientific topic at your choice in civil engineer.You should cite at least two different types of sources (Book, Article, report, website, etc).The citation may be a paraphrase or summary; the direct quotation should not exceed 10%.Use proper citation style, e.g.APA,The summary should not exceed one-page including the references ( on the program word 12 font size and single line space)Note:(1) Avoid plagiarism, copying and pasting.(2)I want the references that you...
Based on your understanding of the topic, conduct a research and create a report on the...
Based on your understanding of the topic, conduct a research and create a report on the political battle for universal healthcare in the United States. Your report should include the following elements: History of the national healthcare reform starting from the early days struggle for a national health plan to the present day. Political struggle to pass PPACA. Political impact of Medicare and Medicaid on the push for universal coverage. Major issues from the legislative and executive (presidential) perspective. Who...
Derive a recurrence for the number of degenerate binary search trees that can be generated from...
Derive a recurrence for the number of degenerate binary search trees that can be generated from a given sequence of n distinct elements. Recall that degenerate binary search tree contains no branches and thus is structurally similar to a linked list. You must make an argument to justify each component of your recurrence. Remember that all recurrences have base cases so do not forget to include a base case.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT