Question

Consider the following lines of Matlab code 1 arr-14,7.2,5,1,6: 2 for j 2:length(arr) 3 key arr) 4 i j-1; 5 while i - 1 && ar

Select one: a, arr = [2, 7, 7, 5, 1,6] b.arr=[4, 4, 7, 5, 1,6] c, arr 2, 4, 7, 7, 1, 6] d.arr=[2, 4, 4, 7, 1,6]

0 0
Add a comment Improve this question Transcribed image text
Answer #1

output: answer is

C.arr=[2,4,7,7,1,6]

Explanation:

La 63 h (ani ke while (i) lhe loop output : Lv,5 b] Ly132、output : [Ч.ч.4, 51116] Ql9ea ItOutput:

4, 7, 2, 5, 1, 6] 4, 4, 7, 5, 1, 6] 2, 4, 7, 7, 1, 6] 2, 2, 4, 5, 7, 6] 1, 2, 4, 5, 7, 7]

Add a comment
Know the answer?
Add Answer to:
Consider the following lines of Matlab code 1 arr-14,7.2,5,1,6: 2 for j 2:length(arr) 3 key arr)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Consider the following code C++ like program: int i, j, arr[5]; //arr is an array starting...

    Consider the following code C++ like program: int i, j, arr[5]; //arr is an array starting at index 0 void exchange(int x, int y) { int temp:= x; x:= y; y:= temp; } main(){ for (j = 0; j < 5; j++) arr[j]:= j; i:= 1; exchange(i, arr[i+1]); output(i, arr[2]); //print i and arr[2] } What is the output of the code if both parameters in function swapping are passed by: a- value? b- reference? c- value-result?

  • Question 3 (2 points) Linear time sort a) Call COUNTING-SORT on the input array A (6,0,2,0,1,3,4,...

    Question 3 (2 points) Linear time sort a) Call COUNTING-SORT on the input array A (6,0,2,0,1,3,4,6,1,3,2). Using the plots on slide #67 as a model, illustrate array C after the second for loop (line 5 to 6) and the third for loop (line 7 to 8) are executed, respectively; then illustrate array B and C after executing the first 2 iterations of the fourth for loop (line 10 to 12), respectively Using the plots on slide #81 as a model,...

  • matlap Question 1 1. Consider the following Matlab program 5 - (2 < 3) & (C2...

    matlap Question 1 1. Consider the following Matlab program 5 - (2 < 3) & (C2 > 3) 1 (1 - 0)) What is the final value of s? A. True B. *1 CO D. false 2- Which expression tests whether variable x is between (but not the same as) the values 5 and 10 (a) 5 <x< 10 (b) 5 <= x <= 10 (c) 5 < X & X > 10 (d) x < 10 & 5 <...

  • In the blank below, write the contents of array arr after the following code is executed...

    In the blank below, write the contents of array arr after the following code is executed up to the comment indicated in the main procedure below? #include <iostream> #include <algorithm> using namespace std; void do something(int list[], const int size); int main() { const int SIZE(10); int arr[SIZE] = { 5, 8, 1, 7, 3, 9, 4, 6, 10, 2 }; do somethingCarr, SIZE); ** Write the contents of array arr in the space below when execution reaches here. */...

  • 1 int i, j, k; 2 for (i = 1; i <= 4; i++) 3 {...

    1 int i, j, k; 2 for (i = 1; i <= 4; i++) 3 { 4 j = 1; 5 while (j < 4) 6 { 7 if (i % 2 == j % 2) 8 k = 100*i + 10*j; 9 else 10 k = 100*j + 10*i; 11 j++; 12 } 13 } What will be the value of the variable k at the end of the third, sixth, ninth, and twelfth iteration of the while loop

  • Question 3 QUESTION //Sort the array arr[] for (int i = 0; i< arr.length - 1;...

    Question 3 QUESTION //Sort the array arr[] for (int i = 0; i< arr.length - 1; i++) { for (int j = 1; i < arr.length - i; j++) { if (array[i-1] > array[i]) { // swap (j-1, ) }//if }//for i }//for i In the array= 19 7 23 12 4 8 17 158, after the completion of the outer iteration #4 , the array becomes = Answer

  • Question 1) Suppose a program has the following code: const int X = 2, Y =...

    Question 1) Suppose a program has the following code: const int X = 2, Y = 3; int sum; int values[X][Y] = {{1, 2, 3},                                  {4, 5, 6}}; for(int i=0; i<X; i++) {      sum=0;      for(int j=0; j<Y; j++)         sum+=values[i][j];    cout<<sum<<endl; } What is this program getting the sum of? Group of answer choices D-) The columns of the 2D array C-) The rows of the 2D array A-) All of the elements of the 2D...

  • Consider the following code segment. int[]arr={1, 2, 3, 4, 5, 6, 7, 8}; for(int k=3; k<arr.length-1;...

    Consider the following code segment. int[]arr={1, 2, 3, 4, 5, 6, 7, 8}; for(int k=3; k<arr.length-1; R++ arr[k]-arr[k+1]; What are the contents of arr as a result of executing the code segment? a. {1, 2, 3, 5, 6, 7, 8, 8) b. {2, 2, 4, 5, 6, 7, 8, 8} C. {2, 4, 6, 5, 6, 7, 8,8} d. {4, 2, 4, 4, 6, 7, 8, 8) e. {6, 6, 4, 5, 6, 7, 8, 8} int) arr={7, 2.5, 3.0,...

  • Bubble sort is a popular, but inefficient, sorting algorithm. It works by repeatedly swapping adjacent elements...

    Bubble sort is a popular, but inefficient, sorting algorithm. It works by repeatedly swapping adjacent elements that out of order. BUBBLESORT(A) 1. for i = 1 to A.length – 1 2. for j = i + 1 to A.length 3. if A[j] < A[i] 4. exchange A[j] with A[i] a) A loop invariant for the outer for loop in lines 1 – 4 is: At iteration i, the sub-array A[1..i] is sorted and any element in A[i+1..A.size] is greater or...

  • How do I answer the two problems correctly? ECEN IU what are the values ofA, m and w after execution of these MATLAB ommands bse a table to understand the lines of code. If your answer is not clea...

    How do I answer the two problems correctly? ECEN IU what are the values ofA, m and w after execution of these MATLAB ommands bse a table to understand the lines of code. If your answer is not clear or is messy, I will take off points. ( m = 7; while A >5,5a m=m+1; end b.S S4-f What is the value of T after execution of these MATLAB commands. T is called an array. An array is an arrangement...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT