Question: ( 3 points ) Write a function that inserts the values of a binary search tree into a linked list in such a way that
points Write a function that inserts the values of a binary search tree into a linked list in such a way that the contents of the linked list are in order from least to greatest. Test your function in the main. Make sure to print the contents of the resulting linked list. You have the correct functionality, if the values print from least to greatest.
Hint: Your function prototype should look like:
void createOrderedListconst nodeType root, list& ordList;
if using the STL list
OR
void createOrderedListconst nodeType root, unorderedLinkedList& ordList;
if using the LinkedList class we wrote
You can obtain the root from the binarySearchTree by using the search function we wrote to search for the value in the root.
const nodeType treeRoot bstObj.searchrootValue;
For example if the BST looks like:
Then printing the contents of the list would display:
points Create a function that takes in the root of a binary search tree of integers, a start value, and end value. Then print all values found in the tree that are in between the start value and end value. Test your function in the main.
Hint: Your function prototype should look like the following and should use recursion:
void printRangeconst nodeType root, int a int b; where a is start value and b is end value
For example, if I call printRangebstRoot; where bstRoot is a pointer to the root of the binarySearchTree
if our tree looks as follows:
The function should display
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
