In a circular linked list, if an elements needs to be inserted at front [just before the node pointed by head], can be done in O(1) (see the answer here)
But in a book currently, I have, it is mentioned that it is done in O(n) (the usual method). I also saw few lecture ppts, they all mention the usual method of traversing the list & adding an element.
My question is :
In practical scenarios which method is used ?
I am about to attend an exam, which consists of MCQs, if above question is asked shall I mark O(n), since that is the standard answer ?
I am about to attend an exam, which consists of MCQs, if above question is asked shall I mark O(n), since that is the standard answer ?
Ask the lecturer, or choose O(1) and send an email to him after exam. $\endgroup$