GeeksforGeeks » Miscellaneous

time complexities in Queue

(2 posts)

Tags:

  1. lavi
    guest
    Posted 1 year ago #

    What are the time complexities following operations in Queue. Consider Linked List representation
    1) insert()
    2) remove()
    3) search()

    What are the complexities for Stack?

  2. kartik
    Moderator
    Posted 1 year ago #

    Following are the time complexities, assuming that you have both pointers front and rear in the Linked List implementation.
    1) insert(): O(1)
    2) remove(): O(1)
    3) search(): O(n)

    Following are the time complexities for stack, assuming that you have only one pointer top.
    1) insert(): O(1)
    2) remove(): O(1)
    3) search(): O(n)


Reply

You must log in to post.

RSS feed for this topic