Top Ad unit 728 × 90

Data structure



★ Data:- 

Data can be define as a representation of facts,concepts or instructions in a formalized manner which should be suitable for communications,interpretations or processing by human or electronic machine. 


What is data

★ Data structure:-

Data structure is a representation of logical operation existing between individuals elements of data.
Data structure is also define as a mathematical and logical model of organising particular sets of data items.
Data structure is providing a way and a medium for accessing the data,organising the data,and calculating the data.
 
Classification of Data structure :-


data structure


1.  Primitive data structure :-

 ( A primitive data structure can store the value of only one data type.) these are basic data structure that are directly operand by machine instructions to be store. they are different representation of different machines and that  can hold a single value in specific location. example-  int,char,,float double.                                                                         

2.  Non primitive data structure :-                                                                                                                                                                                                                                  Non primitive data structure is a type of data structure that can store the data of more than one type .  They are based on structuring a group of homogeneous, some type of heterogeneous (different type of data icon).                                                          

ex - array list file etc.

Array :-

 An array is the collection of similar data type . it means that array contains one type of                           data only as all integer , all floating number , and all characters.                                                                 All elements of an array are store in continuous memory location of an array.

                       
        syntax :-
              Data type                         Name of 
                                                            Array
                     int                                    a                       
                                                         
         size of array
             [a]                                                      
          subscript                                            

            size of length =  Upper bound - Lower bound +4

* Link list :-

 It can be define as a collection of variable number of data item . an element of  a list must contains set of node and each node have to field .

   1. data field (for storing the data)

   2 .Pointer field (point the address of next node)

      

File :- 

  1.  A File is a collection of records related to each other.                                                                
  2. A file is a collection of data stored on mass storage (eg. disc or tape).                                             
  3. A file structure is a combinations of representations for data in files.
  4. it is also collections of operations for accessing the data . it enable applications to read write and modify data


Defference between linear and non-linear structrue






★ Stack :-

Stack is the non primitive linear data structure, it is an operand list in which addition and deletion of data item perform only one end that is top of  TOP of the stack . We always access TOP of the stack first. Stack is basically work on LIFO (last in first out) or FILO (first in last out) techniques .
 

Eg . 5 , 6 ,9 ,2, 3
Insert the given data in stack


3 is not insert because stack is overflow

Eg.
       TOP = TOP+1
       TOP = -1
       TOP = -1 +1 =0
       TOP = 0+1
       TOP = 1+1 = 2
   

Operation of stack :-

1.  Push :- used for insertion

         TOP =TOP + 1

2. POP :-  Used for deletion   

        TOP = TOP-1   


★ Queue :-

Queue is a non primitive linear data structure it is a homogeneous collection of elements in which new element are added at one end called the  REAR END and the existing elements are deleted from another end called FRONT END .

Queue is basically work on (last in first out) .
Eg.  - 7 , 2 , 6 , 9 , 1


           REAR = REAR + 1 (Insertion)

           FRONT = FRONT - 1 (Deletion)

Condition :- Queue is empty when front is (-1) and near also (-1)

           

★ Tree :-

 Tree is a non-primitive non-linear data structure . In this data items/elements are arranged in sorted sequence . It is use to represent helical relation existing between several data items .
 

★ Graph :-

Graph is a non primitive, non linear data structure . A graph (G) consists of vertical (V) and a set of edge (E) edge is called a order .

The main work of the edge is connect to vertices.

 ‡ Graph is basically 2 types :- 

1. Direct graph
2. Undirect graph


★ Complexity :-

Complexity of an algorithm is a function describing the efficiency of the algorithm is term of the amount of data that the algorithm must process. There are two main complexity majors of the efficiency of an algorithm.

1. Time complexity
2. Space complexity

* Time complexity :-

  1. Time complexity is the amount of time taken by the programme for complete execution.
  2. Time complexity is always major by frequency count. By frequency count we major the frequency of the program.

Frequency count :-

  • The efficiency of programme Majored by inserting counter in the algorithm in order to count number of times the basic operation is executed. 
  • ex- consider the following source code & calculate the frequecy count.

1.     void display()

           {

         int a,b,c;

          a=10;

          b=15;

          c=a+b;

       printf("%d",c);

           }

       code                             frequency count

       a=10;                                         -

       b=15;                                         -

       c=a+b;                                       -

       printf("%d",c);                    total  4


2.     int   sum [int a[10] , int[n]]
               {
            int  i , sum=0;
          for(i=0;i<n;i++)
              {
            sum = sum + a[i]
              }
            return  sum;
               }

     code                                           frequency

   sum=0                                                 1
  for(i=0;i<n;i++)                                  n+1
  sum = sum + a[i]                                  n
     return (sum)                                       1
                                                       total = 2n + 3        
                                                       
 
3.   obtain frequency count when i = 1
        
            do
             {
            a++
          if(i==5)
           break;
            i++;
             }
          while(i<=n)
  

        code                           frequency

        i=1                                    1
        a++                                   1
     if(i==5)                                5
       i++                                     6
    while(i<=n)                          n
       break;                                1 
                                          total = 14 + n
                       

*space complexity :- 

           It can be define as amount of memory space required by an algorithm to run on execute.
           to compute the space complexity we used two factors.

       1. constant

       2.  instant characterstics

the space requirement s(p) can we given as
(space require)    S(P)   =  C+S(P)
    where -
     SP =  Instance variable port
      C =  Constant (fix port)

C is also denote input or output space.
this space is the amount of space taken by instruction , variable & identifier SP is a space upon instant 

ex :- 
      sum (a , n)
        {
       s=0.0;
      for i =1 to n
        s=s+ a[i];
       return (s)
          }

       code                                    Sp
           

    s=0.0                                      0(1)
   for i=1 to n                             0(n)
  s=s+a[i]                                   0(n)
   return (s)                                0(n)
                                           total = 0(2n+2)    
   

Data structure Reviewed by For Learnig on December 19, 2023 Rating: 5

No comments:

If you have any doubts, please tell me know

Contact Form

Name

Email *

Message *

Powered by Blogger.