In Stack (LIFO) situation: If I use the command peek() in linked-list, the complexity is 0(n). Why is it so since I only read the last object of the list? Should it be 0(1)? In Queue (FIFO): If I use peek() in linked-list, the complexity is now 0(1). Why is there a difference?
Thanks for spending time for reading and helping.