DATA STRUCTURE

A data structure is a way of organizing data that considers not only the items stored,but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data.

“In computer science, a data structure is a particular way of organizing data in a computer

so that it can be used efficiently” -(Wikipedia)

These are the area where Data structure are mostly used:

  • Compiler Design
  • Operating System
  • Database Management System
  • Statistical analysis package
  • Numerical Analysis
  • Graphics
  • Artificial Intelligence
  • Simulation

A data structure requires a certain amount of space for each data item it stores, a certain amount of time to perform a single basic operation, and a certain amount of programming effort. Each problem has constraints on available space and time.Each solution to a problem makes use of the basic operations in some relative proportion.

A data structure is any data representation and its associated operations. Even an integer or floating point number stored on the computer can be viewed as a simple data structure.

In C language Different types of data structures are

  • Array
  • Stack
  • Queue
  • Linked List

Array:

It is a collection of homogeneous( same data type) data items. 

There are two types of Array:

  • One dimensional array

Declaration in C :

data_type arr_name [arr_size];

Initialization in C:

data_type arr_name[arr_size]=(value1, value2, value3,….);

Accesing in C:

array_name[index];

  • Multi dimensional array

 

Declaration in C :

data_type arr_name [num_of_rows][num_of_column];

Initialization in C:

data_type arr_name[arr_size]=(value1, value2, value3,….);

Accesing in C:

array_name[index];

Why ARRAYS?

  • Less amount of code
  • Easy access of elements
  • Easy to implement algorithms
  • Random Access

NOTE: We cannot use negative indexes

We can access any elements of array  in O(1) time complexity.

 

Leave a Reply

Your email address will not be published. Required fields are marked *