Question

In: Advanced Math

Suppose A is (10, 2, 5, 9, 1, 8, 2, 4). Consider the function: int BBOX(int...

  1. Suppose A is (10, 2, 5, 9, 1, 8, 2, 4). Consider the function:

int BBOX(int n, int k)

            if (n <= 0) return 0;

            else if (A[n] < k) return (1+ 2*BBOX(n-1,k+1));

            else return BBOX(n-1,k-2);

            Find BBOX(8, 5)

Solutions

Expert Solution

If you find my answer useful please put thumbs up. Thank you.

Explaination of the function BBOX(int n, int k):

  1. The value of n is checked first. If the value of n is less than or equal to 0, then the programs returns zero. If the value of n is not less than or equal to 0, then go to step 2.
  2. Here, the value of A[n] is compared with the value of k. If A[n] is less than the value of k, then the program recursively calls itself, i.e BBOX(n-1, k+1). Then multiplies its value with 2, adds 1 and retuens the final value. If the condition is not true, i.e if A[n] is not less than k then go to step 3.
  3. Here, the function calls itself BB)X(n-1, k-2)

The working of the function call BBOX(8,5) is shown below


Related Solutions

Consider the following function ?(?) = ?^ 4+ 2? ^3 + 8?^ 2+ 5? With the...
Consider the following function ?(?) = ?^ 4+ 2? ^3 + 8?^ 2+ 5? With the initial guesses of ?1 = −2, ?2 = −1, and ?3 = 1, find the minimum of the given function using parabolic interpolation. Perform five iterations, reporting Ɛa based on the location of the minimum (i.e. xopt) and not the actual minimum value. (Round the final answer to four decimal places.)
1.Consider the program: .data myArray: .word 1, 2, 3, 4, 5, 6, 7, 8, 9, 10...
1.Consider the program: .data myArray: .word 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 .text la $s0, myArray li $s1, 0 loop: sll $t0, $s1, 2 add $t0, $t0, $s0 lw $s2, 0($t0) lw $s3, 4($t0) add $s2, $s2, $s3 sw $s2, 0($t0) addi $s1, $s1, 1 slti $t1, $s1, 9 bne $t1, $zero, loop .end Explain what does this program do? How is the data bound from the .data segment to the base address register $s0? What...
A = (1 −7 5 0 0 10 8 2 2 4 10 3 −4 8...
A = (1 −7 5 0 0 10 8 2 2 4 10 3 −4 8 −9 6) (1) Count the number of rows that contain negative components. (2) Obtain the inverse of A and count the number of columns that contain even number of positive components. (3) Assign column names (a,b,c,d) to the columns of A. (4) Transform the matrix A into a vector object a by stacking rows. (5) Replace the diagonal components of A with (0,0,2,3). Hint:...
5.) For the data set 2 4 4 5 7 8 9 10 12 12 13...
5.) For the data set 2 4 4 5 7 8 9 10 12 12 13 13 16 16 16 16 17 19 19 20 23 24 24 24 25 26 26 27 28 28 29 31 32 34 34 36 37 38 42 44 45 46 47 47 48 50 52 53 53 54 55 56 56 57 58 (a) Find the 80th percentile. The 80t percentile is =    (a) Find the 42nd percentile. The 42nd percentile is...
5. (20%) Suppose we have an array int a [8] = {1, 2, 3, 5, 6};...
5. (20%) Suppose we have an array int a [8] = {1, 2, 3, 5, 6}; and we also have a linked list L of 5 entries 1 -> 2 -> 3 -> 5 -> 6, where 1 is the first in the linked list L, followed by 2 etc. We want to put a new item 4 between 3 and 5 in the array a and in the linked list L (a) Explain in plain English how you do...
Consider the following set of observations: Obs. 1 2 3 4 5 6 7 8 9...
Consider the following set of observations: Obs. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 input 1 2 3 4 5 6 7 8 9 10 11 12 13 14 result 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Enter the data in L1 and L2 in your TI calculator, find the regression line, and construct a scatterplot with the regression line included. Does a line appear to...
A = [4, 5, 9] B = [-4, 5, -7] C = [2, -7, -8, 5]...
A = [4, 5, 9] B = [-4, 5, -7] C = [2, -7, -8, 5] D = [1, -9, 5, -3] E = [3, 3, -1] Uz = 1/|z| ^z d(X,Y) = (Rθ) d = diameter R = Radius θ = Theta Find a. Uc b. d (D, C) c. Let P = B + 3E, UP = d. A x B e. 3B x E f. C x D
tens Units 1 5 2 3 4 8 5 2 5 6 9 6 1 3...
tens Units 1 5 2 3 4 8 5 2 5 6 9 6 1 3 5 4 7 9 7 0 0 4 5 6 9 9 8 1 3 5 6 8 9 9 0 1 2 3 5 9 The table represent a random sample of 31 test scores taken from a large lecture class. Find the following [round to 2 decimal points X. XX] a) [2 pts] Find the 5 number summary [L, Q1, Q2, Q3,...
QUESTION 5 What is printed? int[] aArray = {1, 2, 3, 4}; int[] bArray = {5,...
QUESTION 5 What is printed? int[] aArray = {1, 2, 3, 4}; int[] bArray = {5, 6, 7, 8}; bArray = aArray; System.out.print(bArray[2]); 1 points    QUESTION 6 What is printed? public static void main(String[] args) { int[] aArray = { 1, 2, 3, 4 }; System.out.print(aArray[2]); int i = aMeth(aArray); System.out.print(i + "" + aArray[2]); } public static int aMeth(int[] iArray) { for (int i = 0; i < iArray.length; i++) { iArray[i]++; } int[] bArray = { 5,...
Match No. 1 2 3 4 5 6 7 8 9 10 11 12 13 14...
Match No. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Player A 8 42 56 68 91 123 12 46 57 137 5 80 14 10 19 Player B 38 44 46 59 57 61 48 42 51 39 58 41 55 45 68 1. For the given data set representing the runs scored by two players in last 15 matches, conduct the following analysis: i. Which average you will use to summarize...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT