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...

  • please use c++ language 1. Request three different integers from the console. a) Write a swap...

    please use c++ language 1. Request three different integers from the console. a) Write a swap function that swaps two integer values. b) Write a sort function which accepts three integers as input then sorts them from largest to smallest using the swap function. c) Output the integers before and after sorting. Example 1 Output (input in bold italics) Enter three different integers: 3 2 4 3 2 4 4 3 2 Example 2 Output (input in bold italics) Enter...

  • 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...

  • 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...

  • 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...

  • 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...

  • this is c code. please answer all questions on a piece of paper and show work....

    this is c code. please answer all questions on a piece of paper and show work. i need to prepare as i have a midterm i will have to be completing on paper 1) Bit Operators: This C program compiles and runs. What is its output? 1) #include <stdio.h> 2) void main (void) 3) unsigned char x =60; 4) 5) 6) 7) 8 ) 9) 10) 11) 12) 13) unsigned char a = x < 1; unsigned char b unsigned...

  • Question 13 pts (TCO 4) Which of the following functions grows at a slower rate than...

    Question 13 pts (TCO 4) Which of the following functions grows at a slower rate than the rest? n2 n log n n3 Flag this Question Question 23 pts (TCO 4) Algorithms can be described using pseudo-code. assignment and arithmetic operations. loops and decision statements. All of the above Flag this Question Question 33 pts (TCO 4) The running time of an algorithm is the time, in milliseconds, it takes to complete its execution. the running time of its implementation....

  • 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...

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