?O(1) או O(n) ?Polynomialב __init_ מה הסיבוכיות זמן של הפעולה
__init__ gets a list of size n, and has to read it.
Therefore it cannot run in O(1), and indeed runs in O(n).
Actually, if you are interested in the complexity of the following method:
def __init__(self, coeffs_lst): self.coeffs = coeffs_lst
Then it is O(1)!
I'm afraid that Mr. Rubinstein was mistaken again (as in all our arguments) :-)
The reason is that given a list coeffs_lst, we only define a field (a data member) self.coeffs which points to the same location in memory to which coeffs_lst points.
Mrs. Kleinbort is obviously right in this particular instance, and I humbly admit my mistake.
I resent the insinuation made by her though, as if it is the usual case in our arguments.
Well, you will all be the judges for that in HW5 question 6 section gimel…