Question: 1. The Fibonacci sequence is defined as a sequence of integers where each number is the sum of the two preceding ones. The following function


1. The Fibonacci sequence is defined as a sequence of integers where each number is the sum of the two preceding ones. The following function returns the nth Fibonacci number. Show the computation steps for Fibonacci (4) (2 pts) int fibonacci (int n) if (n. 0) return 0 else if (n 1) return 1; else return fibonacci (n-1 fibonacci (n 2. What does the following function return for each input: (2 pts) nt puzzle (char val int a int b) if (a b) return 1; else if (val la val [b]) return puzzle (val, a b-1) -1 else return 0 a. val 'a', 'y, 'a', 'k') b-5 val m, a IT, m 3. The following function counts the occurrences of character x in an array. Fix the errors (3 pts) int coun toccurences (char data [J, char x, int idx) int count 0; if (data [idx] x) count 1; return countoccurences (data x, idx
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
