Question: 1 . Objective: The student will practice how to - Implement a simple algorithm using dynamic arrays ( STL vectors ) - Design and implement
Objective:
The student will practice how to
Implement a simple algorithm using dynamic arrays STL vectors
Design and implement recursive functions.
Describe the running time of the recursive functions using recurrence relations.
Tasks:
Tribonacci sequence:
The Tribonacci sequence Tn is defined as follows:
mathrmTmathrm~Tmathrm~T and mathrmTmathrmnmathrmTmathrmnmathrmTmathrmnmathrmTmathrmn for mathrmn
Given n return the value of T n
Required:
Write a recursive function to calculate Tn
Write the recurrence relation of the Tribonacci function.
Fibonacci sequence:
The Fibonacci numbers, commonly denoted Fn form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from and That is F F
FnFnFn for n
Required:
Write a function to calculate Fn and consider the range of n
What is the time and space complexity for your code?
Reverse string recursively:
you need to design a recursive function that given a string S returns it in reversed order.
Required:
Write a recursive function to reverse a string.
Write the recurrence relation and determine its running time in big O notation.
Subarray division:
Given an array A find the number of subarrays of length m such that the sum of its elements equals d
Required:
Implement your algorithm to solve the problem.
What's the running time of your algorithm?
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
