On Oct 13, 10:52 am, "sharad kumar" <[EMAIL PROTECTED]> wrote:
> its possible
> take gn array.
> find median
> then split arraay in two halves
> split it till it becomes smallest no.
> then exchange each even no with odd and merge them.= till u get original 
> array.
> almost the reverse form of merge sort
>

Why get so complex?
You have essentially two sorted arrays waiting for a final merge.

max <- size(input)
even <- 0
odd  <- 1
i <- 0
result <- makearray(max)
while i < max
   ;; four cases
   if(even >= max) ;; even is done
   {
       result[i] <- input[odd]
       odd <- odd+ 2
   }
   else if(odd >= max) ;; odd is done
   {
       result[i] <- input[even]
       even <- even + 2
   }
   else if(input[odd]>input[even]) ;; even is smaller
   {
      result[i] <- input[even]
      even <- even + 2
   }
   else ;; take the odd
   {
      result[i] <- input[odd]
      odd <- odd + 2
   }
   i <- i+1
end while

---
Geoff


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to