ARRAYS
A parking lot is an example of an array with each index of the array storing whether a car is present or not. Or it may be used for some other functionality.
Phone contacts stored in a sorted array
Details of all the employees in a company stored in a database and fetched through an array
Linear searching or binary search some paper from a collection(array) kept in some order
No of units of each item currently available in a shopping mall stored in an array
Chess is a 2D array of 8*8
Rubix cube is an example of 3d array
Seats in a lecture hall is an example of a 2d array
Collection of all music songs in your phone stored in an array
Details of all the books available in a library stored in an array
Bank locker
Egg cartons
Marks of each student in a class is stored in an array
To encode and decode data in encryption we need matrices (2d arrays). There is a key that helps encode and decode data which is generated by matrices
Construction of buildings can be done with matrices. A matrix is made of rows and columns you can change the number of rows and columns within a matrix. Matrices can help support various historical structures.
A 2D digital image is a collection of pixels stored in a 2d array.
LINKED LIST
Train is an example of a linked list as it is made up of a collection of railroad cars where each car is connected to the car in front of it.
A chain is an example of a linked list as it is connected in a linked list fashion. Each link is connected with the next one.
One funny example of linked list
Image viewer is also an example of a linked list as you can view the previous and next image respective to the current image
Previous and forward navigation in your browser is also implemented in a linked list
A music player in which we can only play the next song after current and not the previous one is an example of a singly linked list
A music player in which we can play both the previous as well as the next song is an example of a doubly linked list
A music player in which we can play songs in loop i.e after finishing the last song it automatically plays the first song is an example of a circular linked list
Undo redo operations are mostly implemented in a linked list
Keeping track of turns in a multiplayer board game is an example of a circular linked list. Put all the players in a circular linked list. After a player takes his turn, advance to the next player on the list.
Musical chair game is an example of a circular linked list in which chairs are connected in a circular link and after each iteration of the game, one chair (node) is removed from the list.
Planning a trip to some particular destination is an example of a linked list as you plan a series of directions where to go to after which place. Each step in the navigation sequence has a logical order and then points to the direction to take after the current step.
GPS Navigation: A linked list of map data. Traveling from origin to destination is an example of traversing through all nodes. Rerouting by a GPS is an example of Add and Remove operations of map data.
STACK
Stack is a LIFO (Last In First Out) data structure.
A pile of books is an example of a stack. The last book kept on the pile will be removed first i.e LAST IN FIRST OUT (LIFO) data structure
A pile of plates
Stack of chairs
Tower of Hanoi: Famous application of stack
Activities (Screens) in your Android app are arranged in a stack (the back stack) in the order in which each activity is opened. An email app might have one activity to show a list of new messages. When the user selects a message, a new activity opens to view that message which is added to the back stack. If the user presses the Back button, that new activity is finished and popped off the stack
Women bangles - Women wear a bangle one by one and to pull the first one they have to first pull out the last one.
Web browsers use the stack to keep track of the history of websites. If you click back then the previous site opens immediately.
Call logs in mobiles use the stack (in which the recent call is on the top)
When a company wants to reduce its workforce. Typically they follow "Last Hired First Fired"
Function call uses the stack
Matching of brackets by the compiler is also implemented using stack.
QUEUE
A Queue is a First In First Out (FIFO) data structure
Boarding a bus -
Passengers stand in a queue to board a bus. The person who first gets into the queue is the one who first gets on the bus. The new passengers can join the queue from the back whereas passengers get on the bus from the front.A ticket line
An escalator
Vehicles on a one way road
CPU Scheduling in operating systems - CPU Scheduling is the process of determining which process will own CPU for execution while another process is on hold. The CPU schedules processes available in the ready queue based on the scheduling algorithm used.
Call center phone system -
Call Center phone systems use Queues to hold people calling them in order until a service representative is freeAirplanes waiting for landing instructions -
The Queue is used for airplanes waiting for landing instructions.Packets queue in data communication in a computer network
Keyboard buffer -
The keys pressed are enqueued in the queue in the sequence in which it arrives. The operation is performed which key is pressed first i.e first in first outAny waiting line
Manufacturing items in a queue using the assembly line production technique in industries
You can see queue many places around you daily.
Bonus example
TREE
A tree
The nodes that give birth to other nodes under them is called a "parent node" and its children are simply called "daughter node" or "children nodes". The main stem of the tree is called the "root node".
Family The family of Mr. Alpha can be represented as a tree where Mr. Alpha has two children - Mr. Charlie and Mr. Romeo and similarly they both have two children.
A hierarchical company structure
An organism classification tree
A Tree Corresponding to the Markup Elements of a Web Page
Folder structure in an Operating system
An XML Tree structure
Decision-based algorithm used in machine learning
Database indexing - In database indexing, B trees are used to sort data for simplified searching, insertion, and deletion
DNS Servers - Domain Name Servers (DNS) also use tree structures.
Quora comments - Posting questions on quora, the comments are child of questions
Comments on Twitter - The comment to a tweet on Twitter is a child of that tweet and similarly, a reply to your comment is your child of that comment
Routing tables- A routing table is used to link routers in a network. It is usually implemented with a trie data structure. The tree data structure will store the location of routers based on their IP addresses. Routers with similar addresses are grouped under a single subtree.
Data compression using Huffman coding
GRAPH
Google maps navigation system
The navigation system is based on the algorithm to calculate the shortest path between two vertices.Social Graphs
Social graphs draw edges between you and the people, places, and things you interact with online.Facebook Friend Suggestion Algorithm
In Facebook, users are considered to be the vertices and if they are friends then there is an edge running between them. Facebook’s Friend suggestion algorithm uses graph theory. Facebook is an example of an undirected graph.World Wide Web
In World Wide Web, web pages are considered to be the vertices. There is an edge from page u to page v if there is a link of page v on page u. This is an example of a Directed graph.Resource Allocation Graph in Operating Systems
In Resource Allocation Graph each process and resources are considered to be vertices. Edges are drawn from resources to the allocated process, or from requesting process to the requested resource. If this leads to any formation of a cycle then a deadlock will occur.Google knowledge graph
A knowledge graph represents a network of real-world entities i.e. objects, events, situations, or concepts, and illustrates relationships between them. This information is usually stored in a graph database and visualized as a graph structure.GraphQL
GraphQL is operated on Graph data structures. API developers use GraphQL to create a schema to describe all the possible data that clients can query through that service.Route optimizations in flight networks
In flight networks, graph data structures are used to compute shortest paths and fuel usage in route planning. The vertices in flight networks are places of departure and destination, airports, aircraft, cargo weights.Computer Network
The relationships among interconnected computers within the network, follow the principles of graph theoryElectronic chip design
In electronic chip design, each component is considered as a vertex of the graph. A printed circuit board takes input in form of a graph where edges denote that there is a connection between pair of components. The head that creates this connection on the board then finds the optimal to move across the chip to get the desired resultant circuit.Molecular structure in chemistry
Graphs are used to model molecule structures for computer processing. Here atoms can be considered as vertices of a graph the bonds that connect them are represented as edges between them.Currency conversion
Getting the maximum profit by exchanging the currency of different countries is solved by using graph theoryBonus Image
This is the end of the blog.
If you liked this make sure to give a follow.