Question

In: Computer Science

Design in pseudo code a multiple recursive version of Tetranacci calculators. Tetranacci numbers are a more...

Design in pseudo code a multiple recursive version of Tetranacci calculators.

Tetranacci numbers are a more general version of Fibonacci numbers and start with four predetermined terms, each term afterwards being the sum of the preceding four terms. The first few Tetranacci numbers are: 0, 0, 0, 1, 1, 2, 4, 8, 15, 29, 56, 108, 208, 401, 773, 1490, …

Solutions

Expert Solution

Here is the answer...

CODE:

def tetranacci(n):
if(n==0 or n==1 or n==2): #for first three numbers return 0
return 0
elif(n==3): #return 1 for fourth number
return 1
else: #recursively calling to sum up the back three numbers
return tetranacci(n-4)+tetranacci(n-3)+tetranacci(n-2)+tetranacci(n-1)

n = int(input("Enter how many numbers you want : ")) #read how many numbers he want
i = 0 #start with 0
while(i < n-1): #to run through given numbers count
print(tetranacci(i),end=", ") #call tetrancci with that number and print the return result
i +=1 #increment i by 1
print(tetranacci(n-1)) #print the last tetranacci number
  

CODE Snapshot:

Pseudo code:

-> Read how many numbers he want

-> loop over through given number

->call tetranacci function with the number

-> increment number.

->print the tetranacci number for last number

Recursive tetranacci function:

-> if number==0 or 1 or 2

-> return 0

->else

->sum up the recursive calls of previous four numbers.

if you have any doubts please COMMENT...

If you understand the answer please give THUMBS UP...


Related Solutions

Develop an algorithm for INSERTION SORT. Give the pseudo-code version. Convert your pseudo-code into a Java...
Develop an algorithm for INSERTION SORT. Give the pseudo-code version. Convert your pseudo-code into a Java program.
Write a recursive algorithm in pseudo-code to compute the “power list” of a given list of...
Write a recursive algorithm in pseudo-code to compute the “power list” of a given list of integers. Assume that the List type has members: int List.length returns the length of the list. void List.push(T n) pushes an element n to the front of the list T List.pop() pops an element from the front of the list. List$$ List$$.concat(List$$ other) returns the concatenation of this list with other. Explain in plain English the reasoning behind your algorithm. Power Lists should be...
Java String search Design and implement a recursive version of a binary search.  Instead of using a...
Java String search Design and implement a recursive version of a binary search.  Instead of using a loop to repeatedly check for the target value, use calls to a recursive method to check one value at a time.  If the value is not the target, refine the search space and call the method again.  The name to search for is entered by the user, as is the indexes that define the range of viable candidates can be entered by the user (that are...
1. Here is a pseudo-code of a program that takes two non-negative numbers X and Y...
1. Here is a pseudo-code of a program that takes two non-negative numbers X and Y as its inputs and outputs a number Z. Write this program in C. What does this program do? Explain how it computes the output Z from its inputs X and Y. Determine the big-Oh of this program in terms of its input sizes.                                                                 f (int x, int y) {      z = 0; k = y; w = x;      while (k != 0) {           if...
Complete java program below. Complete non-recursive version nthFibonacciWithLoop() method. Complete recursive version nthFibonacciWithRecursion() method. public class...
Complete java program below. Complete non-recursive version nthFibonacciWithLoop() method. Complete recursive version nthFibonacciWithRecursion() method. public class Fibonacci { // Fib(N): N N = 0 or N = 1 // Fib(N-1) + Fib(N-2) N > 1 // For example, // Fib(0) = 0 // Fib(1) = 1 // Fib(2) = Fib(1) + Fib(0) = 1 + 0 = 1 // Fib(3) = Fib(2) + Fib(1) = Fib(2) + 1 = (Fib(1) + Fib(0)) + 1 = 1 + 0 + 1...
Examples Example 1: Write pseudo code that reads two numbers and multiplies them together and print...
Examples Example 1: Write pseudo code that reads two numbers and multiplies them together and print out their product. Example 2: Write pseudo code that tells a user that the number they entered is not a 5 or a 6. Example 3: Write pseudo code that performs the following: Ask a user to enter a number. If the number is between 0 and 10, write the word blue. If the number is between 10 and 20, write the word red....
Problem 3.2 A more efficient version of the function for computing Tetranacci numbers can be defined...
Problem 3.2 A more efficient version of the function for computing Tetranacci numbers can be defined by following three steps: Implement a function which takes a list of integers and adds the sum of the top four elements to the head of the list (e.g., in F#, 1::1::1::1::[] should become 4::1::1::1::1::[]). Implement a recursive function which computes the nth Tetranacci number in linear time. This function may use a linear amount of space to compute its result, but the number...
Kramerica Industries decided to compete in the market of "tip calculators" by designing a cheaper version...
Kramerica Industries decided to compete in the market of "tip calculators" by designing a cheaper version of the Sharp Wizard and offering it for only $50 (as opposed to the $200 genuine Wizard). After successful pilot testing at a resort in Del Boca Vista, Kramerica Industries realized that they needed to significantly boost their production capacity for the upcoming holiday season. Kramerica is deciding whether or not to purchase a new piece of manufacturing equipment to adequately produce the volume...
show some example of few recursive problem in java language and the solution code. Need more...
show some example of few recursive problem in java language and the solution code. Need more practice as a new learner
can someone translate this pseudo code to actual c++ code while (not the end of the...
can someone translate this pseudo code to actual c++ code while (not the end of the input) If the next input is a number read it and push it on the stack else If the next input is an operator, read it pop 2 operands off of the stack apply the operator push the result onto the stack When you reach the end of the input: if there is one number on the stack, print it else error
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT