big O of queue

could anyone tell me how do i compute the big "O" of quene as referenne-based implementation?

publicvoid enquene(obeject newItem)

{

Node newNode =new Node(newItem);

//insert the neew node

if (isEmpty( ))

{

newNode.setNext(nextNode);

}

else

{

newNode.setNext(lastNode.getNext());

lastNode.setNext(nextNode);

}

}

and is it O(1) for the index-based implementation of queue?

publicvoid enquene(Object newItem)

{

if (!isFull())

{

back = (back+1)%(MAX_QUEUE);

item[back] = newItem;

++count;

}

}

Message was edited by:

Ivan1238

[1243 byte] By [Ivan1238a] at [2007-11-27 9:22:03]
# 1
You don't compute it, you analyze it based on the number of steps in the algorithm as against the number of items being dealt with, in this case the total number of items in the queue. If you studied your algorithmic complexity topic attentively your question is trivial.
ejpa at 2007-7-12 22:16:18 > top of Java-index,Java Essentials,Java Programming...