Question

Q8 BST 15 Points Given a BST T with root r write algorithms (pseudocode) to determine: (a) The height of T. (b) The maximum e
0 0
Add a comment Improve this question Transcribed image text
Answer #1

a)

int findHeight(r) {
  if (r == null) return 0
  return 1 + max(findHeight(r.left), findHeight(r.right))
}

b)

int maxElement(r) {

temp = r;

while (temp.right != null) {

temp = temp.right;

}

return temp.value;

}

NOTE: As per HOMEWORKLIB POLICY I am allowed to answer specific number of questions (including sub-parts) on a single post. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.

Add a comment
Know the answer?
Add Answer to:
Q8 BST 15 Points Given a BST T with root r write algorithms (pseudocode) to determine:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • part C please 8 BST 15 Points Given a BST T with root r write algorithms...

    part C please 8 BST 15 Points Given a BST T with root r write algorithms (pseudocode) to determine: (a) The height of T. (b) The maximum element in T. (c) If T is height balanced. Please select file(s) Select file(s) Q9 Double

  • Please select file(s) Select file(s) Q9 Double 15 Points Consider inserting the keys 10, 22, 31,...

    Please select file(s) Select file(s) Q9 Double 15 Points Consider inserting the keys 10, 22, 31, 4, 15, 28, 17, 88, 59 into a hash table of length m 11 using open addressing with the auxiliary hash function l'(k) = k. Illustrate the result of inserting these keys using linear probing, using quadratic probing with c1 3, and using double hashing with h1(k) = k and h2(k) = 1 + (k mod (m – 1)). See Cormen p.272 1 and...

  • NEED HELP IN C!! Answer in C programming language. Question: Functions and .h file: Test function:...

    NEED HELP IN C!! Answer in C programming language. Question: Functions and .h file: Test function: part 1: part 2: For the assignment use the following structs for Binary Trees and Binary Search Trees. struct Binode { int value; struct Binode* left; struct BTnode* right; struct BTnode* parent; }; typedef struct Binode BTnode_t; typedef struct BST { BTnode_t* root; BST_t; Question 2 [10 points] Write a function that gets a binary tree and returns the sum of its elements. //...

  • EX16_XL_CH05_GRADER_CAP_AS - Travel Expenses 1.8 Project Description: <Project Description> Steps to Perform: Step Instructions Points Possible...

    EX16_XL_CH05_GRADER_CAP_AS - Travel Expenses 1.8 Project Description: <Project Description> Steps to Perform: Step Instructions Points Possible 1 Start Excel. Open the downloaded Excel file named exploring_e05_grader_a1_Expenses.xlsx. Save the workbook as exploring_e05_grader_a1_Expenses_LastFirst, replacing LastFirstwith your own name. 0 2 On the Subtotals worksheet, use the Sort dialog box to sort the data by Employee and further sort by Category, both in alphabetical order. 4 3 Use the Subtotals feature to insert subtotal rows by Employee to calculate the total expense by...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT