hey,programming expert here sa java...do u have any knowledge about this enqueue,dequeue,pop,push...do u have any example?
hey,programming expert here sa java...do u have any knowledge about this enqueue,dequeue,pop,push...do u have any example?
don't know about java but i bet those are methods for storing and retrieving data from special data objects. push/pop is traditionally used with a stack.
ang enqueue and dequeue kai gamit sa queue sad ^^
Data Structures & Algorithms - Stacks & Queues
enqueue,dequeue,pop,push are just basically insertion and deletion of an object from an ordered list
push(insert) and pop(delete) - used for a STACK wherein it follows the algo of Last In First Out(LIFO) which means that the Last item that was push(inserted) will be the first item deleted when you pop
enqueue(insert) and dequeue(delete) - used for a QUEUE wherein it follows the algo of First In First Out(FIFO) which means that the first item that was enqueue(inserted) will be the first item deleted when you dequeue
hope that helps.![]()
Sample
FOR STACK :
push(9);
push(2);
push(5);
push(10);
//print the stack (10, 5, 2, 9)
pop();
//print the stack (5, 2, 9)
--> Last In First Out (LAST IN(push) was 10 so when pop was called 10 was FIRST OUT)
FOR QUEUE:
enqueue(9);
enqueue(2);
enqueue(5);
enqueue(10);
//print the queue(10, 5, 2, 9)
dequeue();
//print the queue(10, 5, 2)
--> First In First Out (FIRST IN(enqueue) was 9 so when dequeue was called 9 was FIRST OUT)
Similar Threads |
|