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

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?
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) {...
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?
(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.
Write a function in Python that adds two Binary Trees together. The inputs of your function...
Write a function in Python that adds two Binary Trees together. The inputs of your function should be two binary trees (or their roots, depending on how you plan on coding this), and the output will be one Binary Tree that is the sum of the two inputted. To add Binary Trees together: Add the values of nodes with the same position in both trees together, this will be the value assigned to the node of the same position in...
Draft a brief introduction explaining a research topic of your choice, including a discussion of your...
Draft a brief introduction explaining a research topic of your choice, including a discussion of your research question and hypotheses. Locate three peer-reviewed academic sources that have been published within the last 5 years. Draft an annotated bibliography for your three sources. Conclude your assignment with a summary of why these sources are important.
What is your understanding of mentoring? Why do nurses need mentors? Give a brief summary of...
What is your understanding of mentoring? Why do nurses need mentors? Give a brief summary of each section of this Paper. DO NOT copy-and-paste the paper. Mentoring in Nursing (1 points) Benefits of Mentoring (1 points) Mentoring Relationships (1.5 points) Characteristics of a Healthy Mentor-Mentee Relationship (1.5 points) Mentoring Cycle (1 points) Reflection in Mentoring (1 points) Barriers to Mentoring (1.5 points) Give a brief contrast of a tutor vs mentor, vs friend, vs instructor. (1.5 points)
Write a brief summary of the AIS used at your place of employment. If you are...
Write a brief summary of the AIS used at your place of employment. If you are not currently employed, you may use a previous employer or interview an acquaintance about the AIS used at his or her workplace. If you have not been employed, interview a friend or family member. Assume you are an accounting manager at this organization and, reflecting on the concepts covered in this course, describe the changes that you would make to the internal control structure....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT