QuestionQuestion

Goal:
In our video lecture, we discussed the Binary Search Tree data structure. In the Hands On session, we implemented the class BinarySearchTree that adds elements into instances of that class. Using that code as your starter code, implement the following methods into the
BinarySearchTree class:
• The property method getMin that returns the minimum Node value found in the tree. If tree is empty, method returns None. Note that the entire tree does not need to be scanned to find the minimum.
• getHeight(node_object) that returns the height of the given node as an integer. You can assume the node is in the tree. Recursion could be helpful here
• isEmpty() tests to see whether the tree is empty. It needs no parameters and returns a boolean value.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

# Lab #6
# Due Date:
########################################
#                                    
# Name:
# Collaboration Statement:            
#
########################################

class Node:
    def __init__(self, value):
       self.value = value
       self.left = None
       self.right = None

    def __str__(self):
       return ("Node({})".format(self.value))

    __repr__ = __str__


class BinarySearchTree:
    '''
       >>> x=BinarySearchTree()
       >>> x.isEmpty()
       True
       >>> x.insert(x.root,9)
       >>> x.insert(x.root,4)
       >>> x.insert(x.root,11)
       >>> x.insert(x.root,2)
       >>> x.insert(x.root,5)
       >>> x.insert(x.root,10)
       >>> x.insert(x.root,9.5)
       >>> x.insert(x.root,7)
       >>> x.getMin
       2
       >>> x.getHeight(x.root)
       3
       >>> x.getHeight(x.root.left.right)
       1
       >>> x.getHeight(x.root.right)
       2
       >>> x.isEmpty()
       False
    '''

    def __init__(self):
       self.root...

By purchasing this solution you'll be able to access the following files:
LAB6.py.

$13.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats