0% found this document useful (0 votes)
46 views

Data Structures Introduction

The document discusses different data types including primitive and non-primitive data types. It also discusses different types of data structures such as linear, non-linear, static, dynamic, homogeneous, and heterogeneous data structures. Common data structures like arrays, stacks, queues, linked lists, trees and graphs are described.

Uploaded by

akurathikotaiah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Data Structures Introduction

The document discusses different data types including primitive and non-primitive data types. It also discusses different types of data structures such as linear, non-linear, static, dynamic, homogeneous, and heterogeneous data structures. Common data structures like arrays, stacks, queues, linked lists, trees and graphs are described.

Uploaded by

akurathikotaiah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Data Types

Primitive Data Type:


A primitive data type is one that fits the base architecture of the underlying
computer such as int, float, and pointer, and all of the variations, thereof such as
char short long unsigned float double and etc, are primitive data type.

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.

Non- Primitive Data type:


A non-primitive data type is something else such as an array structure or class is
known as the non-primitive 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 of non-primitive data type.

Array, structure, union, link list, stacks, queue etc.


DATA STRUCTURES
The collection of raw facts is known as Data. The data after processing becomes
information. The collection of data elements along with relationships between
these individual elements is called Data Structures. These relationships are
provided by some specific member functions.

Data structures are basically of following types:


 Linear Data structures
 Non linear Data structures
(Or)
 Static Data structures
 Dynamic Data structures
(or)
 Homogeneous Data Structures
 Heterogeneous Data Structures

Linear Data structures:


If the data elements are stored in a sequential order, such type of data
structures are called Linear Data Structures

A linear data structure is a means where data may be organized in sequential


manner or in linear order.

Examples : Arrays, Stacks, Queues and linked lists are the examples for linear
data structures.

Non-linear Data structures:


If the data elements are stored in memory without any order that type of
structure is called Non-Linear Data Structures.

A non-linear data structure is a means where data may be organized in quite a


different manner. It doesn’t follow any linear form.
Examples : Trees & Graphs are the examples for the non-linear data structures.
Static Data structures:
A static data structure is fixed in its size as it is specified during the compile
time. Arrays, Stacks & Queues are the examples for static data structures.

Dynamic Data structures:


A dynamic data structure is created during the runtime. It provides better
flexibility to the user as it allows the user to increase or decrease the size during
the execution of the program. Hence we say that dynamic data structures may
vary during the runtime. Moreover, dynamic data structures allow the user to
add, delete and rearrange data items at runtime.

Example: Linked lists, Trees & Graphs

Homogeneous Data Structures


It is a data structure where items of similar kind or same type of items are
placed/arranged. Arrays, Stacks, Queues are the examples of this kind.

Heterogeneous Data Structure


It is a data structure where items of different can be placed and operated.
Linked Lists, Trees & Graphs may be the examples of Heterogeneous data
structures
Arrays

Array is a collection of similar kind of items or elements. In other words, an


array is a linear list in which a group of elements are identified by a unique
name. In some other way, a group of elements that have common name is said
to be an array. An array can be called as linear list or simply list.

Arrays are of two different types:


 Single Dimensional arrays
 Multi-dimensional arrays.

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

char str [ 8 ]; // character array

Data type array name index


Symbolic representation of a single dimensional array follows:
a
0 1 2 3 4 5
10 30 20 40 60 50

100 102 104 106 108 110


a[0] a[1] a[2] a[3] a[4] a[5]

 Here 0,1,2,3,4 and 5 are the index location.


 a[0],a[1],a[2]….. are the elements.
 100,102,104,106,108 and 110 are the physical locations of the elements.

Array locations can be calculated as follows:

a[ i ] = a(starting address) + i ( index) * blocking factor ( data size)

For example: Address of a [2] is: a [ 2 ] = 100 + 2 * 2 = 104.

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.

Symbolic representation of two dimensional arrays follow:

For example, consider int a [3][4];

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:

1. As arrays store all the elements in continuous locations, it becomes easy


to access all the elements.
2. Arrays allow the user to store elements of same type in sequential
manner.
3. Array elements can be accessed randomly (need not to follow any order).
4. Arrays avoid no. of variables & their naming.

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.

You might also like