DATA STRUCTURES NOTES

BY

Mohammad Sajid Farooq

Instructor,

PETROMAN TRAINING INSTITUTE

SUKKUR CAMPUS

Email Address: [email protected]

Data Structures: The logical or mathematical model of data is called a data structure.

Data is actually plural of Datum, means Raw Information or unprocessed information. Data are simply values or sets of values. A data item refers to a single unit of values. For example, a student’s information may be divided into four items/properties GRNO, name, class, and semester. But the GRNO would be treated as unique/ item.

Data are also organized into more complex types of structures.

Types of Data Structures

There are two types of data structure are available

  1. Linear
  2. Non-Linear
  1. Linear Structures: In this type of data structure we perform insert, delete, search, update operations sequentially or in an order (like Ascending/Descending). for example you have a list having 5 elements containing A,B,C,D,E,F values if u want to find that on which location E is store in this list, you must compare E with A,B,C,D and finally with E along this you must perform an increment to counter. After that you will find the actual location of your required/search item with the help of counter in this example the value of counter=4.
  • Examples of Linear Data Structures are as follows:
    1. Non-Linear: In this type of data structure we perform Traversing, insert, delete, search, update operation randomly.
  • Examples of Non-Linear Data Structures are as follows:
  • Data Structure operations: The data appearing in our data structures are processed by means of certain operations. In fact, the particular data structure that one chooses for a given situation depends largely on the frequency with which specific operations are performed. The following four operations play a major role in this text.

    1. Traversing: Accessing each record exactly once so that certain items in the record may be processed.( This accessing and processing is sometimes called "visiting" the record.)
    2. Searching: Finding the location of the record with a given key value, or finding the locations of all records, which satisfy one or more conditions.
    3. Inserting: adding a new record to the structure.
    4. Deleing: Removing a record from the structure.

    sometimes two or more of the operations may be used in a given situation; for example we may want to delete the record with a given key, which may mean we first need to search for the location of the record. the following two operations, which are used in special situation, will also be considered.

    1. Sorting: Arranging the records in some logical order (for example alphabetically according to some Name key, or in numerical order according to some Number key. such as account number.
    2. Merging: Combining the records in two different sorted files into a single sorted file

    Algorithm: An algorithm, is a finite step-by-step list of well-defined instructions for a particular problem.

    Algorithmic Notations:

    Note( In the bellow table all italic words indicates a user defined value)

    Notation Meaning
    ALGORITHM N.M

    where n=m=0,1,2,3,4,5,6,7,8,9

    n= major problem # and m = its alternative #
    (NAME OF ALGORITHM) in description portion u must define the name of algorithm.
    STEP#N where n=0,1,2,3,4,5,6,7,8,9 instruction # for future reference
    SET for example set max:=9999999 use for initializing value to a variable
    , for example set max:=0,k:=10 separator
    . statement terminator
    WRITE for example Write : aksks,1 output related
    READ for example Read: a input related
    IF .. THEN ELSE .. for example

    step#1 set a=10,b=20

    step#2 if a>b, then write: ‘A is Greatorthan B’ , ELSE write: ‘B is Greatorthan A’

    step#3 Exit

    conditional/testing related
    GOTO for example GOTO step#3 Unconditional Loop
    Exit End of Algorithm
    Repeat for Index Loop
    Repeat while Conditional Loop
    := for example A:=10 Assignment Operator
    = for example if a=b then write: ‘equ’ Testing/comparison operator
    + for example set a:=b+c. Addition (arithmetic operator)
    - for example set a:=b-c. subtraction (arithmetic operator)
    * for example set a:=b*c Product (arithmetic operator)
    / for example set a:=b/2 division (arithmetic operator)
    [] for example [This is comment] comments
    Declare

    for example Declare a , b [as integer]

    variable declaration statement
    and (logical operator)

    for example if a=10 and b=20 then write:‘a!=b ‘.

    (logical operator) in this example if both a=10 and b=20 then write executed other wise write statement doesn’t work.
    OR (logical operator)

    for example if a=b, OR , b=1 then write(‘a’)

    (logical operator) in both cases if a=b or b=1 then write executed.
    NOT for example if NOT a=10 then write: ‘a is not equals to 10’ (logical operator) in this example if a is not 10 then write will be executed.

    Array: A linear array is a list of finite number n of homogeneous data elements(i.e., data elements of the same type) such that:

    1. The elements of the Array are referenced respectively by an index set consisting of n consecutive numbers.
    2. The elements of the Array are stored respectively in successive memory locations

    The number n of elements is called the length or size of the array. if not explicitly stated , we will assume the index set consists of the integers 1,2,…n. In general, the length or the number of data elements of the array can obtained from the index set by the formula

    Length=UB-LB+1

    where UB is the largest index, called the upper bound, and LB is the smallest index, called the lower bound, of the array. Note that length=UB when LB=1.

    The elements of an array A and may be denoted by the subscript notation

    A1,A2,A3…An

    or by the parenthesis notation

     

     

    Note : Site is under construction further notes available very soon

     

     

     

     

    Hosted by www.Geocities.ws

    1