Sunday, March 3, 2013

Data Structure full notes in Hindi

Data Structure notes in Hindi. All notes only in one pdf file download click here- Download

Thursday, February 28, 2013

Types of array


There are mainly three types of array.these are follows.
  1. One- Dimensional array
  2. Two- Dimensional array
  3. Multi- Dimensional array
One-Dimensional array : In C a one-Dimensional array can be declared as int a[10];
by the above statement we are giving an integer type are array named a which can store the element up to 10. In the declaration of an array three things must be encountered:
data-type var_name[size];
We can calculate the length of an array using the given formula:
Length=(UB-LB)+1
LB=Lower bound
UB=Upper bound
Here we have used '+1' in the formula since in general an array is started  from 0 location and to find the exact location of the number '+1' is applied.
Example :Let we have marks of 5 students then it can be show as follows:
Marks[0]=70, Marks[1]=92, Marks[2]=75, marks[3]=72, Marks[4]=82,  
It can be display in row from of array as follows:
And in column from as follows:
 
Hence we can calculate the length of this array.
Length = (UB+LB)+1
=4-0+1
=5
Memory allocation to an array:~As per the data type of the element it is allocate memory space i.e. in C for int 2 bytes, for char 1byte etc.So for the generalized memory space we can drive the expression for each kind data type.
Memory space Required= Length*w
w = byte allocated to that type of data type
For e.g. if we take above given example then from formula
memory apace Reuired =   Length*w  
(for int w=2) 
=5*2
=10
 This array will occur 10bytes in memory
  Let LA be a liner array in the memory of the system. So we can calculate the location of element in the follows manner.
LOC(LAK)=Base(LA)+W(K-lower bound)
Where LA is the linear array, Base address(LA) is denoted the address of the first element of LA and W is the number of words for memory cell for the array LA.
Example: consider an array school,  which record the number of school generated each year from 1947 to 1999. Suppose SCHOOL appears in memory as picture-
Array representation
That is  base[SCHOOL]=500
W=4 words per memory cell for SCHOOL
LOC [1947]=500, LOC[1948]=504,...............
So find the address of array element for the year =1980, So
LOC(SCHOOL[1980]) =Base (SCHOOL)+W(1980-LB)
=500+4(1980 - 1947)
=632
Two dimensional array : A two dimensional array  m * n array is a collection of m.n data elements such that each element is specified by a pair of integers data type, called subscript.
The element of A first subscript J and second subscript K will be denoted by

Aj,k   or A[J,K]

Notes-Detailed study of 2-D array will cover in the next post.

Multi- Dimensional array :-General Multidimensional array are defined analogously an n-dimensional array  M1 * M2 *M3....................Mn, array B is a collection of M1 * M2 *M3....................Mn, data elements can be represents as:
Bk1,k2.......kn or B[k1 k2.......kn]

Operation of array

There are many operation perform by the linear array, there are as follows:

  1. Traversal the array
  2. Deletion from an array
  3. Sorting is an array
  4. Insertion in an array
  5. Searching in an array
  6. Merging in an array
These are all the operation of the array. Now we will be discuss operation one-by-one.
  1.  Traversal the array :-By traversing we mean, accessing and/or processing(visiting) of each element exactly once of the array.
Algorithm-: LA (LB, UB, K)
  1. [ Initialize counter] Set K=LB
  2. Repeat step 3 and 4 while K<=UB
  3. [Traverse an element] Apply process to LA[K]
  4. [Increase counter] set K=K+1
  5. [End of the step 2 loop]
  6. Exit
This is the algorithm of the traversing of an array. Now we can see the C-implementation of an array.
Program:-
#include<stdio.h>
#include<conio.h>
void main()  /* Main function */
{
int a[10], i;
clrscr();
printf("enter array value");
for(i=0; i<10; i++)

scanf("%d", & a[i])
}
printf("the enter array is/n");
for( i=0;, i<10; i++)
{
printf("%d",a[i]);
}
getch();
}
Output of program:-
1
2
3
4
5
6
7
8
9
The enter array is
1
2
3
4
5
6
7
8
9

Insertion in array-After some time:

Arrays

Array is a defined as collection of finite number of homogeneous elements(same type elements) or data item.It means an array can contain of type of data only, either all integers, all floating number etc. it is a group of contiguous or related data item that share a common name. it is basically a collection of  same data type is other words. declaration of arrays is as following:~
char a [5];
Where char specifies the data type or type elements array store. "a" is the name of array, and the number specified inside the square brackets is the number of elements is the number of elements as array can store, that is also called length of array.
length of size of array is the total number of elements.
Length of array = UB - LB + 1
 Here - UB- denotes upper bound
             LB- denotes lower bound
   Where under bound is the largest index and lower bound is the lowest index of the array.
