You are on page 1of 4

Data Structures

Data structure is concerned with the representation and manipulation of data in a computer. The computer programs manipulate and represent the data in some way that requires an algorithm.

Data type
A data type is a data storage format that allows a specific type or range of values and a set of operations. Data can be organized with variables. Each variable must be assigned a specific data type. Some common data types include Integers Floating point numbers Characters Strings Boolean etc.

Abstract Data Type

Abstract data type is a unique mathematical model or tool for specifying the logical properties of a data type. In another way we can define, a set of data values and associated operations that are precisely specified independent of any particular data type implementation. ADTs are one of the foundations of Object oriented because they formulize the notation of information hiding/encapsulation, which hides the implementation of an ADT behind its interfaces. For example: An abstract stack data structure could be defined by three operations Push That inserts some data item onto the structure . Pop That extracts an item from it. Peek That allows data on top of the structure to be examined without removal Advantages: 1. Abstraction The user does not need any technical knowledge of how the implementation works to use the ADTs. 2. Localization of change Code that uses an ADT object will not need to be edited if the implementation of ADT is changed. 3. Flexibility Different implementations of an ADT may be more efficient in different situations.

An algorithm is a sequence of steps that gives method of solving a problem. It creates the logic of program. More precisely, an algorithm is a sequence of instructions that act on some input data to produce some output data in a finite number of steps. An algorithm must have the following properties. An algorithm must receive some input data supplied externally. An algorithm must produce at least one output as the result. The algorithm must terminate after a finite number of steps. The steps to be performed in the algorithm must be clear and Unambiguous. Effectiveness One must be able to perform the steps in the algorithm on paper. Input Output Finiteness Definiteness

Complexity of Algorithm
The analysis of an algorithm provides information that determines the amount of resources such as runtime and storage space necessary to execute the program. The theoretical estimation of run time needed by any algorithm as a function of input size is called time complexity. Here the space is fixed for an algorithm then only run time will be considered for obtaining the complexity of an algorithm. The efficiency of an algorithm is depends on both run time and storage space. Run time means the time taken by program for execution and storage space means the space required to run the program. The performance of the algorithm is determined by giving any one of 3 categories of Inputs. 1. Best case Input-- The input set that allows an algorithm to perform Most quickly. For example: The value that the algorithm is searching is found in the 1st location. 2. Worst case Input-- The input set that allows an algorithm to perform mist slowly. 3. Average Case Input The input set that allows an algorithm to deliver an average performance.

It is more important that the rate of increase in operations performed by the algorithm as the size of the program inputs increases. This is often called the rate of growth of the algorithm. Based on the rate of the growth the algorithms can be grouped into 3-categories.

1. Algorithms that grow at least as fast as some functions can be represented as Big Omega i.e. (f). 2. Algorithms that grow at the same rate can be represented as Big Oh i.e. O(f). 3. Algorithms that grow no faster can be represented as Big Theta i.e. (f).

An array is finite collection of similar elements stored in adjacent memory locations. Finite means that there are specific number of elements in an array and similar means that all the elements in an array are of the same type. For example, an array may contain all integers or all characters but not both. Advantages: 1. Very easy to define and understand. 2. No need of remembering the addresses of data items/objects. 3. You can use one name for similar objects and save then with the same name but different indexes. 4. Arrays are very useful when you are working with sequences of the same kind of data 5. Arrays use reference type. Disadvantages: 1. Arrays have a fixed dimension. Once the size of an array is decided it cannot be increased during execution. 2. Operations like insertion of a new element in an array or deletion of an existing element from the array are little bit tedious. 3. Array elements are always stored in contiguous memory locations. At times it might so happen that enough contiguous location might not be available for the array even though the total free space in the system is more than the space required by the array to be created. 4. Sometimes it's not easy to operate with many index arrays. 5. C environment doesn't have checking mechanism for array sizes.

Sparse Matrix
A sparse matrix is a matrix that allows special techniques to take advantage of the large number of zero elements. There is no precise definition of when a matrix is sparse and when it is not. "How many" zeros a matrix needs in order to be "sparse." The answer is that it depends on what the structure of the matrix is, and what you want to do with it. The number of colons in sparse is 3 and the number of row is depending on the non-zero elements in the original matrix plus one.

For Example: 0 0 0 0 1 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Matrix -5 0 0 2 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 0 0 5 0 7 0 0 0 0 0 0 8 0 1 1 2 3 4 7

Sparse 7 3 1 6 4 3 0 5 7 -5 4 7 9 2 1 5