Question: In C coding language, not C + + , please complete the following 2 code files wherever a / / TODO is marked. The
In C coding language, not C please complete the following code files wherever a TODO" is marked. The instructions are also attached for reference. A picture of another file, jacobsthal.c is also attached, but only for reference and not to be completed.
Code file #jacobsthalMemoizationc:
#include
#include
#include
Computes the nth Jacobsthal number using an iterative
method
long long jacobsthalIterativeint n;
TODO: place your prototype and documentation here
Hint: it should return a long long integers
it should take a cache array of long longs as well
This program computes the nth Jacobsthal number using recursion.
It also reports how long the program takes to execute.
int mainint argc, char argv
if argc
fprintfstderr "Usage: s n
argv;
exit;
int n atoiargv;
TODO: set up our tablecache which is of size n since we
compute values from J to Jn inclusive
TODO: initialize the table values
take care of the base cases
set all other values to a flag value to indicate
the value has not yet been computed and cached
timet start, end;
long long iterativeResult jacobsthalIterativen;
start timeNULL;
TODO: call your function here
end timeNULL;
int time end start;
printfIterative: Jacobsthaldlld
n iterativeResult;
printfMemoization: Jacobsthaldlld
n memoizationResult;
printfTotal Computation Time: d seconds
time;
return ;
TODO: write your memoizationbased Jacobsthal function here
long long jacobsthalIterativeint n
ifn
return n;
long long prev ;
long long curr ;
forint i; in; i
long long t prev curr;
prev curr;
curr t;
return curr;
Code file #palindromec:
A program to compute whether or not a given
string is a palindrome the same backwards as
forwards
#include
#include
#include
This function should return true if the given substring is
a palindrome. The function should be recursive.
int isPalindromeconst char str int leftIndex, int rightIndex;
int mainint argc, char argv
if argc
printfUsage: isPalindrome word
;
exit;
int isPal isPalindromeargv strlenargv;
if isPal
printfs is a palindrome!
argv;
else
printfs is NOT a palindrome!
argv;
return ;
int isPalindromeconst char str int leftIndex, int rightIndex
TODO: implement this function as specified
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
