Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the Lucas numbers: L n = L n - 1 + L n - 2 , n > 1 ; L 1 = 1
Consider the Lucas numbers:
;;
a Write a recursive function to compute using the above definition directly. Implement your solution and print where as output.
b Write a recursive functionprocedure to compute with time complexity more precisely, the time complexity should be when is large, where is the complexity of adding and Implement your solution and print where as output. This program must be able to compute precisely for Hint :
Let :;
With this formulation, design a recursive algorithm for such that the algorithm will return both and with input parameter
Hint : Can you use a primitive type to store
For programs in and of this question, you are NOT allowed to use Python. For C and Java, you can only use primitive types such as char, int, long and long long. You are not allowed to use large integer, such as BigInteger in Java, from the language library. You have to write your own large integer class or data type, if needed.
c Use the Unix time facility bash time command to track the time needed for each algorithm. Compare the results and state your conclusion in two or three sentences.
d Can you use your program in a to compute if int type of bytes is used? Briefly explain your answer. Explain why your program in b can computes precisely?
Algorithms and answers for b to d should be in asn solutions.pdf
For this question, for when compiling option could be considered and a makefile should be written such that the command "make clean" will remove all the o files, the command "make asna will generate an executable file "asna for a that can be run by typing "asna; and the command "make asnb will generate an executable file "asnb for b that can be run by typing "asnb If you are using Java, you may not need the makefile. In that case, you should have shell script files, "asna and "asnb such that by typing, "asna and "asnb your java programs will run.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started