If lower bound=1 then length of array is equal to upper bound.
Some important points about of array :
1.  The individual element of an array can be accessed by specifying name of the array follows by index inside the brackets for example to access third element of array a, we have to give the following statement :
a[2] 
2.  The first element of an array has index [0]. It means the first element and last element will be specified as:
a [0] and [n - 1]
3.  Array are normal like any other variable.
4.  Array can always be read or written through loop.If we study about one dimensional the requires one loop for reading and writing. 
For example
(a) reading an array :
for(i=0; i<=n; i++)
{
scanf("%d",&a[i]);
}
(b) for printing an array :
for (i=0;i<=n;i++)
{
printf("%d",a[i]);
}
similarly we are studying about two dimensional array then we require two loops. And similarly the array of n dimensional require n loops:
Example Let A be 10 element of linear array of integer such that
A[0]=1, A[1]=2, A[2]=3, A[3]=4, A[4]=5, A[5]=6, A[6]=7, A[7]=8, A[8]=9, A[9]=10
So length of array = UB-LB+1
=9-0+1
=10
Some command operation performed on array are as follows:
  1. Creating:Creating an array.
  2. Traversing:Processing every element of array.
  3. Searching:Finding the location of an element.
  4. Insertion:Insert a new element in given array.
  5. Deletion:Delete an item from  the array.
  6. Merging: Merging of an arrays.
So these are the some operation of an arrays. this was the brief description of an array.
TYPES OF ARRAY -CLICK HERE

Wednesday, February 27, 2013

Classification of data structure

Data structure are Diveded into two main categories.:~
  1. Primitive data structure
  2. Non-primitive data structure
  1. primitive data structure :~The primitive data structure are defined that can be manipulated or operated by the machine instruction.There is general, have different representations an different computers.
For example- the integers, floating-point numbers, pointers, string constans, characters etc.
are some of the different primitive data structure.in C language, the different primitive data structure are defined using the data type such as int, char, float, double etc.

 2. Non-primitive data structure-The non-primitive data structures are data structure that cannot be manipulated or operated directly by the machine instructions.These are more sophisticated data structures.These are derived from the primitive data structure.
For example-Arrays, structure, stack, queues, linked list etc.
The non-primitive data structure are classified into two categories linear and non linear data structure.Whene the elements are accessed in contiguous memory location then data structure is know as linear   data structure.
Array stack queue and link list are the example of the linear data structure in linear data structure we have to first allocate memory for the number of elements like in arrays.This some time leads to wastage memory.
in non-linear data structure element are not accessed in contigious memory allocation
 Example-Non-linear data structure are tree graph, sets etc.
we can represent a hierarchy of data structure as follows:~

Tuesday, February 26, 2013

1.1 INTRODUCTION

A data structure in computer science is a way of storing data in a computer so that it can be used efficiently.It is an organization of mathematical and logical concepts of data. A well defined datda structure a variety of critical operations to be performed using a few resources, both exection time and memory space, as possible. Data structures are implemented by a programming language as data types and the references and operations they provide.
  Data structure is a way of organizing the all data items that considers not only the element stored but also their relationship to each other. data structures usually consists of two things : first one is the type of structure that we are going to used to store data and second hoe efficiently we perform operation on to the data stored in structure so that it result in less execution time and amount of memory they require. So by this way we can say that data structure is one collection of data structures.
Data structure mainly classify the following features:~
1. Organization of data.
2. Logical or mathematical model of data.
3. Accessing Methods of data.
4. Implementation of an abstract data type.
5. Degree of associativity.
6. Processing alternatives for information.
7. Dynamic memory allocation.
Data structure are the building   block of the programs and hense the choice of a particular data model or structure depends on the following features:~
* Data structure must be rich enough in structure to reflect the actual relationship of the data
* And second one structure should be simple (not complex to understand) enough that any one can process  data easily whenever required.

A program is make by the combination of the algorithm and the data structure. SO we can write as:
data structure + algorithm = program
Notes :~ Algorithm is the step by step solution of a program.
To develop a program of  an algorithm

0.3 ASYMPTOTIC NATATION

The asymptotic notation is nothing but to assume the volume of a function.A try is made to equate two function with some assumptions to make the representation simple and general. Most commonly used asymptotic notations are big oh(O), big omega and big theta, so

Both space complexity and time complexity can be represented using asymptotic notations.

0.2 ALGORITHM PREFORMANCE

THE performance evaluation of an algorithm is obtained by totalling the  number of occurrences of each operation when running the algorithm. performance of an algorithm depend upon the time and space. time taken by the algorithm depends upon many factors: one of the factor is operation used by the algorithm. run time efficiency of an algorithm depends upon the execution time of instruction in algorithm for a set of inputs. There instruction are used in an algorithm in such a way that execution time of instruction become less for the inputs. To solve this problem scientists developed asymptotic notations. These notations are commonly used in performance on analysis and used to characterize the complexity. There are various nation used in such type of analysis