What is O(1) space complexity? -
i having hard time understanding o(1) space complexity. understand means space required algorithm not grow input or size of data on using algorithm. mean?
if use algorithm on linked list 1->2->3->4, traverse list reach "3" declare temporary pointer. , traverse list until reach 3. mean still have o(1) space? or mean different. sorry if not make sense @ all. bit confused.
to answer question, if have temporary pointer , traverse list counted o(1) space complexity. if have 10 or 100 or 1000 temporary pointers space complexity o(1). but, if wanna have 'n' pointers, , if 'n' small 1, space complexity o(n).
hope understand, o(1) denotes constant (10, 100 , 1000 constant) space , not vary depending on input size (say n).
Comments
Post a Comment