combinationGraphDataGen.py (710B)
1 import math 2 3 nVals = [100, 200, 300, 400, 500] 4 rVals = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 5 6 results = [] 7 8 for r in rVals: 9 results.append([]) 10 for n in nVals: 11 # With m = r, math.comb(m, r) = math.comb(r, r) = 1. 12 # Therefore, the complexity is: 13 # math.comb(n, r) * (r^3 + r * n) 14 result = math.comb(n, r) * (r**3 + r*n) 15 results[-1].append(str(result)) 16 17 for res in rVals: 18 if res == 0: 19 continue # Skip r = 0 since it gives 0 instructions. 20 print(str(res) + " & ", end="") 21 itr = 1 22 for r_val in results[res]: 23 if itr == len(nVals): 24 print(r_val + " \\\\") 25 else: 26 print(r_val + " &", end=" ") 27 itr += 1 28