use recursion to generate random permutations

1 回表示 (過去 30 日間)
越琪 吴
越琪 吴 2020 年 10 月 13 日
コメント済み: 越琪 吴 2020 年 10 月 15 日
a) Write a recursive algorithm that takes as input a set of elements and an integer l, and returns all their permutations of length l.
b) Adjust the previous algorithm to return a random subset of all the permutations containing n elements.
Hint: generating all the permutations and selecting n of them afterwards in not a good idea.
a) and b) are two codes.I really don't know how to write the code. Any help will be appreciated! Thanks a lot!

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 10 月 13 日

カテゴリ

Help Center および File ExchangeDiscrete Math についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by