Question
please answer all parts and code thanks
. - PART 1-Introduction to Sorting, 21 points Use this array of integer for the problems 1A, 1B, and 1c: 9 57 8324761 Each of
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Part 1 . <A>

Step 1 : 9,5,7,8,3,2,4,7,6,1

Step 2 : 5,7,8,3,2,4,7,6,1, 9

Step 3 : 5,7,3,2,4,7,6,1, 8,9

Step 4 : 5,3,2,4,7,6,1, 7,8,9

Step 5 : 5,3,2,4,6,1, 7,7,8,9

Step 6 : 5,3,2,4,1, 6,7,7,8,9

Step 7 : 3,2,4,1, 5,6,7,7,8,9

Step 8 : 3,2,1, 4,5,6,7,7,8,9

Step 9 : 2,1, 3,4,5,6,7,7,8,9

Step 10 : 1, 2,3,4,5,6,7,7,8,9

Step 11 : 1,2,3,4,5,6,7,7,8,9 Completed

Part 1 . <B>

Step 1 : 9,5,7,8,3,2,4,7,6,1

Step 2 : { 1 },{ 9,5,7,8,3,2,4,7,6 }

Step 3 : { 1,2 },{ 9,5,7,8,3,4,7,6 }

Step 4 : { 1,2,3 },{ 9,5,7,8,4,7,6 }

Step 5 : { 1,2,3,4 },{ 9,5,7,8,7,6 }

Step 6 : { 1,2,3,4,5 },{ 9,7,8,7,6 }

Step 7 : { 1,2,3,4,5,6 },{ 9,7,8,7 }

Step 8 :  { 1,2,3,4,5,6,7 },{ 9,8,7 }

Step 9 : { 1,2,3,4,5,6,7,7 },{ 9,8 }

Step 10 : { 1,2,3,4,5,6,7,7,8 },{ 9 }

Step 11 : { 1,2,3,4,5,6,7,7,8,9 } Completed

Part 1 . <C>

Step 1 : 9,5,7,8,3,2,4,7,6,1

Step 2 : 2,5,7,8,3, 9,4,7,6,1 compare 9,2 and sort

Step 3 : 2,4,7,8,3, 9,5,7,6,1 compare 5,4 and sort

Step 4 : 2,4,7,8,3, 9,5,7,6,1 compare 7,7 and sort

Step 5 : 2,4,7,6,3, 9,5,7,8,1 compare 8,6 and sort

Step 6 : 2,4,7,6,1, 9,5,7,8,3 compare 3,1 and sort

Step 7 : 1,4,7,6, 2,9,5,7, 8,3 compare 2,1,8 and sort

Step 8 :  1,4,7,6, 2,3,5,7, 8,9 compare 4,9,3 and sort

Step 9 : 1,4,5,6, 2,3,7,7, 8,9 compare 7,5 and sort

Step 10 : 1,4,5,6, 2,3,7,7, 8,9 compare 6,7 and sort

Likewise we will get { 1,2,3,4,5,6,7,7,8,9 } Completed

Part 1 . <D>

Here the algorithm A is just searching in the list but the algorithm B is focusing over the sorting and then searching so as algorithm A includes only linear search so its very fast as comparison to the algorithm B.

Part 1 . <E>

This is the c language code for given problem

#include <stdio.h>

int main()
{
int i,j,c,d,swap,x;
int n=5;
int position=0;
printf("Here the program starts: \n");
int disp[5][5] = {
{1,2,3,4,5},
{3,4,5,1,2},
{5,2,3,4,1},
{2,3,1,4,5},
{4,2,3,1,5}
};
for(i=0; i<5; i++)
{
for(j=0;j<5;j++)
{
printf("%d ", disp[i][j]);
}
printf("\n");
}
for (c = 0; c < (n - 1); c++)
{
position = c;

for (d = c + 1; d < n; d++)
{
if (disp[position][0] > disp[d][0])
position = d;
}
if (position != c)
{
for(x=0;x<n;x++)
{
swap = disp[c][x];
disp[c][x] = disp[position][x];
disp[position][x] = swap;
};
}
}
printf("Here the array is sorted : \n");
for(i=0; i<5; i++)
{
for(j=0;j<5;j++)
{
printf("%d ", disp[i][j]);
}
printf("\n");
}
return 0;
}

Part 2 . <A>

Here output be like

step 1 : first queue starts

step 2 : queue : Jane

step 3 : queue : Jane, Jess

step 4 : queue : Jane, Jess, Jon

step 5 : Jane removed from queue

step 6 : Jess will be printed on screen

step 7 : Jim added to queue and its like queue : Jess, Jon, Jim

step 8 : jess removed from queue and gone to my string

step 9 : Jess will be printed on screen Jon

