Question: Question 3: Recursion (40 points) Write a recursive function printFlag(A) that takes an array of integers A as input, prints a flag-shape pattern from it

 Question 3: Recursion (40 points) Write a recursive function printFlag(A) that
takes an array of integers A as input, prints a flag-shape pattern

Question 3: Recursion (40 points) Write a recursive function printFlag(A) that takes an array of integers A as input, prints a flag-shape pattern from it as follows: the first level is simply the list of all the elements in the array from the second level onward, the number of elements at each level is half the number of the elements at the previous level, and the 7th element at the current level equals the sum of the ath and the (n-i)th elements from the previous level See below for sample input and output. Make sure to test your function before submitting. Sample: Input: A= {1,2,3,4,5,6,7) Output: 11.2.3,4,5,6,7) 18,8,8] [16] Explanation: (1,2,3,4,5,6, 7) -> (1+7= 8, 2+6 = 8, 3+5 = 8) --> (8,8,8) -> (8 + 8 = 16) -> (16) >

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!