Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

[Bitonic Sort] what is rotation ? and is there any formal algorithm for it ? #65

Closed
thaodod opened this issue Jun 7, 2019 · 9 comments

Comments

@thaodod
Copy link

thaodod commented Jun 7, 2019

I don't understand the definition of rotation in the lecture. Also is there any formal algorithm for bitonic merge func ? (like the formal in odd-even merge). Any one can help ? Thank in advance my savior

@CauchyComplete
Copy link

  1. S' is said to be a rotation of S if there exists an integer k such that S'[i+k]==S[i] for all i. Note that I'm denoting S[i+2n]==S[i] where S has length of 2n.

  2. pseudocode for bitonic merge
    def bitonicMerge(comparision operator <, sequence X) :
    if |X| == 1 then return X
    A = xchgL(X)
    B = xchgR(X)
    A' = bitonicMerge(<,A) # recursion
    B' = bitonicMerge(<,B) # recursion
    X' = A' ++ B' # concatenation
    return X'

@thaodod
Copy link
Author

thaodod commented Jun 7, 2019

@CauchyComplete I think it should be for each i, there is one k for each i, right ? e.g. for: i=1 k could be 5, i=2 k could be another number.
right ? not all i in S using the same k ?

@HaritzPuerto
Copy link

HaritzPuerto commented Jun 8, 2019

@doduythao Maybe an example would clarify it. As I understood from the class, given this sequence <1,2,3,4> a rotation would be <2,3,4,1> and of course there are more rotations like <3,4,1,2>
Hope it helps, and please, let me know if I am wrong :)

@LLJE
Copy link

LLJE commented Jun 8, 2019

image

@CauchyComplete I followed your pseudocode, but I got wrong result.
Did I follow wrong way?

@ppnchb
Copy link

ppnchb commented Jun 8, 2019

@LLJE Bitonic merge needs bitonic sequence as an input, and outputs a sorted sequence

@LLJE
Copy link

LLJE commented Jun 8, 2019

@ppnchb Ah, I see. I confused it with bitonic sort. Thanks.

@CauchyComplete
Copy link

@doduythao It's one k all i, not k_i for each i.

@jeehoonkang
Copy link
Member

@doduythao I believe the discussion here answers your question, right?

@thaodod
Copy link
Author

thaodod commented Jun 9, 2019

Thanks. I know got the "Note that I'm denoting S[i+2n]==S[i] where S has length of 2n."

@thaodod thaodod closed this as completed Jun 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants