Data Structure
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.
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.
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.
Graph
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.
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.