$30
Write a program that sorts the grades of students registered in a data structure course. Let’s assume that grades are given out of 100. The number of students registered to the course is not known in advance. Student IDs and grades are given in input. Your program will output the sorted list of the student grades with student ids (Assume for this homework, student grades are distinct). Use binary search tree in your program.
Input:
123 70
546 90
456 50
445 60
677 80
121 40
Your output will be the sorted list of student grades with their ids (In-order walk on the binary search tree produce the sorted list).
121 40
456 50
445 60
123 70
677 80
546 90
Your program should also print the binary search tree in the following way (First number represents the student id, second number displays the grade and the number in parenthesis shows the parent node. L represents left child and R represents right child).
123 70
456 50 (70 L) 546 90 (70 R)
121 40 (50 L) 445 60 (50 R) 677 80 (90 L)
Output:
121 40
456 50
445 60
123 70
677 80
546 90
123 70
456 50 (70 L) 546 90 (70 R)
121 40 (50 L) 445 60 (50 R) 677 80 (90 L)