Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve question 4 ASAP Question 4 [20]. Consider the Student struct as defined in Question 1 above. Implement the binary search tree whose each node

image text in transcribed
image text in transcribed
Solve question 4
ASAP
Question 4 [20]. Consider the Student struct as defined in Question 1 above. Implement the binary search tree whose each node has data component an instance of the struct Student. Comparison of the nodes must be made with respect to age. Write the following functions to: (i) check whether tree is empty or not; (ii) insert nodes in a tree; (iii) print the tree in pre order fashion; (iv) print the tree in post order fashion; (v) print the tree in order fashion; (vi) find the minimum element of the tree; (vii) find the maximum element of the tree; (viii) find/search an elementode from the tree (this function should return the address of the node if the node exists); (ix) remove a node from the tree; Implement the following: (i) check whether tree is empty; insert three elements to the tree: (s1, 25, 20.25), (s2, 19, 25.17) and (s3, 23, 15.72) (get from user); print the tree in order fashion; remove an element from the tree (82, 19, 25.17) (get from user); find the minimum element of the tree; (vi) find the maximum element of the tree; (vii) find the node (s1, 25, 20.25), print the address of the node if the node exists; In other words, determine whether (sl, 25, 20.25) is a node of the tree or not? Hint: to determine the existence of the node, compare the address returned by the Search Node function with nullptr. (viii) print the tree in pre order fashion; (ix) print the tree in post order fashion. Question 1 (10). Write a struct Student that has member variables: (string) first name, (int) age and (double) fee. Write the functions as described in the class for the following purposes. 1. Write a function to create a dynamic sorted (in ascending order according to the age) circular linked list, where the data component of each node is an instance of the struct Student. 2. Write a function to insert the instances in the linked list. You also need to write a function to find the spot for insertion of the nodes. 3. Write a function to remove the node from the linked list. 4. Write a function to count the elements of the linked list. 5. Write a function to determine check whether an element belongs to the linked list. 6. Write a function to print the linked list (from head node) on the console. Implement the above functions as follows. Initially, the list must have two nodes that are the instances of the struct: (studenti, 20,20.75) and (student2, 25, 85.55) (get these values from the user). Insert two nodes that are instances of the struct: (student3, 23, 73.53) and (student4, 19, 45.37) (hardcode these values). Print the list (in ascending order). Remove one node (studentl, 20, 20.75) (hardcode; hardcode this node for removal only, not for inserting). Print the list again. Search the list to find whether the list has an element (student2, 25, 85.55). Print the number of elements in the list

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is the basis of her claim of duress?

Answered: 1 week ago