Math, asked by sumy55, 11 months ago

Even numbers at even index and odd numbers at odd index excel

Answers

Answered by kartikkalra
3

\fcolorbox{blue}{aqua}{Hey Mate Here Is Your Answer}

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

\bold{\huge{\fbox{\color{Maroon}{Hope It Helps You}}}}

Answered by Anonymous
0

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