Question: these are 3 different programs, please code all three problems Problem description: You need to write a recursive function in climbing Stairs(int n). This function
these are 3 different programs, please code all three problems



Problem description: You need to write a recursive function in climbing Stairs(int n). This function takes only one parameter n. Suppose that you're climbing a staircase with stairsteps. Each time you can choose to climb either 1 step or 2 steps. Your function shall return the total distinct ways in which you can climb to the top. Sample input/output: Input Output Explanation There are two ways to climb to the top: 1. 1 step + 1 step 2. 2 steps Input Output Explanation There are three ways to climb to the top: 1. 1 step + 1 step + 1 step 2. 1 step + 2 steps 3. 2 steps + 1 step You need to write a recursive function int god (int numl, int num2). This function takes two ints as parameters -num/ and num2. Your function shall return the greatest common divisor of num/ and num2. If either num/ or num2 is negative or 0, return -1. Sample input/output: Input 24, 36 Output 12 Input 7,5 Output Problem description: You need to write a recursive function in binary Search(int[array, int target, int left, int right). The function takes four parameters: a sorted int array, a target number, left index, and right index. The sorted int array contains only positive integers, with each integer appear only once. Your job is to use binary search to locate the index of target. The left index and right index are just for your convenience when using recursion. Return -1 if you can't find the target. You may assume that the first input of int left and int right will always be 0 and array.length-1, respectively. Sample input/output: Input Array: [1, 2, 3, 5, 6, 8, 13] left: 0 right: 6 Target: 3 Output Explanation: The index of 3 is 2 Input Array: [1, 2, 3, 7, 8] left: 0 right: 4 Target: 5 Output Explanation: 5 is not in this array
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
