If you’re a CS major, I am sure you have come across a data
structure. You may have worked with
arrays, linked lists, graphs, or trees.
These are all ways of storing and organizing data for efficient usage. There
is no “best” data structure and are used depending on the task at hand; all data structures have pros/cons. The question is HOW are these structures used
in the real world? Let’s take a look at a few common ones:
1) Linked List
1) Linked List
An example on how a linked list may be used in the real world is managing a train. These trains are linked together in a calculated way so that items can be loaded, transferred, unloaded, and picked up efficiently. Like a linked list, trains can be added or removed at any point of the train. Also, the train at the end can be removed easier than the train in the middle. Therefore, one may use a linked list in order to plan the order of the trains, and the contents of the trains.
2) Binary Search Trees
Binary Search Trees are often used for data that is constantly added or removed, such as a map or set of objects. For example, any language library (C++, Java, .Net, etc) uses binary search to find items; items are inserted in order, and items can be easily accessed.
3) Hash Tables
Internet Routers use Hash Tables; a router table may contain millions of entries. Therefore, the router must determine the best route by querying the router table when the packet is routed to a specific IP address. In this case, the key is the IP address and the value is the address.
Knowing when to implement these data structures is important because some are more efficient, depending on the task!
No comments:
Post a Comment