Computer Science, asked by dsprn12345, 10 months ago

You are given an array A of size N. Your task is to divide the elements into two parts such that the first N/2 elements are strictly increasing and next N/2 elements are non-decreasing

Answers

Answered by sohailabbas
0

Answer:

Answer:  

This is very simple task we can divide the element by following.

Explanation:

You can perform this task in any of the computer program. You have just follow the steps and make a formula for this task. The formula will auto generate the two portions of the the array.

Answered by apocritia
0

Answer:

The method is explained in the explanation part.

Explanation:

The required task is to divide the elements into two parts such that the first N/2 elements are strictly increasing and the next N/2 elements are strictly non decreasing out of N elements in an Array.

It can be done as follows-

1) Take two arrays of size N/2 namely A1 and A2.

2) Store the first element in A1 and second element in A2 and so on, in other words say store the odd index elements in A1 and even index elements in A2.

3) So the half of elements will be in A1, sort them in ascending order. It will be strictly increasing.

4) Similarly half of the elements will be in A2, sort them in descending order. It will be strictly decreasing.

Similar questions