Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This has to use a sublinear time complexity function Problem #3: (40 points) The Fibonacci sequence fib: is defined recursively as follows: fib(1)1, fib(2) 1

image text in transcribedThis has to use a sublinear time complexity function

Problem #3: (40 points) The Fibonacci sequence fib: is defined recursively as follows: fib(1)1, fib(2) 1 and, fib(n)-fib(n-1)+ fib(n-2) for n 2 3 The numbers in the Fibonacci sequence are called the Fibonacci numbers, for example: 11, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233.. (a) Implement a sub-linear time complexity function in Java. int fib(int n) that returns the nth Fibonacci number. Example: fib(9) returns 34. (b) What is the running time complexity of your function? Justify your answer by using the basic algorithms techniques of algorithm analysis. Important Notes: Your Java program should print correctly the fib(250); fib(250)7896325826131730509282738943634332893686268675876375 In the resolution of this problem it is not allowed (and is not a good idea) to use the Binet's formula. .You must add the main method in your program in order to test your implementation There are no data errors that need to be checked as all the data will be assumed correct. Your program MUST be submitted only in source code form (.java file). A program that does not compile or does not run loses all correctness points

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions