Computer Science, asked by gangakvpattom4013, 1 month ago

A parade is arranged for Independence Day celebrations in your campus. A line of students are arranged in odd and even positions. Now the students in the odd positions are to be sorted in the descending order and the students in the even position are to be sorted in ascending order, given a 1 D array. The maximum length of the line is 20. Display – ‘Invalid Size’, if the input specified is zero or negative. Write an algorithm to implement the above scenario.

Answers

Answered by jainsarita3128
0

Answer:

A parade is arranged for Independence Day celebrations in your campus. A line of students are arranged in odd and even positions. Now the students in the odd positions are to be sorted in the descending order and the students in the even position are to be sorted in ascending order, given a 1 D array. The maximum length of the line is 20. Display – ‘Invalid Size’, if the input specified is zero or negative. Write an algorithm to implement the

Explanation:

it help you bro

Answered by shubhojeetbanerjee47
10

Answer:

Start

Read the size n

If N is negative or zero print "Invalid Size"

Declare the array of the given size n

Create two array evenArr[] and oddArr[]

traverse the array and put all even-placed elements in evenArr[] and odd placed elements in oddArr[]

Then we sort evenArr[] in ascending and oddArr[] in descending order.

Finally, copy evenArr[] and oddArr[] to get the required result.

Print the array

End

Explanation:

Similar questions