All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Sign of a Permutation (Posted on 2006-08-05)
A permutation p1,p2,...,pn of 1,2,...,n is even (resp. odd) if it can be returned to the original order 1,2,...,n using an even (resp. odd) number of interchanges of pairs of elements. It is known that every permutation is either even or odd (and therefore not both).

The sign, or signum (for those who want to be fancy), of a permutation is +1 for an even permutation and -1 for an odd permutation.

You are given the integer n and the array p initialized to the integer values p[1]=p1, p[2]=p2, ..., p[n]=pn which are guaranteed to be a permutation of 1,2,...,n. What algorithm would you advocate for determining the sign of the permutation? You need not preserve the original contents of p.

 See The Solution Submitted by Richard Rating: 3.2000 (5 votes)

 Subject Author Date re(2): What I would NOT advocate Richard 2006-08-07 16:31:55 re: What I would NOT advocate Old Original Oskar! 2006-08-07 15:43:59 re(3): No Subject Richard 2006-08-07 14:14:05 re(2): No Subject Charlie 2006-08-07 13:10:13 re: No Subject Richard 2006-08-07 12:57:18 No Subject And Or 2006-08-07 10:46:16 What I would NOT advocate Richard 2006-08-05 23:05:50 Simple Federico Kereki 2006-08-05 19:09:26 re: Solution Charlie 2006-08-05 17:24:50 Solution Bractals 2006-08-05 16:14:10 Trivially? Old Original Oskar! 2006-08-05 15:54:15

 Search: Search body:
Forums (0)