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

  Short discussion on the concept of cryptography

The answer gives the learner with a short discussion on the concept of cryptography and the different aspects and functions that are provided through using encryption.

  Question 1 explain five types of information systems and

question 1. explain five types of information systems and give an example of each.question 2. describe three common

  Write algorithm to identify substrings which form numbers

Write the algorithm, by using pseudo code, to do the following task. Given string of numbers, identify all the substrings which form numbers that are divisible by 3.

  Find the shortest paths from s to all the other nodes

Find the Minimum-Cost Spanning Trees for the above graph using the following algorithms.

  State two different self-reductions for the sum problem

State two different self-reductions for the SUM problem and give recursive algorithms based on your divide-and-conquer self-reductions to solve the SUM problem.

  Deliverable is to design an algorithm

Deliverable is to design an algorithm for a function that accepts an integer array as an argument and returns the total of values in the array. this is algorithm

  Complex routing algorithm are used to maintain routing table

Complex routing algorithms are used to maintain routing table

  Skech-perofrm pre order traversal on binary search tree

Let the binary search tree (BST) which is initially empty. Sketch the tree which will result if following numbers are inserted in the same order.

  Proof the correctness of the algorithm

Take a look at the sudocode of FIND-MAXIMUM-SUBARRAY. Try to proof the correctness of the algorithm.

  1decryption speeda certain cryptography vendor was

1.decryption speeda certain cryptography vendor was providing an encryption technology that was breakable within 10

  Initialize accumulator variable for total rainfall to zero

Set a constant named SIZE to 12. This represents the total number of elements in the array. Initialize an accumulator variable for the total rainfall to 0.

  Linear-time algorithm for computing the strong component

Describe a linear-time algorithm for computing the strong component containing a given vertex v - On the basis of that algorithm, explain a simple quadratic-time algorithm for computing the strong components of a digraph.

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