algorithm - How to decide the sign of the permutation between two ordered set? -


Suppose A and B are two arrays of the same size and each without repetitive members. Is there any efficient algorithm that

1. decides that there are only one members in A and B

2. If the answer to 1 is true, then the determining the order of the conversion Which brings A

You can convert A in B by using an extent table Are:

  pos = hash table (value -> position) b perm = [] for an A: if there is no position: return "not the same!" This part takes O (n) time required.  

Now you have to get a signal of ordering.

You have at least two options:

  • It's definitely possible in O (n log n) or better
  • it's only linear It takes time

    Actually you can use cycle decomposition directly on your input arrays, which will give a nice and small implementation.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -