Hash Table Linked List Array Binary Search Tree (unbalanced) AVL Tree Stack Heap
----------------------- 0 | | | | ----------------------- 1 | | | | ----------------------- 2 | | | | ----------------------- 3 | | | | ----------------------- 4 | | | | ----------------------- 5 | | | | ----------------------- 6 | | | | ----------------------- 7 | | | | ----------------------- 8 | | | | ----------------------- 9 | | | | ----------------------- 10 | | | | -----------------------
----------------------- 0 | | | | ----------------------- 1 | | | | ----------------------- 2 | | | | ----------------------- 3 | | | | ----------------------- 4 | | | | ----------------------- 5 | | | | ----------------------- 6 | | | | -----------------------
typedef struct { int salary; char *name; } employee;Declare a pointer variable named workers that is a pointer to an array of employee pointers. Then malloc an array of 20 employee pointers and assign the result to workers. You can combine the declaration and the malloc into a single statement if you wish.
---185--- / \ 150 200 / \ \ 100 175 300 / / 90 160 \ 170
-300- / \ 175 400 \ / 250 350
85 / \ 50 200 / / \ 25 150 300 / \ 100 175 / 160
----5---- / \ 10 8 / \ / \ 15 11 13 15 / \ / \ / 20 17 16 21 15
typedef struct node { int salary; // an employee's salary char *name; // an employee's name struct node *leftChild; struct node *rightChild; } TreeNode;Further assume that you have a binary search tree that is sorted based on an employee's salary. Write a function named printRange that traverses a binary tree and prints in sorted order all employees with a salary greater than or equal to a specified value. For example, here is some sample input and output, based on the assumption that your function is requested to print all employees with a salary greater than or equal to 26000:
input | output |
---|---|
smiley 33000 brad 40000 mickey 20000 daffy 17000 tom 3000 dick 26000 mary 38000 susan 30000 joe 45000 |
dick : 26000 susan : 30000 smiley : 33000 mary : 38000 brad : 40000 joe : 45000 |
Your program should specifically meet the following specifications:
This problem is different than the one you did in lab. You do not have a linked list you can use to traverse the tree. You must traverse it using recursion.
Alternative problem (worth 10/14 points): If you cannot think of a way to answer the above problem, then you can write a function named printTree that takes a pointer to the root node of a binary search tree and prints the employee's in descending order based on salary. printTree should return nothing. It should print employees using the same print specifications given above.