100% found this document useful (1 vote)
397 views26 pages

Introduction of Data Structure - PPT

Data structures allow for the organization and storage of data in a way that supports efficient access and modification. They include linear structures like arrays, linked lists, stacks and queues as well as non-linear structures like trees and graphs. Key operations on data structures include insertion, deletion, and traversal of elements. Selecting an appropriate data structure impacts the performance of programs.

Uploaded by

adhikanshgupta00
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
100% found this document useful (1 vote)
397 views26 pages

Introduction of Data Structure - PPT

Data structures allow for the organization and storage of data in a way that supports efficient access and modification. They include linear structures like arrays, linked lists, stacks and queues as well as non-linear structures like trees and graphs. Key operations on data structures include insertion, deletion, and traversal of elements. Selecting an appropriate data structure impacts the performance of programs.

Uploaded by

adhikanshgupta00
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 26

Introduction of data

Structure
What is Data Structure

 Data Structure is a way of collecting and organizing data in such a way that we
can perform operations on these data effectively

 The data can be managed in various ways, like the logical or mathematical
model for a specific organization of data is known as a data structure.

 Some examples of Data Structures are Arrays, Linked Lists, Stack, Queue, Trees,
etc. Data Structures are widely used in almost every aspect of Computer
Science, i.e., Compiler Design, Operating Systems, Graphics, Artificial
Intelligence, and many more
Need of data structure

 Data Structures support different methods to organize, manage, and store data
efficiently

 With the help of data structure the data items can be traverse easily

 Data Structures provide Efficiency, Reusability, and Abstraction


Basic Terminologies related to Data
Structures
Data Structures are the building blocks of any software or program. Selecting the
suitable data structure for a program is an extremely challenging task for a
programmer.
 some fundamental terminologies used whenever the data structures are
involved:
 Data: We can define data as an elementary value or a collection of values. For
example, the Employee's name and ID are the data related to the Employee.
 Data items: a set of character which are together to represent specific data.
 Record: A collection of different data items are known as a Record. For example,
if we talk about the employee entity, then its name, id, address, and job title can
be grouped to form the record for the employee.
 File: A collection of different Records of one entity type is known as a File. For
example, if there are 100 employees, there will be 25 records in the related file
containing data about each employee.
Continue..

 Entity: An entity is a person , place or event or concepts about which


information recorded.
 Attribute: Attributes gives characteristics or property of entity
 Data value: Data value is a actual data or information contained in each
attribute

Attributes ID Name Gender Job Title

Values 1234 Stacey M. Hill Female Software


Developer
Classification of Data Structures

A Data Structure delivers a structured set of variables related to each other in


various ways. It forms the basis of a programming tool that signifies the
relationship between the data elements and allows programmers to process the
data efficiently.
We can classify Data Structures into two categories:
1. Primitive Data Structure
2. Non-Primitive Data Structure
 The following figure shows the different classifications of Data Structures
Primitive Data Structures

1. Primitive Data Structures are the data structures consisting of the numbers
and the characters that come in-built into programs.

2. These data structures can be manipulated or operated directly by machine-level


instructions.

3. Basic data types like Integer, Float, Character, and Boolean come under the
Primitive Data Structures.

4. These data types are also called Simple data types, as they contain characters
that can't be divided further
Non-Primitive Data Structures

1. Non-Primitive Data Structures are those data structures derived from


Primitive Data Structures.
2. These data structures can't be manipulated or operated directly by
machine-level instructions.
3. The focus of these data structures is on forming a set of data elements
that is either homogeneous (same data type) or heterogeneous (different data
types).
4. Based on the structure and arrangement of data, we can divide these data
structures into two sub-categories -
I. Linear Data Structures
II. Non-Linear Data Structures
Linear Data Structures

 A data structure that preserves a linear connection among its data elements is
known as a Linear Data Structure

 The arrangement of the data is done linearly, where each element consists of
the successors and predecessors except the first and the last data element

 However, it is not necessarily true in the case of memory, as the arrangement


may not be sequential.
Based on memory allocation, the Linear Data Structures are further classified into two types:

1. Static Data Structures: The data structures having a fixed size are known as Static Data
Structures. The memory for these data structures is allocated at the compiler time, and
their size cannot be changed by the user after being compiled; however, the data stored in
them can be altered.
The Array is the best example of the Static Data Structure as they have a fixed size, and its
data can be modified later.

2. Dynamic Data Structures: The data structures having a dynamic size are known as
Dynamic Data Structures. The memory of these data structures is allocated at the run time,
and their size varies during the run time of the code. Moreover, the user can change the
size as well as the data elements stored in these data structures at the run time of the
code.
Linked Lists, Stacks, and Queues are common examples of dynamic data structures
Types of linear data structure

Arrays :
 An array is a collection of similar data elements stored at contiguous memory
locations. It is the simplest data structure where each data element can be
accessed directly by only using its index number.
Linked Lists

