Does algorithm time complexity O(5) considered as O(1)? [duplicate]

I have someone homework to make and in the instructions it says that we need to implement a function in O(1).

Now, does it mean that I can make my function in O(5) or O(2) or whatever?


Yes, O(5) is the same thing as O(1). If you’ve been asked to implement a function in O(1) time, it means it needs to run in the same amount of time no matter how large the data being provided to it is.

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *