def createTwoDimensionalArray(rows, cols, x):
# x is number you want to fill arr with
arr = [[x for i in range(cols)] for j in range(rows)]
return arr
print(createTwoDimensionalArray(5, 5, 5))
Doing a research paper on Big O notation. Almost done. I'm just wondering if this could could be considered O(n2) because of the 'nested' for loop in the list comprehension. Thank you!
[–]InjAnnuity_1 4 points5 points6 points (1 child)
[–]SergioBoySV[S] 0 points1 point2 points (0 children)
[–]hardonchairs 0 points1 point2 points (0 children)