Write a program that implements two recursive methods

Assignment Help Data Structure & Algorithms
Reference no: EM131125195

1) Chapter 3 - Programming Problem 5 (Page 195) Write the solution to this problem and then show a box trace of your algorithm when looking for the 3rd smallest item in the following array: { 14, 5, 21, 17, 6, 2, 22, 15, 7, 13}.

Your recursive algorithm should not alter the original array.

2) You just won the lottery - but the prize is paid in a very peculiar way. For the first week, you will receive one cent. For week 2, you will receive 2 cents; 4 cents for week 3; 8 cents for week 4 - and the amount received keeps doubling every week until the end of the year. So at the end of week one, you will have been paid 1 cent; at the end of week two, 3 cents (2 + 1 cents); at the end of week three, the total will be 7 cents (4 + 3 + 1) and so on.

Write a program that implements two recursive methods: one that given the week number, it will report the amount to be received for that week (i.e. week 10 pays $5.12); and second method that reports the total amount received to date given the week number (i.e. by the end of week 8, $2.55 has received in total).

The program should repeatedly ask the user to indicate the number of weeks and report the results of the two recursive methods. If the user enters 0 weeks, the program will terminate.

Verified Expert

This assignment has solutions to two programming problems which involve recursion. The programming language used is Java. Each solution contains 3 elements : source code , screenshot of output and box trace diagram to track the recursion. The paper has been prepared in Microsoft Office Word and then presented in pdf format.

Reference no: EM131125195

Questions Cloud

What was the identity of the original nucleus : A radioactive nucleus alpha decays to yield a sodium-24 nucleus in 14.8 hours.  What was the identity of the original nucleus?  Show the nuclear equation that leads you to this answer.
Discuss the process of evolving a group into a team : Write a research paper that analyzes methods used to appropriately manage groups and teams. In your paper, be sure to include the following: Discuss the process of evolving a group into a team, and discuss the importance of organizational culture i..
Determine the speed of each block when b descends : The assembly consists of two blocks A and B which have a mass of 20 kg and 30 kg, respectively. Determine the speed of each block when B descends 1.5 m. The blocks are released from rest. Neglect the mass of the pulleys and cords.
Glutamate carboxypeptidase ii within the enzyme : is the structure β8 of glutamate carboxypeptidase II within the enzyme, on the surface or completely exposed to cytosol. Explain.
Write a program that implements two recursive methods : Write a program that implements two recursive methods - Write the solution to this problem and then show a box trace of your algorithm.
Opinion on effectiveness of those core competences : What is Wendy's business strategy? Identify Wendy's three core competences. Compare those core competences with their competitors. What is your opinion on effectiveness of those core competences?
Analyze the broad range of talent management efforts : Discuss aspects of career planning that the organization can use to retain highly talented staff. Use examples of organizations that have career planning systems such as succession planning, education assistance etc. as part of their strategic hum..
Divisional income statements : The following data were summarized from the accounting records for Jersey Coast Construction Company for the year ended June 30, 2016:
Find p1 and p2 if r= 40kn and p3 = 20kn : he force R is the resultant of the forces P1. P2, and P3 acting on the rectangular plate. Find P1 and P2 if R= 40kN and P3 = 20kN.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Write a program that implements kruskals algorithm

Write a program that implements Kruskal's algorithm

  Build a dynamic and functional model

Write 2 to 3 page paper that explains the difference in steps used to build a dynamic and functional model as each relates to object-oriented modeling

  Use insertion sort on a randomly ordered array

Suppose that we use insertion sort on a randomly ordered array where items have only one of three values. Is the running time linear, quadratic, or something in between?

  Create and implement dynamic programming algorithm

Create and implement such dynamic programming algorithm and examine it. You are not sure if CEO must get invited to party, but you suspect that you might get fired if he is not.

  Construct minimal avl trees of height

Construct minimal AVL trees of height 0, 1, 2, 3, and 4. you do not need to fill in the values, just draw the structure of the tree. Tip: Use the recursive definition for the number of nodes in a minimal AVL tree.

  Function implements a two-d orthographic projection matrix

The function implements a 2D orthographic projection matrix, which is used for the. In this question you need to implement the function worldToViewportTransform

  Write a procedure to produce the alternative description

Write a procedure to produce the alternative description of the moves based on the observations If we can move a tower of k rings in either direction we can certainly move a tower of k +1rings.

  Finding median by black-box worst-case linear-time algorithm

Given a black-box worst-case linear-time algorithm for ?nding median, create algorithm solving the selection problem for an arbitrary order statistic.

  Graph the probability distribution for the bond return

Graph the probability distribution for the bond returns based on the 5 scenarios. What might the graph of the probability distribution look like if there were an infinite number of scenarios (i.e., if it were a continuous distribution and not a discr..

  Implement the selection sort algorithm for sorting an array

Implement the Selection Sort algorithm for sorting an array of n elements. This algorithm has n-1 iterations, each selecting the next largest element a[j] and swapping it with the ele- ment that is in the position where a[j] should be.

  Tree walk algorithm

We know how the regular tree walk algorithm works. If you have some values in the tree then the tree walk algorithm prints everything in order

  Perform an insertion sort on the file pointed

Using only the local data already supplied in FileSort, perform an insertion sort on the file pointed to by fd. Use lseeks for this; do not try to create any sort of array or list. An array-based version of insertion is supplied for your reference.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd