Time complexity of a Stack ADT implemented using a Linked List?

You don't have to insert at the end of the list. If you insert at the front of a (singly-linked) list, they are both O(1).

You don't have to insert at the end of the list. If you insert at the front of a (singly-linked) list, they are both O(1). Stack contains 1,2,3: 1->2->3 Push 5: 5->1->2->3 Pop: 1->2->3, returning 5.

For a doubly linked list the stack operations push and pop should both be O(1). If you are stuck with a singly linked list, assuming you are ok with the constant overhead of keeping a pointer to the tail as well as the head, you can have O(1) queue operations of enqueue and dequeue. And because with amortized constant overhead you can make a stack out of two queues, in the end, you can achieve O(1) push and pop.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions