Tuesday, October 29, 2013

Data Structures: Smart and Accessible

Trees, Lists, and Maps for Great Justice!


As a Computer Scientist, data structures are a daily meal. I won't get back into lunch time metaphors while detailing what they mean to me, but I will see about preparing some food for thought. We use data structures to organize and store data in formats that we can easily access, modify, set, and retrieve. The first thoughts that should go into deciding on whether to use an array, linked-list, queue, or hashmap should be on how the data is to be used. For LIFO/FIFO configurations, a simple stack or queue may suffice as they model similar concepts in real life situations. (FIFO is last in, first out, similar to a line at a bank, while LIFO models something closer to a stack of something where you remove the last one that was 'stacked.') Arrays and lists are great for accessing data in a linear manner, or by specifically calling particular items by their respective places. Trees and hashmaps are great for storing data that needs to be organized as it is added, while linked lists and array lists are great for expanding dynamically to fit large amounts of data. The data structure used can make or break the efficiency of the program, so it's best to take a close look at what structures are used in order to have an efficient running program that is easy to work with.


Some things to look at when trying to determine what to use:

  • size of the data (how many elements?)
  • does the data change?
  • does the list need to be in a particular order (sorted)
  • if so, are the elements added already partially, completely or un-sorted
  • how is the data meant to be accessed? (Linear iteration, specific element by place, groups of elements, etc...
As I've lightly touched on, deciding on a data structure is not always easy. As with all software development, pro-active time and effort spent in design is both necessary and well spent.

Bonus! More Snazz on Data Structures.(CLICK ME!)


No comments:

Post a Comment