Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Read the following code and fill in blank #1. TreeNode* Balance(TreeNode* T) // Checks and balances the subtree T. { int balanceFactor = Difference(T); if

Read the following code and fill in blank #1.

TreeNode* Balance(TreeNode* T)

// Checks and balances the subtree T.

{

int balanceFactor = Difference(T);

if (balanceFactor > 1) {

if (Difference(T->left) > 1)

return RotateRight(T); // #1

else

return RotateLeftRight(T); // #2

}

else if (balanceFactor < -1) {

if (Difference(T->right) < 0)

return RotateLeft(T); // #3

else

return RotateRightLeft(T); // #4

}

else

return T;

}

[1] RotateLeft(T)

[2] RotateLeftright(T)

[3] RotateRight(T)

[4] RotateRightLeft(T)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

=+8. Why is productivity important?

Answered: 1 week ago

Question

=+ 9. What is inflation and what causes it?

Answered: 1 week ago

Question

=+6. What does the invisible hand of the marketplace do?

Answered: 1 week ago