0

# Big O

I still have so much confusion when it comes to Big O notation. I know its very simple but still struggle with picking them out. But, my question is. What's the Big O notation for this formula? I feel that its O(n) but I'm unsure. public void enqueue(T element) { if(size() == queue.length) expandCapacity(); queue[rear] = element; rear = (rear+1) % queue.length; numElements++; }

1 Answer

0

Pretty much everything in that method is O(1) besides probably expandCapacity().
Therefore the whole method will obtain the O( ) of whatever the O( ) of expandCapacity() is. That *should* be O(n) but depends on implementation after all.