Page 1 of 1

C Programming Task: Construct Binary Tree • Write a program to build a binary tree according to an input matrix, and ret

Posted: Thu May 26, 2022 9:12 am
by answerhappygod
C Programming Task Construct Binary Tree Write A Program To Build A Binary Tree According To An Input Matrix And Ret 1
C Programming Task Construct Binary Tree Write A Program To Build A Binary Tree According To An Input Matrix And Ret 1 (178.22 KiB) Viewed 25 times
C Programming Task: Construct Binary Tree • Write a program to build a binary tree according to an input matrix, and returns the pointer to the root of the binary tree. Complete Node* constructBT(int matrix[][3], int rowNum); Input matrix format: Ubut mati • The matrix has three columns. ● Every entry stores the key of a node. All keys are positive integers. • For each row, the first column value denotes the key of a node, second column value denotes the key of its left child and third column value denotes the key of its right child. (-1 means the child is empty.) • The value stored in matrix[0][0] is the root of the tree. • You can assume there is no duplicate keys in the binary tree. For example: OBIC 123 24 -1 2 6) 3 3-16 UB BIC. BIC• 123 245 367 7 4 6 UB
BIC BIC • Submit the complete code set including ● Struct definition ● Declaration and implementation for every necessary method. • You can use the printTree method provided in previous labs) • A main function which runs your own test cases 123 245 1 3 12 3 24 -1 367 3-16 4 Demo results 4 (6- 3 5 6 7 1 2 1 UBIC 4 1 2 3 3 (6 UB UR