currently I have best case as o(n), worst case as o(n). I am unsure if this is correct for the following code segment and I would really appreciate if someone could confirm