Question

Extra Credit - Fibonacci Function (Lec. 5 topic: Recursive function and runtime stack. Use recursion to calculate the Fibonac3.) Run the program, beginning with n = 10, and then change the program to n = 20. Then n = 30, n = 40, n = 45 and n = 47. Af

0 0
Add a comment Improve this question Transcribed image text
Answer #1


// I am answring only 1 and 3 questions
// PLEASE REPOST RMANING QUESTION
// THANK YOU

// // / I am awwwww only 1 and questions PLEASE REPOST RMANING QUESTION THANK YOU #include<stdio.h> int fib(int num) if (numI E:\programs_c\main\feb.exe Enter number : 10 fibonacci Sequence for 10 is: @ 1 1 2 3 5 8 13 21 34 Process returned 10 COXAE:\programs_c\main\feb.exe Enter number : 20 fibonacci Sequence for 20 is: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1E:\programs_c\main\feb.exe - x Enter number : 30 fibonacci Sequence for 30 is : 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610I E:\programs_c\main\feb.exe Enter number : 40 I fibonacci Sequence for 40 is : 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 619E:\programs_c\main\feb.exe Enter number : 45 fibonacci Sequence for 45 is: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 372 619 987 1E:\programs_c\main\feb.exe Enter number : 46 1123358820231 1 2 19 19 39438169 fibonacci Sequence for 46 is: 0 1 1 2 3 5 8 133. Question Time in Seconds. Fibonacci Number fib(num) 10 20 30 40 45 2.598 s 4.678 s 18.678 s 6.457 s 20.550 s 32.302 s 46

Add a comment
Know the answer?
Add Answer to:
Extra Credit - Fibonacci Function (Lec. 5 topic: Recursive function and runtime stack. Use recursion to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • CMPS 290 Programming Assignment Arrays and Recursion – Fibonacci Numbers In this programming assignment you will...

    CMPS 290 Programming Assignment Arrays and Recursion – Fibonacci Numbers In this programming assignment you will be working with arrays and multiple function calls, including a recursive function call. The goal of the assignment will be to, using a pre-set array of sequence numbers, calculate the Fibonacci sequence number for each value in the array (see the example at the bottom if this isn’t clear). Instructions and Requirements: • Create a program that assembles and runs to find the correct...

  • How do can I update this code (Code A): Code (A) #include using namespace std; int fibonacci(int n) { int a = 0,...

    How do can I update this code (Code A): Code (A) #include using namespace std; int fibonacci(int n) { int a = 0, b = 1, c; if (n <= 1) return n; for (int i = 2; i <= n; i++) { c = a + b; a = b; b = c; } return b; } int fibonacciRecursive(int n) { if (n <= 1) { return n; } return fibonacciRecursive(n-1) + fibonacciRecursive(n-2); } int main() { int n;...

  • My following program has an array which holds 1000 random integers between 1-1000. Now I need...

    My following program has an array which holds 1000 random integers between 1-1000. Now I need help to create an array that holds 10,000 random integer between 1-1000 in my following program. The main goal of this program is time analysis by using bubble sort and binary search algorithms. Please do the following task; 1. Replace the 1000 random integers with 10,000 random integers After change please answer the following question 2. what will be happen, if an array holds...

  • c++ help Write a program that obtains the execution times for the following three code segments...

    c++ help Write a program that obtains the execution times for the following three code segments with the different n. code 1: for(int i = 0; i <= n; i++)   { x = i; } code 2: for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { x = i + j; } } code 3: for (int i = 0; i <= n; i++) { for (int j =...

  • In C++: Please help me correct this code .... All parts with (FIX ME) #include <algorithm> #include <climits&gt...

    In C++: Please help me correct this code .... All parts with (FIX ME) #include <algorithm> #include <climits> #include <iostream> #include <string> // atoi #include <time.h> #include "CSVparser.hpp" using namespace std; //============================================================================ // Global definitions visible to all methods and classes //============================================================================ const unsigned int DEFAULT_SIZE = 179; // forward declarations double strToDouble(string str, char ch); // define a structure to hold bid information struct Bid { string bidId; // unique identifier string title; string fund; double amount; Bid() {...

  • *** Tasks to be completed *** Task 1: Define structures to hold bids Task 2: Initialize...

    *** Tasks to be completed *** Task 1: Define structures to hold bids Task 2: Initialize the structures used to hold bids Task 3: Implement logic to free storage when class is destroyed Task 4: Implement logic to calculate a hash value using the bid Id as the source for calculating the key Task 5: Implement logic to insert a bid Be sure to check for key collisions and use the chaining technique with a linked list to store the...

  • Part 1 The function 'vbrf' (for very bad recursive function) is defined as follows: vbrf(0) =...

    Part 1 The function 'vbrf' (for very bad recursive function) is defined as follows: vbrf(0) = 2 vbrf(1) = 3 vbrf(2) = 4 vbrf(3) = 5 vbrf(n) = vbrf(n-1) - vbrf(n-2) + 3*vbrf(n-3) - 2*vbrf(n-4) if n > 3 Your job for this problem is to implement the function vbrf as a method in Java. Then write a program that uses this method to compute the function for various values of the argument and time how long it takes to...

  • c++ please read all question edit the program to test different random sizes of the array and give me the time in a file will be like random size of the array and next to it the time it took for each...

    c++ please read all question edit the program to test different random sizes of the array and give me the time in a file will be like random size of the array and next to it the time it took for each size Im trying to do time analysis for Quick sort but i keep getting time = 0 also i want edit the program to test different random sizes of the array and give me the time in a...

  • PLEASE HELP WITH THE FIX ME'S #include #include #include #include "CSVparser.hpp" using namespace std; //==...

    PLEASE HELP WITH THE FIX ME'S #include #include #include #include "CSVparser.hpp" using namespace std; //============================================================================ // Global definitions visible to all methods and classes //============================================================================ // forward declarations double strToDouble(string str, char ch); // define a structure to hold bid information struct Bid { string bidId; // unique identifier string title; string fund; double amount; Bid() { amount = 0.0; } }; //============================================================================ // Linked-List class definition //============================================================================ /** * Define a class containing data members and methods to *...

  • LANGUAGE IS C++ Lab Ch14 Recursion In this lab, you are provided with startup code which...

    LANGUAGE IS C++ Lab Ch14 Recursion In this lab, you are provided with startup code which has six working functions that use looping (for, while, or do loops) to repeat the same set of statements multiple times. You will create six equivalent functions that use recursion instead of looping. Although looping and recursion can be interchanged, for many problems, recursion is easier and more elegant. Like loops, recursion must ALWAYS contain a condition; otherwise, you have an infinite recursion (or...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT