Explain different types of Data Structure with suitable example. ( 5 Marks, Mumbai University)

 

Explain different types of Data Structure with suitable example. (5 Marks, MU)

Answer: 

Data Structure can be defined as the group of data elements which provides an efficient way of storing and organizing data in the computer so that it can be used efficiently. Data structures are the building blocks of any program or the software.

They are classified into 2 different types:

  1. Primitive data structure

  2. Non-primitive data structure

 a)Linear data structure

b)Non-linear data structure


Fig: Types of Data Structure

Primitive data structures

Primitive Data Structures are the basic data structures that directly operate upon the machine instructions.

It includes:

  1. Integer
  2. Real
  3. Character
  4. Boolean



Non-Primitive data structures: These data types are not actually defined by the programming language but are created by the programmer. They are also called “reference variables” or “object references” since they reference a memory location which stores the data.

It includes 2 types they are:

  • Linear data structures
  • Non-linear data structures


Linear Data Structure: A Linear data structure have data elements arranged in a sequential manner and each member element is connected to its previous and next element.

It includes:

Arrays: An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. This makes it easier to calculate the position of each element by simply adding an offset to a base value, i.e., the memory location of the first element of the array. The base value is index 0 in an array.

Fig: Array Linked List: A linked list is a linear collection of data elements whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes which together represent a sequence.


Fig: Linked List



Stacks: Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out).


Fig: Stack


Queues: Queue is an abstract data structure, somewhat similar to Stacks. Unlike stacks, a queue is open at both its ends. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue). Queue follows First-In-First-Out.


Fig: Queue



Non-linear data structures: A non-linear data structure has no set sequence of connecting all its elements and each element can have multiple paths to connect to other elements. Such data structures supports multi-level storage and often cannot be traversed in single run.

It includes:


Trees: A tree is a nonlinear data structure, A tree can be empty with no nodes or a tree is a structure consisting of one node called the root and zero or one or more subtrees.


Fig: Tree


Graphs: A Graph is a non-linear data structure consisting of nodes and edges. The nodes are sometimes also referred to as vertices and the edges are lines or arcs that connect any two nodes in the graph, a graph consists of a finite set of vertices(or nodes) and set of Edges which connect a pair of nodes.



Fig: Graph





 

No comments:

ads
Powered by Blogger.