Data Structures are structures that are used to store /
organize data and provide a way to operate on data that is contained within
them.
Why are Data Structures so important?
- When the code base itself is small and the data on which it
operates is small there isn't much of a difference but when it comes down to
huge amounts of data the difference between using the right data structure
(read best suited) and a not so suited
one can be substantial.
Take the example of a binary tree and a hash set to be used
for searching –
Searching for a particular number in a binary tree has an
average time complexity of O (log n) while the worst case is O (n).
As opposed to this, a hash set, will have an average case time
complexity of O (1) meaning that each element can be accessed in constant time.
As can be seen from
the time complexities, the time taken to search for an element will increase with
increase in the amount of data with the array. In case of a hash set, this time
complexity will not change due to the way a hash set is implemented.
Data Structures can be further sub divided as shown in the diagram -
Data Structures - Primary classification. |
Examples of Data Structures include and are not limited to –
HashTables, HashMap, Array, LinkedList, ArrayList, Binary Tree, Trie etc.
Different types of data structures are suited to different
needs.
- Array – When random access of elements is of essence.
- LinkedList – When growth of the memory space with minimum complexity for addition at the beginning or the end is required.
- HashTable – When constant search time is required.
- Priority Queues – Scheduling
- Heaps – For dynamic memory allocations
- Graph – Essential to store connected data, like with Social Networks.
Hello Ashwin,
ReplyDeleteI find your definition of data structures to be concise and easy to understand. You did a great job explaining some of the data structures in terms of how long it takes to search for an item. I liked how you made a list of which data structures are suited best for specific needs. The image you provided is very helpful and can provide a visual learning experience for those that are learning or will learn data structures. You did a great job writing this blog.
Hi Ashwin, I enjoyed reading your post. Your post is well written and informative. I found easy to understand data structures definition and why data structures are important. Your question and answer format is interesting. You have explained the basics of data structure very well. The data structure diagram is very helpful for visual learner. But I feel providing an additional information link will be more helpful for reader.
ReplyDeleteHi Farjahan,
DeleteI thank you for commenting. All of this information isn't from a single source, it's information that I have been collecting as I study and work and hence a single link to understand all of this probably cannot be found.If there are some specific areas that you are looking to gain information in, please feel free to let me know. I would be more than happy to help you out.
For starters here is a great resource on Linked Lists - http://cslibrary.stanford.edu/103/
Hi Ashwin,
ReplyDeleteI like the way you explained the importance of choosing the right data structure based on running time. You also provided a list of data structures and the situation in which to use them, which is very helpful. You said that Linked list can be used when you want to grow memory space with minimum complexity and to add elements at the beginning or end of list. But in a linked list, you can also add elements in the middle of the list (I mean, anywhere in the list.) Overall it is well composed and informative post.
Hi Usha,
ReplyDeleteI appreciate you commenting. Allow me to clear any confusion. I am well aware that one can add elements anywhere in the middle of a linked list. I was explaining how and under what circumstances which data structure is most beneficial. As we know adding a node anywhere except the head and the tail increases the complexity by a lot. Hence the words " minimum complexity for addition" .