Every arc diagram ((io, jo), increasing order, i.e., io < i (in-1. Jn-1)) of n arcs on 2n points (0, 1,..., 2n-1) has n starting points it, which we will assume to be sorted in < ... < İn−1 · For a general arc diagram, the end points j must satisfy i

Advanced Engineering Mathematics
10th Edition
ISBN:9780470458365
Author:Erwin Kreyszig
Publisher:Erwin Kreyszig
Chapter2: Second-order Linear Odes
Section: Chapter Questions
Problem 1RQ
icon
Related questions
Question
Every arc diagram ((io, jo),
increasing order, i.e., io < i
(in-1. Jn-1)) of n arcs on 2n points (0, 1,..., 2n-1) has n starting points it, which we will assume to be sorted in
< ... < İn−1 ·
For a general arc diagram, the end points j must satisfy i<jk, but otherwise can be chosen freely. Therefore, a brute-force way of finding all arc diagrams
on arcs is to consider all (2") combinations of starting points, and for each of these combinations to consider all »! permutations of the corresponding end
points. If all starting and ending points satisfy i <jk then this results in an arc diagram.
Use this method to write a function find_all_arc_diagrams that takes an integer n and returns a list of all arc diagrams on n arcs.
Test your code by printing out a list of all arc diagrams for n = 3 and by verifying that the total number of obtained diagrams is (2n- 1)!! for a couple of
(small) values of n.
You might find it helpful to loop through permutations of a list using itertools.permutation (imported above) by adopting code similar to
perms-permutations (list_of_items)
for p in perms:
and similarly for combinations using itertools.combination (imported above).
Transcribed Image Text:Every arc diagram ((io, jo), increasing order, i.e., io < i (in-1. Jn-1)) of n arcs on 2n points (0, 1,..., 2n-1) has n starting points it, which we will assume to be sorted in < ... < İn−1 · For a general arc diagram, the end points j must satisfy i<jk, but otherwise can be chosen freely. Therefore, a brute-force way of finding all arc diagrams on arcs is to consider all (2") combinations of starting points, and for each of these combinations to consider all »! permutations of the corresponding end points. If all starting and ending points satisfy i <jk then this results in an arc diagram. Use this method to write a function find_all_arc_diagrams that takes an integer n and returns a list of all arc diagrams on n arcs. Test your code by printing out a list of all arc diagrams for n = 3 and by verifying that the total number of obtained diagrams is (2n- 1)!! for a couple of (small) values of n. You might find it helpful to loop through permutations of a list using itertools.permutation (imported above) by adopting code similar to perms-permutations (list_of_items) for p in perms: and similarly for combinations using itertools.combination (imported above).
You must not import any other modules.
#DO NOT CHANGE THE CONTENT OF THIS CODE BOX
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.patches as patches
from timeit import timeit
import seaborn as sns
from itertools import permutations, combinations
Transcribed Image Text:You must not import any other modules. #DO NOT CHANGE THE CONTENT OF THIS CODE BOX import matplotlib.pyplot as plt import numpy as np import matplotlib.patches as patches from timeit import timeit import seaborn as sns from itertools import permutations, combinations
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
Advanced Engineering Mathematics
Advanced Engineering Mathematics
Advanced Math
ISBN:
9780470458365
Author:
Erwin Kreyszig
Publisher:
Wiley, John & Sons, Incorporated
Numerical Methods for Engineers
Numerical Methods for Engineers
Advanced Math
ISBN:
9780073397924
Author:
Steven C. Chapra Dr., Raymond P. Canale
Publisher:
McGraw-Hill Education
Introductory Mathematics for Engineering Applicat…
Introductory Mathematics for Engineering Applicat…
Advanced Math
ISBN:
9781118141809
Author:
Nathan Klingbeil
Publisher:
WILEY
Mathematics For Machine Technology
Mathematics For Machine Technology
Advanced Math
ISBN:
9781337798310
Author:
Peterson, John.
Publisher:
Cengage Learning,
Basic Technical Mathematics
Basic Technical Mathematics
Advanced Math
ISBN:
9780134437705
Author:
Washington
Publisher:
PEARSON
Topology
Topology
Advanced Math
ISBN:
9780134689517
Author:
Munkres, James R.
Publisher:
Pearson,