A node in a binary tree (a tree of degree two) can be defined as follows: struct btnode_int; typedef struct btnode_int *

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

A node in a binary tree (a tree of degree two) can be defined as follows: struct btnode_int; typedef struct btnode_int *

Post by answerhappygod »

A Node In A Binary Tree A Tree Of Degree Two Can Be Defined As Follows Struct Btnode Int Typedef Struct Btnode Int 1
A Node In A Binary Tree A Tree Of Degree Two Can Be Defined As Follows Struct Btnode Int Typedef Struct Btnode Int 1 (138.83 KiB) Viewed 9 times
A node in a binary tree (a tree of degree two) can be defined as follows: struct btnode_int; typedef struct btnode_int *btnode; struct btnode_int { int data; btnode left; btnode right; }; and you may assume the existence of those types and the following functions: void init_btnode (btnode *tp, void *o); void *get_data (btnode t) ; btnode get_left (btnode t); btnode get_right (btnode t) ; void set_data (btnode t, int o); void set_left (btnode t, btnode 1); void set_right (btnode t, btnode r); A binary tree can hence be defined as follows: struct bintree_int; typedef struct bintree_int *bintree; struct bintree_int { btnode root; }; An implementation could comprise the following functions: void init_bintree (bintree *tp, bool e, int i); bool is empty (bintree t); bool present (bintree t, int i); void add (bintree t, int i); Assume that init_bintree () and is_empty() have been defined. a. Implement the present () function to search for the specified value i from the given binary tree t. You should return true if the value can be found and
false otherwise. You may write other functions to assist your implementation. Click or tap here to enter text. [20 marks] b. Implement the add () function to add the specified value i to the given binary tree t. The value should be added as the right-most node in the binary Continued... -12- KIT107 Programming tree and you may assume that the binary tree t has already been initialised. You may write other functions to assist your implementation. Click or tap here to enter text. [10 marks]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply