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

Design in pseudo code a linear recursive version of Tetranacci calculators. Tetranacci numbers are a more...
Design in pseudo code a linear 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, …
Design in java a multiple recursive version of Tetranacci calculators. You will calculate Tetranacci(5), Tetranacci(10) and...
Design in java a multiple recursive version of Tetranacci calculators. You will calculate Tetranacci(5), Tetranacci(10) and measure the corresponding run times. (for instance, Tetranacci(10) returns 56). You can use Java’s built-in time function for finding the execution time.
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.
design two algorithms, an iterative version and a recursive version , for finding the min and...
design two algorithms, an iterative version and a recursive version , for finding the min and max values in an array of n numbers A.) a iterative version B.) a recursive version derive the time efficiency functions (or time function in terms of n) for each, analyze each function, and compare and discuss the results of the analysis
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...
In pseudo-code, design an algorithm for finding baking a cake.
In pseudo-code, design an algorithm for finding baking a cake.
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...
*Please give the answers in pseudo code 1) Design an algorithm that will receive two integer...
*Please give the answers in pseudo code 1) Design an algorithm that will receive two integer items from a terminal operator, and display to the screen their sum, difference, product and quotient. Note that the quotient calculation (first integer divided by second integer) is only to be performed if the second integer does not equal zero. 2) Design an algorithm that will read two numbers and an integer code from the screen. The value of the integer code should be...
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...
Learning objectives; File I/O practice, exceptions, binary search, recursion. Design and implement a recursive version of...
Learning objectives; File I/O practice, exceptions, binary search, recursion. 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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT