Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Write a recursive function sumTreeNodeHelper that sums the elements of a binary search tree starting with the smallest element and adding elements in order up to the largest element and prints the running sum as each new value (ie. Node->val) is added to the sum (We're assuming double values are stored in the tree).You will not use an iterator.

void sumTreeNodeHelper(struct BNode *node, double *sum)

{

printf(" Running sum = %fn", *sum);

}

void sumTree(struct BSTree *tree, double *sum)

{

sumTreeNodeHelper(tree->root, sum);

}

/* Example use */

struct BSTree myTree;

int sum = 0;

/* Initialize and Add elements to the tree */

addTree(&myTree, 5);

addTree(&myTree, 1);

addTree(&myTree 10);

sumTree(&myTree, &sum);

printf(" Final sum of tree values = %fn", sum);

...< /span>

The output of the above should be:

Running sum = 1

Running sum = 6

Running sum = 16

Final sum of tree values = 16

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91719565

Have any Question?


Related Questions in Computer Engineering

Questionusing the cost-benefit analysis method estimate how

Question..... Using the cost-benefit analysis method, estimate how much money MidCorp should spend on power protection. You will have to make several assumptions to do this. Your answer should contain an "assumptions" se ...

Please discuss the data hazards associated with pipelining

Please discuss the data hazards associated with pipelining with an example and how these hazards impact the performance gain associated with pipelining.

What are your thoughts on grant writing and grant money

What are your thoughts on grant writing and grant money toward purchase? How essential is this practice when looking at gaining money toward purchases?

Reconstructing binary trees via traversalsrecall the binary

Reconstructing Binary Trees Via Traversals Recall the binary tree data structure; recall three algorithms for traversing the tree: the inorder traversal, the preorder traversal, and the postorder traversal. 1. Suppose yo ...

Determine the number of moles of oleic acid in the

Determine the number of moles of oleic acid in the monolayer. Assume the nubmer of grams of oleic acid in the monolayer is  7.12×10 -6  g MW for oleic acid is 282 g/mol.

Come with an app that only runs in horizontal orientation

Come with an app that only runs in horizontal orientation. It displays "This is fun!" on the top left corner of the screen with no margin either from the top or the left.

Discuss 5 of the most important sql server management

Discuss 5 of the most important SQL Server Management Studio (SSMS) features. Provide references - website link, book, article, etc.

Calculate the standard gibbs free energy change and the

Calculate the standard Gibbs free energy change and the equilibrium constant for the oxidation of a formate ion to carbon dioxide at pH=7 and room temperature.

In a software design meeting in your company your manager

In a software design meeting in your company, your manager says that one of the most important engines of the Record Keeping System you are developing is the Index Sorting Engine. Your coworker quickly jumps in and says ...

Short answer1 what must be installed or prepared to utilize

Short answer: 1. What must be installed or prepared to utilize Windows Remote Management (WinRM) on a Windows Server 2012 R2? 2. What is the PowerShell command to check the status of Windows Remote Management (WinRM)? 3. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As