in theoritical analysis of bubble sort, how can we assume that swap function is doing CONSTANT work… how?
Space time complexity
@deck123 swap function takes o(1) time only as you are just swapping elements. if you use normal swap using temp variable that also takes 0(1) time.
also space complexity is o(1) for swap function and if you use temp then also o(1)
dont forget to hit like and mark resolved if cleared
but i dont understand how you manage to conclude that?
@deck123 well if you cout<<var<<endl;
its space complexity is o(1) right
so swap also only swaps the value so o(1)