hello all

This question is all about implementation and design.

Given an array of n elements print array’s elements in ascending order or descending order without changing the array’s elements and without creating any new array.

i know there may be several possible ways of doing this.

here is my approach .

MIN=INT_MAX;

MAX=INT_MIN;

for(int j=0;j<n;j++){

for(int i=0;i<n;i++){

```
if(A[i]<MIN&&A[i]>MAX){
MIN=A[i];
count=1;
```

}else if(A[i]==MIN&&A[i]>MAX)

```
count++;
```

}

while(count–){

```
cout<<MIN<<" ";
```

}

MAX=MIN;

MIN=INT_MAX;

count=0;

}

this will print all the array’s element in ascending order similarly we can do this for descending order too.

I want all of you to discuss all the possible ways of doing this question and if anyone is having any doubts regarding my approach the comment.

I am also having one more approach for tackling the same question i will discuss it here soon.

it is selection sort basicly

Simplest answer just use Selection sort method which element smallest in each iteration print element