attached file, you will find a function that creates a binary search tree of a given size and files that will randomly generate keys in the range [1,1000]. The value associated with each key can be passed to the function, default is 1. Complete the program by implementing the necessary code to perform the following tasks: Create a binary search tree of size 20, name it bst Print all keys in bst on a single line to save space Print the mimimum key in bst Print the smallest key larger than 500 in bst (if any) Print all keys in the range [100,300] in bst Print the tree height Import the modules first before doing this. from bst.binary_search_tree import TreeMap

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

In the attached file, you will find a function that creates a binary search tree of a given size and files that will randomly generate keys in the range [1,1000]. The value associated with each key can be passed to the function, default is 1.

Complete the program by implementing the necessary code to perform the following tasks:

  1. Create a binary search tree of size 20, name it bst
  2. Print all keys in bst on a single line to save space
  3. Print the mimimum key in bst
  4. Print the smallest key larger than 500 in bst (if any)
  5. Print all keys in the range [100,300] in bst
  6. Print the tree height

Import the modules first before doing this.

from bst.binary_search_tree import TreeMap
from AVLTreeMap import AVLTreeMap
import random

def create(size, value = 1):
    bst = AVLTreeMap()     # or just use AVLTreeMap()
    counter = 0
    while counter<size:
        val = random.randint(1,1000)
        if not val in bst.keys():
            bst[val] = value
            counter +=1
    return bst

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY