Rank: 4871 based on 2 downloads (last 30 days) and 2 files submitted
photo

Khaled Hamed

E-mail
Company/University
Sultan Qaboos University

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by Khaled View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
27 Nov 2006 RECPERMS (Recursive Permutations) Produce permutations of the integers from 1 to n recursively one at a time. Author: Khaled Hamed permutation single re... 1 1
  • 5.0
5.0 | 1 rating
21 Nov 2006 perms1 returns a single permutation of the numbers 1:n Author: Khaled Hamed perms permutation sin... 1 2
  • 5.0
5.0 | 1 rating
Comments and Ratings on Khaled's Files View all
Updated File Comment by Comments Rating
21 Oct 2007 RECPERMS (Recursive Permutations) Produce permutations of the integers from 1 to n recursively one at a time. Author: Khaled Hamed Moon, Domingo

This is what I want. Thanx.

23 Nov 2006 perms1 returns a single permutation of the numbers 1:n Author: Khaled Hamed Hamed, Khaled

I have submitted a new function 'recperms' which uses a similar logic, but calculates the permutations recursively, and thus no index is needed. The code is about 2.5 times faster than perms1 (still very slow compared to perms) and avoids the problem with large indices noted by John D'Errico. Thanks John.

21 Nov 2006 perms1 returns a single permutation of the numbers 1:n Author: Khaled Hamed D'Errico, John

Excellent. The author has included error checks, a description of the algorithm, many internal comments so one can understand how the code works. Each call is fast too.

Two things to beware (not the fault of the author) large values of n will still be a problem. For example,

perms1(20,2e18)

and

perms1(20,2e18+1)

will generate exactly the same result. This is an artifact of double precision in matlab. So you don't want to go above n=18 in perms1.

Secondly, perms1 does not generate its permutations in the same order as perms. I'd argue that the order chosen by perms1 is more logical than perms anyway.

Well done.

Top Tags Applied by Khaled
perms permutation single, permutation single recursive
Files Tagged by Khaled View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
27 Nov 2006 RECPERMS (Recursive Permutations) Produce permutations of the integers from 1 to n recursively one at a time. Author: Khaled Hamed permutation single re... 1 1
  • 5.0
5.0 | 1 rating
21 Nov 2006 perms1 returns a single permutation of the numbers 1:n Author: Khaled Hamed perms permutation sin... 1 2
  • 5.0
5.0 | 1 rating

Contact us at files@mathworks.com