Data Structure – Introduction

Table of Contents

Data Structure – Introduction

Data may be organized in many different ways; the logical or mathematical model of a particular organization of data is called a data structure.

Data are represented by data values help temporarily with in program’s data area or recorded permanently on a file. The different programs to make use of these relationships, these data values must be in an organized form. The organized collection of data is called a data structure.

Data Structure = Organized Data + Allowed Operations Program

= Data Structure + Algorithms

 

Classification:

Data structures are classified into two types:-
  • Linear Data Structure:- A linear data structure is that whose data items are arranged in a linear sequence. For example: Linked, array, stack, queue.
  • Non-Linear Data Structure:- In this type of data structure, the data items are not in sequence. For example: Tree, Graph
On the basis of types of data elements, data structure can also be classified as:-
  • Homogenous data structure:- All the elements are of same type. Example:- Array
  • Non- Homogenous  data  structure:-  Elements  may  be  of  different type. Example:- Record structure
On the basis of memory allocation, data structures can be classified as:-
  • Static data structure:- They lave compile time memory allocation i.e. Static structures are ones whose sizes and associated memory locations are fixed at compile time. Example:- Arrays
  • Dynamic data structure:- They have run time memory allocation i.e. Dynamic structures are ones which expand or shrink as required during the program execution and their associative memory locations may change. Example:- Linked List
Data structures can also be classified as:-
  • Primitive data structure:- These are built in or basic data structures. Example:- Integer, Character, Boolean
  • Non-primitive data structure:- These are made with the help of primitive data structures. Example:- String, Arrays, Record

 

Basic Operations of Data Structures:-

  1. Creation:- This operation results in reserving (allocating) memory for data elements. The creation of data structure may take place either during compile time or during run-time.
  2. Insertion:- Adding a new data to the data structure.
  3. Deletion:- Removing a data item from the data structure.
  4. Searching:- Finding the location of the data item with a given key value. Or din cling the locations of all those data items which satisfy one or more conditions.
  5. Traversing:- Accessing each record exactly once so that certain items in the record may be procured.
  6. Sorting:- Arranging the records in some logical order (for e.g., alphabetically according to some NAME key or in numerical order according to some NUMER key like account no.)
  7. Merging:- Combining the records in two different sorted files into a single The may be some other operations, p.g. copying and concatenation.

Algorithms – Stepwise solution of a problem.

  • Algorithms are simple, reliable & correct.
  • Algorithms are easy to understand.
  • They are updatable & general.
  • Algorithms are portable (not depend on system).
  • Implemented easily.
  • They consume less time, memory & other resources.
  • Documented well (User friendly).

Algorithm:- An algorithm is a finite set of instructions which, if followed, accomplish a particular task. In addition, every algorithm must satisfy the following criteria:-

  • Input:- There are zero or more quantities which are externally
  • Output:- At least one quantity is
  • Definiteness:- If we trace out the instructions of an algorithm, them for all cases the algorithm will terminate after a finite number of steps.
  • Clarity:- Each instruction must must be clear and
  • Effectiveness:- Every instruction must be sufficiently basic that it can in principle be carried out by a person using only pencil and paper. It is not enough that each operation be definite but it must also be feasible.

Subalgorithms:- A subalgorithm is a complete and independently defined algorithmic module which is used (or invoked or called) by some main algorithm or by some other subalgorithm.

A subalgorithm receives values, called arguments, from an originating (calling) algorithm; perform computations; and then sends back the result to the calling algorithm.

The subalgorithm is defined independently so that it may be called by many different algorithms or called at different times in the same algorithms.

subalgorithm will usually have a heading of the form: name (para1, para2, ………)

Parameters are used to transmit data between the subalgorithm and the callietg algorithm.

Subalgorithm will have a return statement rather than an exit statement. This means that control is transferred back to the calling program when the execution of the subalgorithm is completed.

You May Like to Browers More