Thursday, October 31, 2013

Data Structures and Algorithms, what they do.

Data structures and Algorithms are an interesting subject. Data structures and the understanding of implementing and when to implement particular data structures are what allow for complex programs and applications to be created. Choosing a data structure for an algorithm/program effects everything from memory allocation, run time, search time, insertion time, and code re-usability. Typically the ideas behind build reusable blocks of code isn't hard, however when choosing data structures it can often make it rather difficult. Have your program work based off of user defined types can drastically change your code and often make it longer and harder to program.

Data structures are exactly what it sounds like. They are structures for holding data. Most data structures are represented with either a cell(http://3.bp.blogspot.com/-o0HXsxh1O-s/TzUzB7a0wlI/AAAAAAAAAZ0/OC03E2t_mBM/s1600/selection_sort_00.gif, example) or with circles often refereed to as nodes. (http://blog.cogswell.edu/wp-content/uploads/2011/04/binarysearch.gif). These structures drastically effect the performance. For example, choosing the wrong data structure in an search algorithm can often change the search time of n from nlogn to n^2. However, space can often just as important if not more important than speed.

A few common data structures are Linked Lists(The most common being Single linked List, double, and circular), Tree's(Binary Tree's, B-Tree's, Red-Black Tree's, 2-3 Tree's), Array's, Hash Tables, and Stacks.

Algorithms are logic that provides some change of state using data structures. Algorithms are generally designed being system and language independent and then are implemented to fit specification. The final result can often look very different then the initial rough draft.


Suggested Reading:
http://en.wikipedia.org/wiki/Linked_list
http://en.wikipedia.org/wiki/List_of_data_structures

3 comments:

  1. Kevin,
    Kudos on your blog post. The post is very casual yet easy and informative. it gave me an overall idea of data structures and how they function. The blog transitions really well and it easy on the eyes and the mind. Th eonly thing i would advise is to use 'Example' as a link and emit using a lengthy URL in your blog.
    Good Job and happy blogging!

    - Tushar

    ReplyDelete
  2. Hi Kevin!

    I like the image you linked with Prim's algorithm; it's a good rundown of how the algorithm is run. I'd suggest moving it to the section that talks about algorithms, though, and adding a caption.

    Also, since this is a massive pet peeve, the plural of "tree" is "trees," not "tree's." There's no data structure called a "binary tree is"...

    Besides that, though, you do a good job of outlining the importance of choosing the right data structure. Is there really a structure that takes O(n^2) to search? I thought the worst a data structure could do was O(n). That's terrible.

    ReplyDelete
  3. Hey Kevin,

    Nice breakdown of data structures and algorithms (and the importance of choosing the right one). I like the diagrams you used to give a visual representation. It’d be a lot cleaner if you made those links hyper-links, instead of multi-line URLs. I like that you mention code-reusability, as I usually don’t think about that when choosing a data structure. I enjoyed reading and working through the diagrams, keep it up!

    ReplyDelete