Wave sort Doubt

Hi , for this wave sort question if the input array is
int a[]={1,3,4,2,7,8};

so can the output be
3 1 4 2 8 7

I have used the logic of even index value should be greater than the odd index value. if not i am swapping it

Please refer to the following code:

@idontknowhowtocode Yes there can be multiple possible outputs for WaveSort question. It will depend on your approach. You just need to ensure that your output numbers are forming a wave like pattern graphically.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like