Page 14 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 14

Unit 1: Data Structures




          By default, the first enumeration member in the set has value 0. The next member has value of  Notes
          the first one plus 1. So in this case red = 0, green = 1 and blue = 2. You can explicitly assign an
          enumeration member to another value using assignment operator ( =) when you define the
          enumeration type.
          The enumeration members must follow the rules:

               An enumeration set may have duplicate constant values. For instance, you can assign 0
               with two enumeration members.

               The name of enumeration member must be unique within its scope. It means its name
               should not be the same as other member or variable name.
          If you declare a variable with enumeration type, the value of that value must be one of the
          values of the enumeration members.


                 Example: Declaring a variable called favourite_color as a variable of the color type.
          enum color favorite_color = green;

          Self Assessment


          Fill in the blanks:
          3.   A ..................... determines the number of bytes to be allocated to the variable.
          4.   The value ranges of integer types can be found in the ..................... header file.
          5.   ..................... types represents non-integer number with a decimal point at any position.
          6.   ..................... type is used to store characters and letters.

          7.   In C, the char type has ..................... unit of memory.
          8.   C provides developers with special types called ..................... to declare symbolic names
               that represent integer constants.

          9.   By default, the first enumeration member in the set has value .....................

          1.3 Description of Various Data Structures

          Data structure are classified into two type such as linear or non-linear.

               Linear: A data structure is said to be linear if its elements form a sequence. The elements
               of linear data structure represents by means of sequential memory locations. The other
               way is to have the linear relationship between the elements represented by means of
               pointers or links. Ex-Array and Link List.
               Non-linear: A data structure is said to be non-linear if its elements a hierarchical relationship
               between elements such as trees and graphs. All elements assign the memory as random
               form and you can fetch data elements through random access process.
          In this section, we will discuss the brief description of various data structures such as arrays,
          stack, queues, etc.

          1.3.1 Arrays

          The simplest type of data structure is a linear (or one dimensional) array. By a linear array, we
          mean a list of a finite number n of similar data elements referenced respectively by a set of n




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