Write the pseudo-code for a Reversed-Tree-Maximum(x) method fora reversed binary
ID: 3616378 • Letter: W
Question
Write the pseudo-code for a Reversed-Tree-Maximum(x) method fora reversed binary search tree.
Inspect the coding of the Tree-Maximum /Tree-Minimummethods for the regular BST.
Explanation / Answer
From the definition of the reversed-binary tree....we know thatleft-child's value is bigger than parent and right-child's value issmaller than the parent. Pseudo-Code:Reversed-Tree-Maximum(RBST): 1) IF RBST = NULL return NULL 2) T--->current Node 3)LT--->Left child of T .//i.e. left-child of current node...canbe NULL also 4) IF LT ==NULL return T.value //it returns the number storedat current node i.e. T 5) else T = LT 5.1) LT = left child of LT 5.2) goto step 4 The algorithm runs until it find the extreme left element whichwill be the maximum of the reversed-binary-tree.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.