ia have meet following problem
suppose we have sorted array of size 2^k-1 where k is given number we should copy this array into heapsearch array b the elements in odd positions of a go in order into last half of the positions of b positions congruent to 2 modul0 4 go into b's secodn quarter and so on this is not homework and please nobody tag it as homework it is from programming pearls please any ideas
views:
35answers:
1
A:
After Googling the actual task (you should provide a clearer description though), this is my idea:
- loop from 0 to k-1, let's call this index
i
- loop from 0 to 2k-i-1, let's call this index
j
and move the element at position i+1+j*2i+1 to position 2i+1+j
I'm not saying this is a completely correct solution, but it should give you some hints on a implementation.
Pieter
2010-05-29 09:13:28