I know how the push() and pop() methods in a typical implementation of a Queue/Linked List work but what I do want to know is what you actually define as a push or a pop? When can you name a method push()/pop()? What makes the insert()/add() method in a typical Tree implementation not a push()?
My understanding is that push()ing means putting something to a position some special pointer is pointing to, and pop()ping an element means putting some object away some pointer is pointing to, but it doesn’t seem to be clearly defined. Or does the naming matter at all?
When referring to operations on a linked list, you can push items on to the list to add them. You can then pop items off of a list to remove them.
If you pop items from the same end of the list that you add them, you have implemented a stack, or a Last-In-First-Out (LIFO) data structure:
If you pop items from the opposite end, then you have implemented a queue – although usually the terminology is “enqueue” and “dequeue”. This is a First-In-First-Out (FIFO) data structure: