Module 5 - PCD - Data Structure
Module 5 - PCD - Data Structure
Pointers
and
Introduction to
Data Structures
• Introduction to Data Structures:
Primitive and non primitive datatypes,
Definition and applications of Stacks,
Queues, LinkedLists and Trees
C Data Structures
• Data is recorded facts that can be manipulated in
order to produce useful information/results.
• 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 main part of many computer
science algorithms as they enable the programmers
to handle the data in an efficient way. It plays a vital
role in enhancing the performance of a software or a
program as the main function of the software is to
store and retrieve the user's data as fast as possible.
Need of Data Structures
• As applications are getting complexed and amount of data is
increasing day by day, there may arise the following problems:
– Processor speed: To handle very large amout of data, high speed
processing is required, but as the data is growing day by day to the billions
of files per entity, processor may fail to deal with that much amount of
data.
– Data Search: Consider an inventory size of 106 items in a store, If our
application needs to search for a particular item, it needs to traverse 106
items every time, results in slowing down the search process.
– Multiple requests: If thousands of users are searching the data
simultaneously on a web server, then there are the chances that a very
large server can be failed during that process
• in order to solve the above problems, data structures are used.
Data is organized to form a data structure in such a way that all
items are not required to be searched and required data can be
searched instantly.
Advantages of Data Structures
• Efficiency:
– Efficiency of a program depends upon the choice of
data structures. For example: suppose, we have
some data and we need to perform the search for a
perticular record. In that case, if we organize our
data in an array, we will have to search sequentially
element by element. hence, using array may not be
very efficient here. There are better data structures
which can make the search process efficient like
ordered array, binary search tree or hash tables.
Advantages of Data Structures
• Reusability: Data structures are reusable,
i.e. once we have implemented a particular
data structure, we can use it at any other
place. Implementation of data structures
can be compiled into libraries which can be
used by different clients.
Data Structure Classification
Primitive Data structure:
• The primitive data structures are the basic data types
that are available in most of the programming
languages and can be manipulated directly by machine
instructions.
• The primitive data types are used to represent single
values.
• They are
– Integer,
– Float and Double ,
– Character ,
– String
– Boolean
Primitive Data structure:
• Integer: This is used to represent a number without
decimal point.
• Eg: 12, 90
• Float and Double: This is used to represent a number
with decimal point.
• Eg: 45.1, 67.3
• Character : This is used to represent single character
• Eg: ‘C’, ‘a’
• String: This is used to represent group of characters.
• Eg: "New Horizon College of Engineering"
• Boolean: This is used represent logical values either
true or false.
Non-Primitive Data structure
• The data structures that are derived from
primary data types are known as non-Primitive
data types. These data types are used to store
group of values.