Description Of Various Data Structures :
An array can be defined as a set of finite number of homogeneous elements
or data items. It means an array can contain one type only, either all Integers, all floating-point numbers or all characters. Declaration of arrays is as follows :-
int a[10];
Where int specifies the data types or type of elements array stores. "a" is the name of arry and the number specified inside the square brackets is the number of elements an array can store. This is also called size or length of array.
Following are some of the points to be remembered about arrays -
1. The individual elements of an array can be accessed by specifying name of the array , followed by index or subscript (which is an integer number specifying the location of element in the array) inside square brackets.
For example to access fifth element of array "a", we have to give the following statement :-
a[4]
2. The first element of the array has index zero(0). It means the first element and last element will be specified as :
a[0] and a[3] respectively.
3. The elements of array will always be stored in consecutive memory locations.
4. The number of elements that can be stored in an array i.e. , the size of array or its length is given by the following equation -
(upperbound - lower bound) +
For the above array it would be. (9-0)+1= 10. Where 0 is the upper bound of array.
5. Arrays can always be read or written through loop. If we read a one - dimentonal array , it requires one loop for reading and other for writing (printing) the array.
2. Linked lists :
A list (linear linked list) can be defined as a collection of variable number of data items. Lists are the most commonly used linear data structures.
An element of list must contain at least two fields, one for storing data or information and other for storing address of next element. As we know for storing address we have a special data structure in C called pointers, hence the second field of the list must be pointer type. Technically each such element is referred to as a node, therefore a list can be defined as a collection of nodes as shown in fig.below.
3. Stack :
A Stack is also an ordered collection of elements like arrays, but it has a special feature that deletion and insertion of elements can be done only from one end , called the top of stack (TOP). Due to this property it is also called as last in first out type of data structure (LIFO).
For example , a stack of plates placed on table in a party , a guest always takes off a fresh plate from the top and the new plates are placed onto the stack at the top. It is a Non-Primitive Data Structure.
When an element is inserted into a stack or removed from the stack , its base remains fixed whereas the top of stack changes. Insertion of element into stack is called Push and Deletion of element from Stack is called Pop. The figure shows how the operations take place on a stack
4. Queues :
In a queue, new elements are added to the queue from one end called Rear end and the elements are always removed from other and called the Front end. Due to this reason , queues are also called First in First out of data structure.
The people standing in a ticket reservation row are an example of queue . Each new person comes and stands at the end of row ( rear end of queue) and persons getting their reservation confirmed , get out of the row from the front end.
5. Trees :
A tree can be defined as finite set of data items (nodes) .Trees is non-linear type of data structure in which data items are arrenged or stored sequence.
Trees represent the hierarchical relationship between various elements. In trees -
1.There is a special data item at the top of tree called the Root of the tree.
2. The remaining data item are partitioned into number of mutually exclusive (i. e. disjoint) subsets , each of which is itself a tree which is called the subtree.
3. The tree always grows in length towards bottom in data structure.
The tree structure organises the data into branches , which relate the information. In general, this type of structure is very useful.
6. Graph :
Graph is a mathematical non-linear data structure capable of representing many kinds of physical structure.
A graph G consists of a set of vertices V and a set of edges E. An edge connects a pair of vertices and many edges have weight such as length, cost or another edges measuring instrument for recording the graph. Vertices on the graph are shown as point or circles and edges are drawn as arcs or line segment. Thus an edge can be representing as
E=(V,W)
Where V and W are pair of vertices. The vertices V and W lie on E.
Thank You...
Comments
Post a Comment
Hello Friends,