(BI). Implement a Red-Black tree with only operation Insert(). Your program should read from a file that contain positive integers and should insert those numbers into the RB tree in that order. Note that the input file will only contain distinct integers. Print your tree by level using positive values for Black color and negative values for Red color. Do not print out null nodes. Format for a node: (, ). For example, the following tree is represented as (12, null) (5, 12) (15, 12) (3,5) (-10, 5) (13, 15) (17, 15) (-4, 3) (7,-10) (11, -10) (-14, 13) (-6, 7) (-8, 7) 4 5 6 7 12 10 8 11 13 15 14 17

icon
Related questions
Question
(BI). Implement a Red-Black tree with only operation Insert(). Your program should read from a file that contain
positive integers and should insert those numbers into the RB tree in that order. Note that the input file will only
contain distinct integers. Print your tree by level using positive values for Black color and negative values for Red color.
Do not print out null nodes.
Format for a node: (<Node_value>, <Parent_value>). For example, the following tree is represented as
(12, null)
(5, 12) (15, 12)
(3, 5) (-10, 5) (13, 15) (17, 15)
(-4, 3) (7,-10) (11, -10) (-14, 13)
(-6, 7) (-8, 7)
3
4
6
12
10
8
11
13
15
14
17
Transcribed Image Text:(BI). Implement a Red-Black tree with only operation Insert(). Your program should read from a file that contain positive integers and should insert those numbers into the RB tree in that order. Note that the input file will only contain distinct integers. Print your tree by level using positive values for Black color and negative values for Red color. Do not print out null nodes. Format for a node: (<Node_value>, <Parent_value>). For example, the following tree is represented as (12, null) (5, 12) (15, 12) (3, 5) (-10, 5) (13, 15) (17, 15) (-4, 3) (7,-10) (11, -10) (-14, 13) (-6, 7) (-8, 7) 3 4 6 12 10 8 11 13 15 14 17
Expert Solution
steps

Step by step

Solved in 6 steps with 6 images

Blurred answer