Question

QUESTION 7 Consider the following list of integers indexed from 1 to 8 (i.e intList[1]-35, intList[8]-38) intList0 (35, 12, 2show work pls

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

At the first iteration of the first inner loop.

35 >12 is true

So, It swap the values of (12, 35).

and then 35 > 27 is true

So, It swap the values of (27, 35).

and then 35 > 5 is true

So, It swap the values of (5, 35).

and then 35 > 18 is true

So, It swap the values of (18, 35).

So, then 37 > 48 is false

So, the total number of values before 35 are 4

So, position of 35 is 5

An suer

a. 5

Add a comment
Know the answer?
Add Answer to:
show work pls QUESTION 7 Consider the following list of integers indexed from 1 to 8...
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
  • 4) [15 points total (5 points each)] Assume you are given a sorted array A of n numbers, where A is indexed from 1 up t...

    4) [15 points total (5 points each)] Assume you are given a sorted array A of n numbers, where A is indexed from 1 up to n, anda number num which we wish to insert into A, in the proper sorted position. The function Search finds the minimum index i such that num should be inserted into Ali]. It searches the array sequentially until it finds the location i. Another function MakeRoom moves A[i], .., AIn] to Ali+1]...AIn+1] same sort...

  • Consider the following pseudo-code: // Assume i, j, k are integers for i = 1 to...

    Consider the following pseudo-code: // Assume i, j, k are integers for i = 1 to n do for j = n-i+1 to n { k = 1; while (k*k <= j) { perform <op>; k = k + 1; } } Find an expression for f(n), the number of times is performed. Find g(n) so that f(n) is Θ(g(n)). Prove your answer.

  • Consider an array A[1...n] which is originally unsorted. One method to sort the array is as...

    Consider an array A[1...n] which is originally unsorted. One method to sort the array is as follows: First find the largest key in the unsorted portion of the array (initially the entire array s unsorted) and swap this with the last position in the unsorted section. This last position is now considered part of the sorted portion. The procedure is repeated until the entire array is sorted. (a) Write an algorithm to sort A as outlined above (in pseudo-code, no...

  • Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers...

    Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...

  • I have this Java program I need Help plz package ads.set2.select; public class Selector { public...

    I have this Java program I need Help plz package ads.set2.select; public class Selector { public static void main(String[] args) {   int index = 3;   int[] numbers = { 23, 4, 33, 11, 99,24 };   int results = select(numbers, index);   System.out.println("Element at index: " + index + " in sorted array is " + results);   // error case   select(numbers, 9); } /** * Returns the number that would be at index {@code index} in a sorted version * of the...

  • 1.             (5 marks) Perform a selection sort on the list 23, 59, 34, 13, 31, 10. Show...

    1.             (5 marks) Perform a selection sort on the list 23, 59, 34, 13, 31, 10. Show the list after each exchange that has an effect on the list ordering. 2.             (5 marks) Explain why the bubble sort algorithm does Ө(n2) comparisons on an n-element list. The bubble-sort algorithm is shown just after question 10 on p. 141. 3.              (5 marks) Write the resulting data list, give the ending value of legit, and find the exact number of copies done by the converging...

  • How do I write this in the c++ language? 1. (10 points) Write a program to...

    How do I write this in the c++ language? 1. (10 points) Write a program to implement Heapsort. The input should be an array of size at least 15. Have the user enter the values or you can specify your own array (unsorted). The output should be the final sorted array AND print out the values in the max heap (just the heap, NOT the full array) after each MAX-HEAPIFY (after BUILD- MAX-HEAP i.e. don't print output in BUILD-MAX-HEAP) in...

  • Sorting Sort the following array using the quick sort algorithm: (4 Marks) a. 12 26 8...

    Sorting Sort the following array using the quick sort algorithm: (4 Marks) a. 12 26 8 9 7 0 4 Pivot selection is defined to be the first element of each sub-list. Show the array before and after each quicksort round (when the array is partitioned after placing the pivot at its correct position). Also, clearly highlight the pivot in each partition b. Consider an unsorted array of integers of size n. Write a Java program to arrange the array...

  • Consider the following: Algorithm 1 Smallest (A,q,r) Precondition: A[ q, ... , r] is an array...

    Consider the following: Algorithm 1 Smallest (A,q,r) Precondition: A[ q, ... , r] is an array of integers q ≤ r and q,r ∈ N. Postcondition: Returns the smallest element of A[q, ... , r]. 1: function Smallest (A , q , r) 2: if q = r then 3: return A[q] 4: else 5: mid <--- [q+r/2] 6: return min (Smallest(A, q, mid), Smallest (A, mid + 1, r)) 7: end if 8: end function (a) Write a recurrence...

  • QUESTION 8 Consider the following propositional functions. Choose the true statements. If we know that p(1)...

    QUESTION 8 Consider the following propositional functions. Choose the true statements. If we know that p(1) is true and we know that the truth of p(n) implies the truth of p(n + 1), then we know that pn) is true for all positive integers n. If we know that p(1) is true, and we know that for all positive integers, if p(n) is true then pln+2) is true, then p(n) is true for all n 2 1. If we know...

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
ADVERTISEMENT