Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago