Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Suppose there is an array of numbers
{s 1 ,s 2 ,....,s n ,,......,t 1 ,t 2 ,....,t n }
you have to implement the code in C such that you will get the result
{s 1 , t 1 , s 2 , t 2 , ...., s n , t n }
using divide and conquer concept.

Example: INPUT- {1,2,3,4,5,6}
OUTPUT-{1,4,2,5,3,6}

What I have tried:

i have googled about this and about dividing into odd and even entries of an array using divide and conquer ....Got nothing...!
Posted
Updated 23-Mar-18 4:14am
Comments
Patrice T 23-Mar-18 11:26am    
Show your code, even if partial and explain where you are stuck
Richard Deeming 23-Mar-18 12:44pm    
"you have to implement the code in C ..."

The key word in that homework assignment being YOU.

YOU have to implement the code. Not some random strangers on the internet.

If you don't know where to start, then talk to your teacher.

1 solution

The assignment is not "about dividing into odd and even entries".

Compare the input and output definitions (not the numerical examples) to find out which algorithm is used:
The first element of the output array is the first element of the input array (s1).
The second element of the output array is the ??? element of the input array (t1).

Then read about Divide and conquer algorithm - Wikipedia[^].

Then you might recognise that the sentence
Quote:
... every algorithm that uses recursion or loops could be regarded as a "divide and conquer algorithm".
might apply here.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900