A Linked List is another example of a linear data structure used to store a collection of data
elements dynamically.
Data elements in this data structure are represented by the Nodes, connected using links or
pointers.
Each node contains two fields, the information field consists of the actual data, and the pointer
field consists of the address of the subsequent nodes in the list.
The pointer of the last node of the linked list consists of a null pointer, as it points to nothing.
Unlike the Arrays, the user can dynamically adjust the size of a Linked List as per the
requirements.
Stack:
 A Stack is a Linear Data Structure that follows the LIFO (Last In, First Out) principle that
allows operations like insertion and deletion from one end of the Stack, i.e., Top.
 Stacks can be implemented with the help of contiguous memory, an Array, and non-
contiguous memory, a Linked List.
 Real-life examples of Stacks are piles of books, a deck of cards, piles of money, and many
more.

The primary operations in the Stack are as follows:


a. Push: Operation to insert a new element in the Stack is termed as Push Operation.
b. Pop: Operation to remove or delete elements from the Stack is termed as Pop Operation.
Queue:
 A Queue is a linear data structure similar to a Stack with some limitations on the
insertion and deletion of the elements.
 The insertion of an element in a Queue is done at one end, and the removal is
done at another or opposite end.
 Thus, we can conclude that the Queue data structure follows FIFO (First In, First
Out) principle to manipulate the data elements.
 Some real-life examples of Queues are a line at the ticket counter, an escalator, a
car wash, and many more.
Primary operations of the Queue:
a. Enqueue: The insertion or Addition of some data elements to the Queue is called
Enqueue. The element insertion is always done with the help of the rear pointer.
b. Dequeue: Deleting or removing data elements from the Queue is termed Dequeue.
The deletion of the element is always done with the help of the front pointer.
Non Linear Data Structures

 Data structures where data elements are not arranged sequentially or linearly
are called non-linear data structures.
 In a non-linear data structure, single level is not involved. Therefore, we can’t
traverse all the elements in single run only.
 linear data structures are not easy to implement in comparison to linear data
structure.
 It utilizes computer memory efficiently in comparison to a linear data structure.
 Examples are trees and graphs.
Types of Non-Linear Data Structures

The following is the list of Non-Linear Data Structures that we generally use:
1. Tree:
 A Tree is a Non-Linear Data Structure and a hierarchy containing a collection of
nodes such that each node of the tree stores a value and a list of references to
other nodes (the "children").
 Trees can be classified into different types:

• General Tree

• Binary Tree

• Binary Search Tree

• AVL Tree

• Red Black Tree

• N-ary Tree
2. Graphs:
 A graph is a pictorial representation of a set of objects connected by links
known as edges. The interconnected nodes are represented by points named
vertices, and the links that connect the vertices are called edges.
The Graph data structure, G is considered a mathematical structure comprised of
a set of vertices, V and a set of edges, E as shown below:

The above figure represents a Graph having seven vertices A, B, C, D, E, F, G, and


ten edges [A, B], [A, C], [B, C], [B, D], [B, E], [C, D], [D, E], [D, F], [E, F], and [E, G].
Depending upon the position of the vertices and edges, the Graphs can be classified into
different types:

 Null Graph
 Trivial Graph
 Simple Graph
 Multi Graph
 Pseudo Graph
 Non-Directed Graph
 Directed Graph
 Connected Graph
 Disconnected Graph
 Regular Graph
 Complete Graph
 Cycle Graph
 Infinite Graph
 Bipartite Graph
 Planar Graph
 Euler Graph
 Hamiltonian Graph
 Cyclic Graph
 Acyclic Graph
 Finite Graph
Basic Operations of Data Structures
In the following section, we will discuss the different types of operations that we
can perform to manipulate data in every data structure.

 Traversal: Traversing a data structure means accessing each data element


exactly once so it can be administered. For example, traversing is required while
printing the names of all the employees in a department.
 Search: Search is another data structure operation which means to find the
location of one or more data elements that meet certain constraints. Such a
data element may or may not be present in the given set of data elements. For
example, we can use the search operation to find the names of all the
employees who have the experience of more than 5 years.
 Insertion: Insertion means inserting or adding new data elements to the
collection. For example, we can use the insertion operation to add the details of
a new employee the company has recently hired.
 Deletion: Deletion means to remove or delete a specific data element from the
given list of data elements. For example, we can use the deleting operation to
delete the name of an employee who has left the job.
 Sorting: Sorting means to arrange the data elements in either Ascending or
Descending order depending on the type of application. For example, we can
use the sorting operation to arrange the names of employees in a department
in alphabetical order or estimate the top three performers of the month by
arranging the performance of the employees in descending order and
extracting the details of the top three.
 Merge: Merge means to combine data elements of two sorted lists in order to
form a single list of sorted data elements.
 Create: Create is an operation used to reserve memory for the data elements of
the program. We can perform this operation using a declaration statement. The
creation of data structure can take place either during the following:
1. Compile-time
2. Run-time
For example, the malloc() function is used in C Language to create data structure.
 Selection: Selection means selecting a particular data from the available data. We
can select any particular data by specifying conditions inside the loop.

 Update: The Update operation allows us to update or modify the data in the data
structure. We can also update any particular data by specifying some conditions
inside the loop, like the Selection operation.

 Splitting: The Splitting operation allows us to divide data into various subparts
decreasing the overall process completion time.

You might also like