Page 12 - DCAP605_ADVANCED_DATA_STRUCTURE_AND_ALGORITHMS
P. 12

Unit 1: Introduction to Data Structure and Arrays




          Non-linear data structure: Every data item is attached to several other data items in a way that   Notes

          is specific for reflecting relationships. The data items are not arranged in a sequential structure.

          Ex: Trees, Graphs.
          Basic Concept of Data

          The memory (also called storage or core) of a computer is simply a group of bits (switches). At
          any instant of the computer’s operation any particular bit in memory is either 0 or 1 (off or on).
          The setting or state of a bit is called its value and that is the smallest unit of information. A set of
          bit values form data.

          Some logical properties can be imposed on the data. According to the logical properties data can
          be segregated into different categories. Each category having unique set of logical properties is
          known as data type.
          Data type are of two types:
          1.   Simple data type or elementary item like integer, character.
          2.   Composite data type or group item like array, structure, union.
          Data structures are of two types:
          1.   Primitive Data Structures: Data can be structured at the most primitive level, where
               they are directly operated upon by machine-level instructions. At this level, data may be
               character or numeric, and numeric data may consist of integers or real numbers.

          2.   Non-primitive Data Structures: Non-primitive data structures can be classified as arrays,
               lists, and fi les.

          An array is an ordered set which contains a fixed number of objects. No deletions or insertions
          are performed on arrays i.e. the size of the array cannot be changed. At best, elements may be
          changed.
          A list, by contrast, is an ordered set consisting of a variable number of elements to which
          insertions and deletions can be made, and on which other operations can be performed. When a
          list displays the relationship of adjacency between elements, it is said to be linear; otherwise it is
          said to be non-linear.

          A file is typically a large list that is stored in the external memory of a computer. Additionally, a
          file may be used as a repository for list items (records) that are accessed infrequently.

          From a real world perspective, very often we have to deal with structured data items which
          are related to each other. For instance, let us consider the address of an employee. We can take
          address to be one variable of character type or structured into various fields, as shown below:


           Address1      Address: Characters (56)


           Address2      House No.: char (5)  Street: char(5)

                         City: char(20)     State: char(20)    PIN: char(6)


          As shown above Address1 is unstructured address data. In this form you cannot access individual
          items from it. You can at best refer to the entire address at one time. While in the second from, i.e.,
          Address2, you can access and manipulate individual fields of the address – House No., Street,

          PIN etc. Given hereunder are two instances of the address1 and address2 variables.





                                           LOVELY PROFESSIONAL UNIVERSITY                                     7
   7   8   9   10   11   12   13   14   15   16   17