Write bash script which takes array as an input of size 10 bind its even indexes to accept even values and odd indexes to accept odd numbers only. Print invalid input if given input is not valid.
Answers
Answered by
1
Answer:
Even numbers at even index and odd numbers at odd index
Given an array of size n containing equal number of odd and even numbers. The problem is to arrange the numbers in such a way that all the even numbers get the even index and odd numbers get the odd index. Required auxiliary space is O(1).
Examples :
Input : arr[] = {3, 6, 12, 1, 5, 8}
Output : 6 3 12 1 8 5
Input : arr[] = {10, 9, 7, 18, 13, 19, 4, 20, 21, 14}
Output : 10 9 18 7 20 19 4 13 14 21
Similar questions
Political Science,
2 months ago
Math,
2 months ago
English,
5 months ago
Math,
5 months ago
Economy,
10 months ago