–tags: Data Structures
Stacks, lists, Queues
- Add something to the top is a stack
- Last in is the first out
- push and pop to the data: .push - add data .pop is return the data at top and remove
- .peek to look into the top data without removing it
- no need to reshuffle or add or insert or anything
- dynamic arrays with just push and pop is actually a stack implementation of an array
Abstract data types:
- Much more reusable
- Continuous memory
- Stack can be made using different way using array or a linked list or something else
- Java has a stack class
- Stack is also an abstract data type or a concrete class too as seen in Java
Queues:
- First in First out
- Printer has a queue to print the data
- Used in multithreading as well
- Queue class available in Csharp
- AN interface in java: linked list can act like a java
- put and get in queue in python
- Queues are mostly used for synchronizing the communication between threads
- push back and pop_front methods in std::queue C++
Priority Queues:
- Higher priority comes to the top to be removed
- Priority can be maintained by comparison
- DEQUE:
- Double ended queue: stack and queue at the same time