answersLogoWhite

0


Best Answer

Selection sort has the following implementation:

// sort an array if integers of length size in ascending order using selection sort algorithm:

void selection_sort (int a[], unsigned size) {

unsigned i, max;

while (size > 1) {

max = 0;

for (i=1; i!=size; ++i) if (a[i] > a[max]) max = i;

swap (a[max], a[--size]);

}

}

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you implement selection sort in c with graphics?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you implement a program to display the Indian flag with colors using c graphics?

ANSI/ISO C does not and never has done graphics.


How do you run graphics program in C?

pro c language to implement linear search using pointers


Different types of sorting techniques in c language?

types of sorting in c language are: insertion sort selection sort bubble sort merge sort two way merge sort heap sort quick sort


How do you implement graphics in C on windows vista?

Install Dos BOx in your computer.. open it and write mount c c:\turboc3 if the c folder is c:\turboc3. now move to c: and simply type the name of the C executable file for example TC. C will open and you will be able to do graphics programming.. but dont use ctrl+f9 to run the program... go to the menu and select the appropriate option


Why graphics mode use in c?

C has nothing to do with graphics.


Explain use of graphics in C language?

C has nothing to do with graphics.


How do you program c plus plus to arrange 3 numbers in ascending order using swap?

void sort (int& a, int& b, int& c) { if (a>b) std::swap (a, b); if (b>c) std::swap (b, c); else return; if (a>b) std::swap (a, b); } Note that this is based upon a bubble sort algorithm. Although usually inefficient as a general sorting algorithm, given that we know there are only three elements means we can implement it reasonably efficiently without any additional space complexity. There will always be 2 or 3 comparisons but at most there will be 3 swaps. The only improvement we could really make is to implement a type of selection sort: void sort (int& a, int& b, int& c) { if (a>b && a>c) std::swap (a, c); else if (b>c) std::swap (b, c); if (a>b) std::swap (a, b); } Here we either make 3 or 4 comparisons but only 2 swaps at most. The assumption here is that a comparison is a quicker operation than a swap thus the selection sort method is more efficient. However, unless you were to sort millions of sets of three one after the other, you are unlikely to see any measurable difference in performance.


Simple c program for selection sort?

The Selection Sort definition is rather simple : find the largest number (element) in a list and move it to it's position in sorted form.You can perform selection sort like, smallest elements are in the beginning and largest element at the end.Now how this element arrange to it's exact position,We can do this by swapping elements at highest index and the process is continue till all the elements are sorted.


Why use setcolor function in c graphics?

C language doesn't say anything about graphics, it is platform-dependent.


Can you implement the same using c?

Some function are not using in c


C code to implement the file allocation algorithm?

yes we can do it,in c


How to solve bgi error Graphics not initialised in C?

to install the graphics driver