Answered step by step
Verified Expert Solution
Question
1 Approved Answer
10:43 384 ED Q 1 of 4 - + > > PROG 20799 - Assignment #3 Due date: Please check the SLATE drop box. Late
10:43 384 ED Q 1 of 4 - + > > PROG 20799 - Assignment #3 Due date: Please check the SLATE drop box. Late assignments will be penalized according to the class plan outline. You can use class example solutions (as a starting point) for this assignment. This assignment will be graded out of 10 and worth 5% of your total marks for this course. Submission requirements: 1. Upload the btree.c to the SLATE drop box only. Otherwise, 10% will be deducted. 2. Do not zip the file(s); otherwise, 10% will be deducted from your final mark of this assignment. 3. Do not change any variable names, function names, and must follow the given function prototypes and data structure definition for implementation. Otherwise, your work will not be graded. Assignment 3 - Part 1 For this part, you are required to do the following tasks. 1. Create three functions: a. preOrder Traversal() b. postOrder Traversal() c. buildTree() You are free to design these three function prototypes. Function descriptions are: . preOrder Traversal - visits a binary tree in preorder fashion. postOrder Traversal - visits a binary tree in postorder fashion. buildTree - creates a binary tree based on a given array. For example, if the array contains three elements 1, 2, and 3, then the root of the created binary tree should be 1, the root's left child is 2, and the root's right child is 3. 2. Create a binary tree with the same node positions as shown in Diagram 1. 12 Diagram 1: binary tree 3. Use the following code to complete this assignment. //----- #include #include #include typedef struct treeNode_deff int number; struct treeNode_def *left, *right; }treeNode; typedef struct{ treeNode *root; int nodeCount; }BinaryTree; void visitNode (treeNode* ) :10:44 384 E Q 3 of 4 - + > > void visitNode (treeNode*); void init(BinaryTree*); treeNode* createNode (int); void inOrderTraversal (treeNode*); int main(int argc, char* argv ){ BinaryTree btree; init(&btree) ; / /call buildTree function inOrder Traversal(btree. root) ; printf(" \ "); return 0; void visitNode (treeNode* node) { printf("%d ", node->number); void preOrderTraversal (treeNode *node) { 17 .. } void postOrderTraversal (treeNode *node) { 1/ .. treeNode* createNode (int num) { treeNode *newNode =malloc(sizeof (treeNode) ) ; assert (newNode ) ; newNode ->number = num; newNode->left = newNode->right = NULL; return newNode; void init(BinaryTree *btree) { btree->root = NULL; btree->nodeCount = 0; } Marking scheme Task 1 Mark preOrder Traversal 1.5 postOrder Traversal 1.5 build Tree 7 Total 10 Assignment 3 - Part Two (Term Project Part 1): Create a function to capture the processor time. Please look up how to use clock() function provided by time.h. (very simple). What do you need to submiss your Project Part 1? 1. queue.h, queue.c, sorting.h, sorting.c, and bigOExperiment.c 2. You can use queue.h and queue.c class examples code from your first half. 3. Sorting.h includes the functions below - a. Bubble sort function This function performs sorting of an array in ascending order using bubble sort algorithm.10:44 384 : Q 4 of 4 - + > > Assignment 3 - Part Two (Term Project Part 1): Create a function to capture the processor time. Please look up how to use clock() function provided by time.h. (very simple). What do you need to submiss your Project Part 1? 1. queue.h, queue.c, sorting.h, sorting.c, and bigOExperiment.c 2. You can use queue.h and queue.c class examples code from your first half. 3. Sorting.h includes the functions below - a. Bubble sort function This function performs sorting of an array in ascending order using bubble sort algorithm. b. Selection sort function This function performs sorting of an array in ascending order using selection sort algorithm. c. Swap function This function swaps the content of two variables. d. array Generator This array generator generates an array with user specified size. For example, arrayGenrtator(n), this function will create an array contains the size of n random numbers. e. markTime Whenever calls this function, the processor time will be captured. The captured time is the number of clock ticks that have elapsed from the start of the program's execution up to the point where the clock() function is called. f. clock TickTo Time This function converts the clock ticks to hours, minutes, and second format (hh:mm:ss). 4. bigOExperiment.c This is an application program that creates an array containing one million random numbers ascending sorting on this array using bubble sort. It will report the time taken for this action. Marking scheme Task 1 Mark queue.h/queue.c Sorting.h/sorting.c 2 bigOExperiment.c 2 Total 5
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started