Data Structure

Knowledge on the the storing, retriving, and structuring of data is vital to software developers. This helps them to create cost effective applications that are easy to use and fast. Knowing about the data structure is just a small part. Practical usage is key factor. Don't just gather information. Try understanding them, the reason why things are the way they are. This also helps in retaining the knowledge for longer periods of time.

@Stack

The best example of a stack is the "Tower of Hanoi" Remember this? In this, a ring be removed only if the ones above it are removed. Also, new rings can only be added on top of the existing ones. No ring can be added to the middle or removed in random. Tower of Hanoi image

Stacks are exactly like this. In technical terms, it is called LIFO which means Last-In-First-Out The element placed last will be removed first. If you insert or add to the stack, you "push" it into the stack. If you remove an element from the stack, you "pop" it out. The same point is used for entry and exit.

Most common application of stack is during recursion and function calls

@Queue

Unlike stacks, queue has 2 contol points. One for entry and one for exit. Take a road for an example. On one side of the road you can only move in one direction. If you don't want to go in this direction, you have to wait for a turning point. Key point, you are stuck in traffic and the road is blocked, so you can't cut in front. You have to wait for the person befor you to move. This is called "Linear Queue". At the turning point, if you take a u-turn and go back to where you came from, you are going in a circle. This type of queue is called "Circular Queue". queue
road If you are in a hurry to reach somewhere. Reaching that place is your priority so you go faster. "Priority Queues" in data structures has the same role. If something is important, put a priority on it and that task will be finished earlier.

Technically, this is called FIFO - First In First Out/ First Come First Serve. You book your movie ticket first, you get the seats first. When you insert an element to the queue it is called "enqueue" and when a element is removed it is called "dequeue"

Queues are used when something does not have to done immediately except for priority items. Some of the examples include mailing services, buffers, and scheduling.