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

Data Structure

Uploaded by

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

Data Structure

Uploaded by

sheebakbs5144
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

DATA STRUCTURE

Data may contain a single element or sometimes it may be a set of elements. Whether it is a
single element or multiple elements but it must be organized in a particular way in the computer
memory system. In this article, we are going to discuss some very important terms like what is
data structure & classification of data structure – Primitive Data Structure, Non-Primitive
Data Structure etc.
In the example mentioned above such as ID, Age, Gender, First, Middle, Last, Street, Area, etc.
are elementary data items, whereas (Name, Address) is group data items.

What is data structure :


The data structure is basically a technique of organizing and storing of different types of data
items in computer memory. It is considered as not only the storing of data elements but also the
maintaining of the logical relationship existing between individual data elements.
The Data structure can also be defined as a mathematical or logical model, which relates to a
particular organization of different data elements.

Specification of data structure :


 Organization of data
 Accessing methods
 Degree of associativity
 Processing alternatives for information
Data structures are considered as the main building blocks of a computer program. So, at the
time of selection of data structure, we should follow these two things so that our selection is
efficient enough to solve our problem.
1. The data structure must be powerful enough to handle the different relationship
existing between the data.
2. The structure of data also to be simple, so that we can efficiently process data when
required.
Basically, the term data structure and algorithm both are somehow related to each other. Set of a
well-defined algorithm and data structure makes a computer program efficient.
Algorithm + Data Structure = Program
A program can be made using the different data structure to produce the same output. But the
efficiency of the program will depend on the choice of the best data structure to create that
particular program. We have a classification of data structures to choose to make this happen.
1
Classification of data structure :

The classification of data structure mainly consists of :

1. Primitive data structure


2. Non-primitive data structure
Primitive data structure :
The primitive data structures are known as basic data structures. These data structures are
directly operated upon by the machine instructions. Normally, primitive data structures have
different representation on different computers.
Example of primitive data structure :
 Integer
 Float
 Character
 Pointer
Non-Primitive data structure :
The non-primitive data structures are highly developed complex data structures. Basically, these
are developed from the primitive data structure. The non-primitive data structure is responsible
for organizing the group of homogeneous and heterogeneous data elements.
Example of Non-primitive data structure :
 Arrays
 Lists
 Files
Integer :
The integers are signed or unsigned whole numbers with the specified range such as 5, 39, -1917,
0 etc. They have no fractional parts. Integers can be positive or negative but whether or not they
can have negative values, it depends upon the integer types.

2
Float :
Float refers floating point or real number. It can hold a real number or a number having
a fractional part like 3.112 or 588.001 etc. The decimal point signals that it is a floating point
number, not an integer. The number 15 is an integer but 15.0 is a floating point number.
Character :
It can store any member of the basic character set. If a character from this set is stored in a
character variable, its value is equivalent to the integer code of that character basically known
as ASCII code. It can hold one letter/symbol like a, B, d etc. Characters can also be of different
types.
Pointer :
A pointer is but a variable-like name points or represents a storage location in memory (RAM).
RAM contains many cells to store values. Each cell in memory is 1 byte and has a unique
address to identify it. The memory address is always an unsigned integer.
Arrays :
Arrays are the set of homogeneous data elements stored in RAM. So, they can hold only one
type of data. The data may be all integers, all floating numbers or all characters. Values in an
array are identified using array name with subscripts. Single sub-scripted variables are known as
a one-dimensional array or linear array; two sub-scripted variables are referred as a two-
dimensional array.

One Dimenstional Array

Two Dimensional Array

3
Lists :
A list is a collection of a variable number of data items. Lists fall in the non-primitive type of
data structure in the classification of data structure. Every element on a list contains at least two
fields, one is used to store data and the other one is used for storing the address of next element.
Linear linked lists

Files :
Files contain data or information, stored permanently in the secondary storage device such as
Hard Disk and Floppy Disk. It is useful when we have to store and process a large amount of
data. A file stored in a storage device is always identified using a file name
like HELLO.DAT or TEXTNAME.TXT and so on. A file name normally contains a primary
and a secondary name which is separated by a dot(.).

Files

Stack :
Like arrays, a stack is also defined as an ordered collection of elements. A stack is a non-
primitive linear data structure having a special feature that we can delete and insert elements
from only one end, referred as TOP of the stack. The stack is also known as Last In First Out
(LIFO) type of data structure for this behaviour.
When we perform insertion or deletion operation on a stack, its base remains unchanged but the
top of the stack changes. Insertion in a stack is called Push and deletion of elements from the
stack is known as Pop.
We can implement a stack using 2 ways:
 Static implementation (using arrays)
 Dynamic implementation (using pointers)

4
Stack

Queues :
Queues are also non-primitive linear data structure. But unlike stacks, queues are the First In
First Out (FIFO) type of data structures. We can insert an element in a queue from the REAR
end but we have to remove an element from the only FRONT end.
We can also implement queues using 2 ways :
 Using arrays
 Using pointers

Queue

Trees :
Trees fall into the category of non-primitive non-linear data structures in the classification of
data structure. They contain a finite set of data items referred as nodes. We can represent a
hierarchical relationship between the data elements using trees.
A Tree has the following characteristics :
 The top item in a hierarchy of a tree is referred as the root of the tree.
 The remaining data elements are partitioned into a number of mutually exclusive subsets
and they itself a tree and are known as the subtree.
 Unlike natural trees, trees in the data structure always grow in length towards the bottom.

5
Trees

Graph :
Graph falls in the non-primitive non-linear type of data structure in the classification of data
structure. Graphs are capable of representing different types of physical structures. Apart from
computer science, they are used broadly in the fields of Geography, Chemistry & Engineering
Sciences.

A graph normally a combination of the set of vertices V and set of edges E.

Graph

The different types of Graphs are :


1. Directed Graph
2. Non-directed Graph
3. Connected Graph
4. Non-connected Graph
5. Simple Graph
6. Multi-Graph
Uses of data structures
In general, data structures are used to implement the physical forms of abstract data types. This
can be translated into a variety of applications, such as displaying a relational database as
a binary tree.

In programming languages, data structures are used to organize code and information in a digital
space. For example, Python lists and dictionaries or JavaScript array and objects are common

6
coding structures used for storing and retrieving information. Data structures are also a crucial
part of designing efficient software.

Importance of data structures

Data structures are essential for managing large amounts of data, such as information kept in
databases or indexing services, efficiently. Proper maintenance of data systems requires the
identification of memory allocation, data interrelationships and data processes, all of which data
structures help with. Additionally, it is not only important to use data structures but it is
important to choose the proper data structure for each task. Choosing an ill-suited data structure
could result in slow runtimes or unresponsive code. A few factors to consider when picking a
data structure include what kind of information will be stored, where should existing data be
placed, how should data be sorted and how much memory should be reserved for the data.

Data structures handle four main functions for us:


 Inputting information
 Processing information
 Maintaining information
 Retrieving information
Inputting is largely concerned with how the data is received.
What kind of information can be included? Will the new data be
added to the beginning, end, or somewhere in the middle of the
existing data? Does an existing point of data need to be
updated or destroyed?

Processing gets at the way that data is manipulated in the data


structure. This can occur concurrently or as a result of other
processes that data structures handle. How does existing data
7
that has been stored need to change to accommodate new,
updated, or removed data?

Maintaining is focused on how the data is organized within the


structure. Which relationships need to be maintained between
pieces of data? How much memory must the system reserve
(allocate) to accommodate the data?
Retrieving is devoted to finding and returning the data that is
stored in the structure. How can we access that information
again? What steps does the data structure need to take to get
the information back to us?

You might also like