Data Structures Introduction
Data Structures Introduction
Primitive data are only single values, they have not special capabilities.
The examples of Primitive data types are given byte, short, int, long, float, double,
char etc.
The integer, real’s, logic data character data pointer and reference are primitive
data structures data structure that normally are directly operated upon by
machine level instructions are known as primitive structure and data type.
The data type that are derived from primary data types are known as non-
primitive data type.
The non-primitive data types are used to store the group of values.
Examples : Arrays, Stacks, Queues and linked lists are the examples for linear
data structures.
Single dimensional arrays have only one subscript or index where as multi-
dimensional arrays may have more than one subscript or index.
For Example:
int a[20];
float b[10]; //single dimensional or one dimensional arrays
int a[3][3]; // double dimensional or table or two dimensional
int a[3][3][3];// multi-dimensional
Note: There may be any number of subscripts for arrays.
Declaration of Arrays:
Syntax:
data type array name [no. of items];
Or
data type array name [index];
Ex:
int a [ 10 ]; // integer array
Note:
Array name should not contain any spaces.
Index of the array should not be zero or less than zero.
Array size is fixed.
Array index starts from zero always.
11 33 22 55 44 88 66 55 77 99 100 101
0 1 2 3 0 1 2 3 0 1 2 3
Operations on Arrays:
1. Creation of array
2. Initialization of array
3. Accepting data into array
4. Displaying contents of array
5. Insertions
6. Deletions
7. Search
8. Sort
Advantages of arrays:
Disadvantages of arrays:
1. Array size is fixed. The user cannot grew or shrink the size dynamically.
2. Optimum utilization of memory may not be achieved (i.e., there is a scope
for wasting the memory).
3. Arrays allow only similar kind of items as data.