[SOLVED] Binary Search Tree and Red-Black Tree Python

I’m working on a Python exercise and need support.

Struggling to find relevant content or pressed for time? – Don’t worry, we have a team of professionals to help you on
[SOLVED] Binary Search Tree and Red-Black Tree Python
Get a 15% Discount on this Paper
Order Now

This is for BST and RB Balanced Tree implementation

I have attached the .txt file and the code to import the numbers from the .txt file.

This function imports a text file and converts all numbers into integers and stores them in a list
Input: A list to store the numbers and file name
Output: Returns a list of imported numbers
def importFile(randL, fname):
    with open(fname, mode="r") as inFile:
        for line in inFile:
            l1 = line.strip('n').split(" ") # strip n at every line and split spaces to put in a list
            for i, val in enumerate(l1):
                if val == 'n':
    # filters out " in list
    randL = list(filter(None, randL))
    # converts str to int for every element in list
    for i, val in enumerate(randL):
        j = int(val)
        randL[i] = j
    return randL

Read the following postings:

Also, visit:

I found the third posting (laurentluce (Links to an external site.)) above is very useful introduction to the beginners of BST implementation . You may read the blog in its entirety.

    1. Download or copy laurentluce (Links to an external site.)‘s library (from github)
    2. Add the following methods in the library:
      • getHeight () – returns the number of tree height from self
      • countNodes() – returns the number of total nodes in a given tree
    3. Create and populate a BST tree with the integer data from ‘rand1000000.txt’ file and count the tree height and the number of nodes using your own methods above.
      • Make sure add() and delete() work
    4. in descending order, traverse the tree to visit the contents of the tree of 1,000 nodes from “rand1000.txt” file ( or100 nodes if you prefer but make your own data file)
      • While traversing, print the node in English number format. For example if the number is 418,621, write it down “four hundred eighteen thousand six hundred twenty one”
      • Use Python “Generator” pattern using ‘yield
      • Feel free to use any Python standard data type available to map a number to English format
    5. Using pypi binarytree package or any other RB tree library you can find from the Internet, do steps 2 – 3 (don’t need 4 again) with a Red-Black tree.


  1. (3 points) Did you read all the articles referenced above? This points counted only if you complete the extra credit assignment in its entirety.
  2. ( 5 points) Heights of both trees (BST and RB BST) with 1 Million nodes
  3. (7 points) The output of tree traversal displaying the numbers in English format

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
Sign up, place your order, and leave the rest to our professional paper writers in less than 2 minutes.
step 1
Upload assignment instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
Get personalized services with MyCoursebay
One writer for all your papers
You can select one writer for all your papers. This option enhances the consistency in the quality of your assignments. Select your preferred writer from the list of writers who have handledf your previous assignments
Same paper from different writers
Are you ordering the same assignment for a friend? You can get the same paper from different writers. The goal is to produce 100% unique and original papers
Copy of sources used
Our homework writers will provide you with copies of sources used on your request. Just add the option when plaing your order
What our partners say about us
We appreciate every review and are always looking for ways to grow. See what other students think about our do my paper service.
i got the paper a bit late but it is good quality will for sure come back and use this website.
Customer 452611, September 9th, 2021
Social Work and Human Services
Thank You, Don!!! :)
Customer 452587, November 9th, 2021
The paper is well written and professional. I highly recommend
Customer 452485, August 22nd, 2021
Customer 452813, July 10th, 2022
Social Work and Human Services
Excellent work
Customer 452587, September 4th, 2021
Thank you!
Customer 452707, April 3rd, 2022
Customer 452813, July 3rd, 2022
Social Work and Human Services
Excellent Work!!!!
Customer 452587, November 29th, 2021
Customer 452813, July 5th, 2022
Great work! I can tell they put great effort in completing this assignment. Thank you.
Customer 452707, October 14th, 2022
IT, Web
Excellent job on the paper!
Customer 452885, December 28th, 2022
Eng 099
I recveived a B on this paper but I'm not sure why.
Customer 452775, June 18th, 2022
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat

Get top-notch homework help now. 20% off first 10 orders!


Thank you for choosing MyCoursebay. Your presence is a motivation to us. All papers are written from scratch. Plagiarism is not tolerated. Order now for a 15% discount

Order Now