7. [-/1 Points] DETAILS HUNTERDM4 6.5.003. Assume that Algorithm 6.3 returns a set of nt distinct n-tuples. Compute (in
Posted: Fri May 06, 2022 6:47 am
7. [-/1 Points] DETAILS HUNTERDM4 6.5.003. Assume that Algorithm 6.3 returns a set of nt distinct n-tuples. Compute (in terms of n> 1) the number of union (U) operations that Algorithm 6.3 performs. (Note that Algorithm 6.3 uses Algorithm 6.4) eBook
Algorithm 6.3 Make a list of all permutations of (0,1,2,...,n-1). Preconditions: n E N. Postconditions: Returns the set S, of all permutations of (0,1,2,...,n-1), listed as ordered n-tuples. function ListPerms (n € N) if n 1 then = return {(0)} else Sn 0 X ListPerms (n-1) for (Po.P P-2) EX do Sn - -S, U InsertEverywhere (n-1, (Po.P Pu-2)) L return S Algorithm 6.4 Make a list of permutations by inserting a new symbol.
Algorithm 6.3 Make a list of all permutations of (0,1,2,...,n-1). Preconditions: n E N. Postconditions: Returns the set S, of all permutations of (0,1,2,...,n-1), listed as ordered n-tuples. function ListPerms (n € N) if n 1 then = return {(0)} else Sn 0 X ListPerms (n-1) for (Po.P P-2) EX do Sn - -S, U InsertEverywhere (n-1, (Po.P Pu-2)) L return S Algorithm 6.4 Make a list of permutations by inserting a new symbol.