answersLogoWhite

0

void main()

{

int i,j,temp1,temp2;

int arr[8]={5,3,0,2,12,1,33,2};

int *ptr;

for(i=0;i<7;i++)

{ for(j=0;j<7-i;j++) {

if(*(arr+j)>*(arr+j+1))

{ ptr=arr+j;

temp1=*ptr++;

temp2=*ptr;

*ptr--=temp1;

*ptr=temp2;

clrscr();

for(i=0;i<8;i++)

printf(" %d",arr[i]);

getch(); }

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

How does a quicksort algorithm with a visualization feature handle the selection of the pivot element as the first element in the array?

A quicksort algorithm with a visualization feature selects the first element in the array as the pivot element. This means that the algorithm will use the first element as a reference point for sorting the rest of the array.


How can the keyword "sorting" be implemented in pseudo code to arrange the elements of an array a of integers in ascending order?

To implement the keyword &quot;sorting&quot; in pseudo code to arrange the elements of an array a of integers in ascending order, you can use the following algorithm: Start by iterating through the array a from the first element to the second-to-last element. Compare each element with the next element in the array. If the current element is greater than the next element, swap their positions. Continue this process until the entire array is sorted in ascending order. Here is a simple example of pseudo code for implementing the sorting algorithm: for i from 0 to length(a) - 1 do for j from 0 to length(a) - i - 1 do if aj aj 1 then swap(aj, aj 1) end if end for end for This pseudo code represents a basic implementation of a sorting algorithm to arrange the elements of an array in ascending order.


What are the Application of quick sort?

Sorting an array.


C program to sort all elements of a 4x4 matrix?

This type of sorting can b performd by simply transferring all the matrix elements in a single dimension array of 1X16 size and then sorting this array and then transferring the elements back to 4X4 matrix. You can also treat the 4x4 matrix as a simple array using pointers and, thus, not need to transfer from matrix to array and back. Example, using ellipses (...) to simulate indentation for clarity... int matrix[4][4] = {...some values...} int *element; int flag = 1; while (flag == 1) { /* simple bubble sort */ ... flag = 0; ... /* loop from first element to next to last element */ ... for (element = &amp;matrix[0][0]; element &lt; &amp;matrix[3][3]; element ++) { ... ... if (*element &gt; *(element + 1)) { ... ... ... flag = 1; ... ... ... *element ^= *(element + 1); /* exclusive or swap */ ... ... ... *(element + 1) ^= *element; ... ... ... *element ^= *(element + 1); ... ... } ... } }


Sorting of array through function in java programming?

// the build in sorting functions in Java will sort pretty much any array // of Comparable objects or primitives Arrays.sort(someArray);


What is the fastest way to sort an array efficiently and effectively?

One of the fastest ways to sort an array efficiently and effectively is by using a sorting algorithm called Quicksort. Quicksort works by selecting a pivot element from the array and partitioning the array into two sub-arrays based on the pivot. The process is then repeated recursively on the sub-arrays until the entire array is sorted. Quicksort has an average time complexity of O(n log n) and is widely used for its speed and efficiency in sorting large datasets.


What is useful to implement quick sort?

Knowledge and experience.


What is the process for finding the kth smallest number in an unsorted array?

To find the kth smallest number in an unsorted array, you can use a sorting algorithm like quicksort or heapsort to arrange the array in ascending order. Then, you can simply access the kth element in the sorted array to find the kth smallest number. This process ensures that the kth smallest number is easily identified and retrieved from the array.


What is the value of the kth smallest element in the given array?

The value of the kth smallest element in the array is the kth element when the array is sorted in ascending order.


Sorting an array of numbers in java?

here you will a good example on java sorting algorithm application http://javacodespot.blogspot.com/2010/08/java-sorting-animations.html http://javacodespot.blogspot.com/


What is internal and external sorting techniques?

Internal sorting it means we are arranging the number within the array only which is in computer primary memory. External sorting it is the sorting of numbers from the external file by reading it from secondary memory.


Will an array element be deleted when you retrieve it from the array?

You cannot delete from an array.