Data structures and algorithms

December 25th, 2009 by Kevin | No Comments | Filed in programming

A data structure is a method of organizing data so that it can be used in a more efficient manner. While we can build custom data structures as per our needs, some of the commonly used data structures are lists, stacks, heaps, trees, queues, hash tables, graphs and priority queues. Data structures compliment algorithms used in computer solutions. An algorithm is a sequence of procedures to be used for the solution of any problem (including computer problems). Data structures and algorithms are used together to create simple, elegant and efficient solutions to many problems which would have otherwise proven complex. The advantages of using data structures and algorithms are three fold as mentioned below:

1) Efficiency
Suppose we want to search a particular book in a list of several books in a library. We could use the normal method of placing the books in an array and checking each book in the array to see if it matches the one that we are searching. But this is a higly inefficient method of a search as the time for the search will be too high in most cases. But if we use a data structure like a hash table or a binary tree or the quick sort or heap sort algorithm, we can drastically reduce the time for the search making our solution highly efficient.

2) Abstraction
A programming language consists of several data types which can be used to solve computer problems. However, to solve complex problems, we can use data structures to enable us to think in the problem space rather than the solution space (think in terms of what to do rather than how to do). Data structures generally work with operations on them such as link lists with insert, remove, procedures creating what we know as abstract data types. An algorithm works on similar lines in the effect that we can use them with an abstract view. For example when we need to sort the employees table, we can do so with a good sorting algorithm(thinking in the problem space) and thus improving our view of the entire solution(reducing the complexity as an effect).

3) Reusability
Great emphasis is laid on reusable components in software because of the reduction in the development and testing time by using already well tested reusable modules. Algorithms and data structures being abstract components can be reused to solve several commonly occuring problems such as sorting and searching. Moreover, these have been tried, tested and immensely improved upon by developers and scientists who have worked towards creating highly efficient, reusable solutions. Further more, several complex problems after considerable thought can be broken down into smaller ones which can be solved using tried and tested algorithms which in effect makes the solution simple.

 

Related Posts:

Tags: , ,