Question: Write a program that takes as input a sorted array of numbers. The objective is to return the array arranged in an alternate order

Write a program that takes as input a sorted array of numbers. The objective is to return the array arranged

Write a program that takes as input a sorted array of numbers. The objective is to return the array arranged in an alternate order such that max value is followed by min value in a descending fashion, so that the 1st element is the max value, 2nd element is the min value, 3rd element is the second max value, 4th element is the second min value & so on. Example: For an input array [2, 4, 6, 8, 101, the expected result would be [10, 2, 8, 4, 6] Note: The solution should modify the original array itself. Please respond back with the following: Description URL that contains the solution in programming language of your choice (recommended: Typescript or JavaScript) Time complexity (Big O notation) of your solution Space complexity (Big O notation) of your solution List all possible test cases Response

Step by Step Solution

3.38 Rating (145 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Program flow 1 Create two pointers one at the start of the array and one at the end of the array 2 I... View full answer

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 Programming Questions!