Question: The current selected programming language is CPP . We emphasize the submission of a fully working code over partially correct but efficient code. Once submitted,

The current selected programming language is CPP. We emphasize the submission of a fully working code over partially correct but efficient code. Once submitted, you cannot review this problem again. You can use cout to debug your code. The cout may not work in case of syntax/runtime error. The version of GCC being used is 5.5.0.
An alternate sort of a list consists of alternate elements (starting from the first position) of the given list after sorting it in an ascending order. You are given a list of unsorted elements. Write an algorithm to find the alternate sort of the given list.
Input
The first line of the input consists of an integer size, representing the size of the given list (N).
The second line consists of N space-separated integers ar0,ar1,dots... arr NN representing the elements of input list.
Output
Print space-separated integers representing the alternately sorted elements of the given list.
Constraints
0 size 106
-106arn106
0i size
Example
Input:
8
351591026
Output:
1359
Explanation:
After sorting, the list is 1,2,3,5,5,6,9,10.
50, the alternate elements of the sorted list are 1,3,5,9.
 The current selected programming language is CPP. We emphasize the submission

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!