BST in C language:
You are required to write a program that behaves as follows:
The program takes in a set of unique numbers E.g. {1,3,5,7} andenters them into a BST. You have been provided with 2 structs andthe outline of the functions you will be required to write. You mayadd functions and structs to your liking. Write a function 'SetNew'that creates a new set, 'SetInsert' that inserts an item into theSet and balances the BST, and SetShow which displays numbers in theset as follows '{1, 2, 3, 4, 5}'. Note: Arrays may not be used,attempt to use recursion when possible.
9 #include "Set.h" 10 #include "SetStructs.h" //NOTE structs have also been mentioned below for clarity purposes // DO NOT CHANGE THE NAME OF THIS STRUCT struct node { 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 }; // DO NOT CHANGE THE NAME OF THIS STRUCT struct set { struct node *tree; // DO NOT CHANGE/REMOVE THIS FIELD }; int item; // DO NOT CHANGE/REMOVE THIS FIELD struct node *left; // DO NOT CHANGE/REMOVE THIS FIELD struct node *right; // DO NOT CHANGE/REMOVE THIS FIELD // You may add more fields here if needed. // You may add more fields here if needed // You may define more structs here if needed /////// // Basic Operations /** * Creates a new empty set */ Set SetNew (void) { // TODO } /** * Inserts an item into the set */ void SetInsert (Set s, int item) { // TODO } } /** * Prints the given set in the format * {elem1, elem2, elem3} */ void SetShow (Set s) { // TODO
BST in C language: You are required to write a program that behaves as follows: The program takes in a set of unique num
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am