Add a comment
Know the answer?
Add Answer to:
please answer all parts and code thanks . - PART 1-Introduction to Sorting, 21 points Use...
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
  • Please come up with an array of 9 random integers then sort the array. Show the...

    Please come up with an array of 9 random integers then sort the array. Show the contents of the array each time a sorting algorithm changes it while sorting the array into ascending order. The 6 sorting algorithm we are using are: 1. Selection Sort 3 points 2. Insertion Sort 3 points 3. Shell Sort 6 points 4. Bubble Sort 3 points 5. Merge Sort 10 points 6. Quick Sort 10 points It is OK to do this assignment on...

  • _______________________________________________________________________________________________ java language-trace instructions". (20 points) Show the contents of the array below, once the contents...

    _______________________________________________________________________________________________ java language-trace instructions". (20 points) Show the contents of the array below, once the contents of the array below, once the "pivot" element is placed at its location after each call of the "Partition” algorithm, in the process of running Quick-Sort on said array. Arrange the data in ascending order (Trom Arrange the data in ascending order (from smallest to largest value). Always select the first element of the partition as "pivot" in data cat B. Apply sorting on...

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

  • cis 112 (java reqire to use JGRASP) Searching and Sorting Assignment This is a non-object oriented...

    cis 112 (java reqire to use JGRASP) Searching and Sorting Assignment This is a non-object oriented assignment. This assignment is due at the start of class on July 16, Create a program that populates and array with 100 random integers between 0 and 99. Then print out the array. Then prompt the user for a number, and do a sequential search on the unsorted array and return whether or not the number was in the array. Then sort the array...

  • Sorting Threads Assignment Overview Write a multithreaded sorting program in Java which uses the ...

    Sorting Threads Assignment Overview Write a multithreaded sorting program in Java which uses the merge sort algorithm. The basic steps of merge sort are: 1) divide a collection of items into two lists of equal size, 2) use merge sort to separately sort each of the two lists, and 3) combine the two sorted lists into one sorted list. Of course, if the collection of items is just asingle item then merge sort doesn’t need to perform the three steps,...

  • Java We did in lecture, and explain your answer briefly. Problem 4: Sorting practice 14 points;...

    Java We did in lecture, and explain your answer briefly. Problem 4: Sorting practice 14 points; 2 points for each part individual-only Important: When answering these questions, make sure to apply the versions of these algorithms that were discussed in lecture. The Java code for each algorithm can be found in our Sort class. Given the following array: {14, 7, 27, 13, 24, 20, 10, 33 1. If the array were sorted using selection sort, what would the array look...

  • Here is the code given for this problem: **And please do this in Python** def mergesort(mlist): if len(mlist)<2: ret...

    Here is the code given for this problem: **And please do this in Python** def mergesort(mlist): if len(mlist)<2: return mlist else: mid=len(mlist)//2 return merge(mergesort(mlist[:mid]),mergesort(mlist[mid:])) Problem 1 (30 points) stable merge sort Consider the following unsorted list of integers containing duplicates where the relative position of each duplicated integer in the unsorted list is noted as a subscript. For example, 1, is at a smaller index than 12. The subscript is ignored when comparing two values since it would not actually...

  • Hi i will give you a thumbs up if you do this problem correctly. Sorting Analysis Code and Essay ...

    Hi i will give you a thumbs up if you do this problem correctly. Sorting Analysis Code and Essay Due: 4/22/2019(Monday) Introduction And now for something completely different.   Different sorting algorithms are better for different size data sets.   Other sorting algorithms are better for data sets of a specific type – for instance, data that is already ordered. In this assignment you will implement four different sorting algorithms and collect statistics for each of those algorithms while sorting multiple different...

  • Radix sort C++ Come up with an unsorted array of numbers (integer array). Sort the numbers...

    Radix sort C++ Come up with an unsorted array of numbers (integer array). Sort the numbers in ascending order and descending order and display them using radix sort. First sort in ascending, then reset the array to its original order and finally sort the array again in descending order. USE THIS STUCTURE struct nodeQ{                            node *front;                            node *rear;               };               nodeQ que[10]; enqueue(que[i],data); EXAMPLE: Original, unsorted list: [170, 45, 75, 90, 2, 802, 24, 66] 1ST PASS:...

  • please I need it urgent thanks algorithms 2.1 Searching and Sorting- 5 points each 3. What is the worst case for quick sort? What is the worst case time com- plexity for quick sort and why? Ex...

    please I need it urgent thanks algorithms 2.1 Searching and Sorting- 5 points each 3. What is the worst case for quick sort? What is the worst case time com- plexity for quick sort and why? Explain what modifications we can make to quick sort to make it run faster, and why this helps. 4. Give pseudocode for an algorithm that will solve the following problem. Given an array AlL..n) that contains every number between 1 and n +1 in...

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