SlideShare a Scribd company logo
1 of 33
Download to read offline
Unit 1 – Introduction
to Data Structures
What is a Data Structure?
Data structure is a way of storing and organizing data ef f
i
ciently
such that the required operations on them can be performed be
efficient with respect to time as well as memory.
Simply, Data Structure are used to reduce complexity (mostly the
time complexity) of the code. Data structures can be two types :
1. Static Data Structure
2. Dynamic Data Structure
What is an Abstract Data Type?
Abstract Data Type (ADT) -
1) An opportunity for an acronym
2) Mathematical description of an object and the set of operations on the object
Data Structures : Algorithms
◦
◦
Algorithm
A high level, language independent description of a step-by-step process for solving a problem
Data Structure
A set of algorithms which implement an ADT
Why so many data structures?
◦
◦
◦
◦
Ideal data structure:
fast, elegant, memory efficient
Generates tensions:
timevs. space
performancevs. elegance
generalityvs. simplicity
one operation’s performancevs.
another’s
◦
◦
◦
◦
◦
◦
Dictionary ADT
list
binary search tree
AVL tree
Splay tree
Red-Black tree
hash table
Code Implementation
◦
◦
◦
◦
◦
Theoretically
abstract base class describes ADT
inherited implementations implement data structures
can change data structures transparently (to client code)
Practice
different implementations sometimes suggest different interfaces
(generality
vs . simplicity)
performance of a data structure may influence form of client code
(time
vs . space, one operation
vs . another)
ADT Presentation Algorithm
◦
◦
◦
◦
◦
◦
◦
Present an ADT
Motivate with some applications
Repeat until browned entirely through
develop a data structure for the ADT
analyze its properties
efficiency
correctness
limitations
ease of programming
Contrast data structure’s strengths and weaknesses
understand when to use each one
Static and Dynamic Data Structure
•
•
Static Data Structure vs Dynamic Data Structure
Static data structures, such as arrays, have a fixed size
and are allocated at compile-time.
Dynamic data structures, on the other hand, have a
variable size and are allocated at run-time.
Static Data Structure
In Static data structure the size of the structure is fixed. The content of
the data structure can be modified but without changing the memory
space allocated to it.
Example of Static Data Structures: Array
Dynamic Data Structure
In Dynamic data structure the size of the structure is not fixed and can be
modified during the operations performed on it. Dynamic data structures
are designed to facilitate change of data structures in the run time.
Example of Dynamic Data Structures: Linked List
Static and Dynamic Data Structure
Aspect Static Data Structure Dynamic Data Structure
Memory allocation
Memory is allocated at compile-
time
Memory is allocated at run-time
Size
Size is fixed and cannot be
modified
Size can be modified during
runtime
Memory utilization
Memory utilization may be
inefficient
Memory utilization is efficient as
memory can be reused
Access Access time is faster as it is fixed
Access time may be slower due
to indexing and pointer usage
Examples
Arrays, Stacks, Queues, Trees
(with fixed size)
Lists, Trees (with variable size),
Hash tables
Operations on Data Structures




There are different types of operations that can be performed for the
manipulation of data in every data structure. Some operations are
explained and illustrated below:
Traversing
Searching
Insertion
Deletion
Other methods for operations.
Create, select, update, sort, merge, split data
Traversing Data Structure
Traversing a Data Structure means to visit the element stored in it. It
visits data in a systematic manner. This can be done with any type of DS.
int main()
{
// Initialise array
int arr[] = { 1, 2, 3, 4 };
// size of array
int N = sizeof(arr) / sizeof(arr[0]);
// Traverse the element of arr[]
for (int i = 0; i  N; i++) {
// Print the element
cout  arr[i]  ' ';
}
return 0;
}
Searching Data Structure
Searching means to find a particular element in the given data-structure.
It is considered as successful when the required element is found.
Searching is the operation which we can performed on data-structures
like array, linked-list, tree, graph, etc.
for (int i = 0; i  N; i++) {
// If Element is present then
// print the index and return
if (arr[i] == K) {
cout  Element found!;
return;
}
}
cout  Element Not found!;
}
Insertion Data Structure
It is the operation which we apply on all the data-structures.
Insertion means to add an element in the given data structure.
The operation of insertion is successful when the required
element is added to the required data-structure.
It is unsuccessful in some cases when the size of the data
structure is full and when there is no space in the data-structure
to add any additional element.
The insertion has the same name as an insertion in the data-
structure as an array, linked-list, graph, tree. In stack, this
operation is called Push. In the queue, this operation is called
Enqueue.
Insertion Data Structure
int main()
{
// Initialise array
int arr[4];
// size of array
int N = 4;
// Insert elements in array
for (int i = 1; i  5; i++) {
arr[i - 1] = i;
}
// Print array element
printArray(arr, N);
return 0;
}
Deletion Data Structure
It is the operation which we apply on all the data-structures.
Deletion means to delete an element in the given data structure.
The operation of deletion is successful when the required
element is deleted from the data structure.
The deletion has the same name as a deletion in the data-
structure as an array, linked-list, graph, tree, etc.
In stack, this operation is called Pop. In Queue this operation is
called Dequeue.
Other methods for Data Structures






Create
Select
Update
Sort
Merge
Split
Types of Data Structures


Linear
Data structure where data elements are arranged
sequentially or linearly where each and every element is
attached to its previous and next adjacent
Non Linear
Data structures where data elements are not arranged
sequentially or linearly are called non-linear data structures
Linear Data Structures




Array
The array is a type of data structure that stores elements of the same type. These are the
most basic and fundamental data structures
Stack
The data structure follows the rule of LIFO (Last In-First Out) where the data last added
element is removed first.
Queue
This structure is almost similar to the stack as the data is stored sequentially. The difference
is that the queue data structure follows FIFO which is the rule of First In-First Out
Linked List
Linked lists are the types where the data is stored in the form of nodes which consist of an
element of data and a pointer.
Non Linear Data Structure


Trees
A tree data structure consists of various nodes linked together. The structure of a tree is
hierarchical that forms a relationship like that of the parent and a child.
Graphs
Graphs are those types of non-linear data structures which consist of a definite quantity
of vertices and edges.
Linear and Non Linear Data
Structures
Linear Data Structures Non Linear Data Structures
1.
In a linear data structure, data elements are
arranged in a linear order where each and every
element is attached to its previous and next
adjacent.
In a non-linear data structure, data elements
are attached in hierarchically manner.
2. In linear data structure, single level is involved.
Whereas in non-linear data structure, multiple
levels are involved.
3.
Its implementation is easy in comparison to non-
linear data structure.
While its implementation is complex in
comparison to linear data structure.
4.
In linear data structure, data elements can be
traversed in a single run only.
While in non-linear data structure, data
elements can’t be traversed in a single run only.
Linear Data Structure Non Linear Data Structure
5.
In a linear data structure, memory is not
utilized in an efficient way.
While in a non-linear data structure, memory is
utilized in an efficient way. 
6.
Its examples are: array, stack, queue, linked
list, etc.
While its examples are: trees and graphs.
7.
Applications of linear data structures are
mainly in application software development.
Applications of non-linear data structures are in
Artificial Intelligence and image processing.
8.
Linear data structures are useful for simple
data storage and manipulation.
Non-linear data structures are useful for
representing complex relationships and data
hierarchies, such as in social networks, file
systems, or computer networks.
9.
Performance is usually good for simple
operations like adding or removing at the
ends, but slower for operations like searching
or removing elements in the middle.
Performance can vary depending on the
structure and the operation, but can be
optimized for specific operations.
Data Structure and Data Type
Data Type is the kind or form of a variable which is being used
throughout the program. It defines that the particular variable
will assign the values of the given data type only
Data Structure is the collection of different kinds of data. That
entire data can be represented using an object and can be used
throughout the entire program.
Data Structure and a Data Type
Data Types Data Structures
Implementation through Data Types is a form of
abstract implementation
Implementation through Data Structures is called
concrete implementation
Can hold values and not data, so it is data less
Can hold different kind and types of data within one
single object
Values can directly be assigned to the data type
variables
The data is assigned to the data structure object
using some set of algorithms and operations like
push, pop and so on.
No problem of time complexity
Time complexity comes into play when working with
data structures
Examples: int, float, double Examples: stacks, queues, tree
How to analyze the programs
There are many criteria upon which we can judge a program, for instance:
(i) Does it do what we want it to do?
(ii) Does it work correctly according to the original specifications of the
task?
(iii) Is there documentation which describes how to use it and how it
works?
(iv) Are subroutines created in such a way that they perform logical sub-
functions?
(v) Is the code readable?
Introduction to algorithm


An algorithm is any well-defined computational procedure
that takes some value, or set of values, as input and
produces some value, or set of values, as output.
An algorithm as a tool for solving a well-specified
computational problem
Asymptotic Notation
1.
2.
3.
The main idea of asymptotic analysis is to have a measure of
the efficiency of algorithms that don’t depend on machine-
specific constants and don’t require algorithms to be
implemented and time taken by programs to be compared.
There are mainly three asymptotic notations:
Big-O Notation (O-notation)
Omega Notation (Ω-notation)
Theta Notation (Θ-notation)
Big O Notation
Big-O notation represents the upper
bound of the running time of an algorithm.
Therefore, it gives the worst-case
complexity of an algorithm.
If f(n) describes the running time of an
algorithm, f(n) is O(g(n)) if there exist a
positive constant C and n0 such that, 0 ≤
f(n) ≤ cg(n) for all n ≥ n0
It returns the highest possible output
value (big-O)for a given input.
Omega Notation
Omega notation represents the lower
bound of the running time of an
algorithm. Thus, it provides the best
case complexity of an algorithm.
The execution time serves as a lower
bound on the algorithm’s time
complexity.
It is defined as the condition that
allows an algorithm to complete
statement execution in the shortest
amount of time.
Theta Notation
Theta notation encloses the function
fro m abo v e and be l o w. Si nc e i t
represents the upper and the lower
bound of the running time of an
algorithm, it is used for analyzing the
average-case complexity of an algorithm.
The execution time serves as both a
l o w e r a n d u p p e r b o u n d o n t h e
algorithm’s time complexity.
It exist as both, most, and least
boundaries for a given input value.
Time Complexity and Space
Complexity
Time Complexity:
The time complexity of an algorithm quantifies the amount of time taken
by an algorithm to run as a function of the length of the input
Space Complexity:
Problem-solving using computer requires memory to hold temporary data
or final result while the program is in execution. The amount of memory
required by the algorithm to solve given problem is called space
complexity of the algorithm.
Analysis of Algorithm





Time Efficiency — Indicates how fasts algorithm runs
Space Efficiency — How much extra memory the algorithm
needs to complete its execution
Simplicity — Generating sequence of instructions which are
easy to understand
Generality — Range of inputs it can accept .

More Related Content

Similar to Unit.1 Introduction to Data Structuresres

Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data Structurechouguleamruta24
 
Data structure (basics)
Data structure (basics)Data structure (basics)
Data structure (basics)ShrushtiGole
 
Data Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxData Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxmexiuro901
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structureadeel hamid
 
introduction about data structure_i.pptx
introduction about data structure_i.pptxintroduction about data structure_i.pptx
introduction about data structure_i.pptxpoonamsngr
 
data structure is a storage that is used to store and organize data .pptx
data structure is a storage that is used to store and organize data .pptxdata structure is a storage that is used to store and organize data .pptx
data structure is a storage that is used to store and organize data .pptxVicky Singh
 
DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS Adams Sidibe
 
Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...Tutort Academy
 
Data structures - Introduction
Data structures - IntroductionData structures - Introduction
Data structures - IntroductionDeepaThirumurugan
 
DS-UNIT 1 FINAL (2).pptx
DS-UNIT 1 FINAL (2).pptxDS-UNIT 1 FINAL (2).pptx
DS-UNIT 1 FINAL (2).pptxprakashvs7
 
Data Structures_Introduction
Data Structures_IntroductionData Structures_Introduction
Data Structures_IntroductionThenmozhiK5
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structuresunilchute1
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structuresunilchute1
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfAxmedcarb
 

Similar to Unit.1 Introduction to Data Structuresres (20)

Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data Structure
 
UNIT II.docx
UNIT II.docxUNIT II.docx
UNIT II.docx
 
Ch1
Ch1Ch1
Ch1
 
Data structure (basics)
Data structure (basics)Data structure (basics)
Data structure (basics)
 
Data Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxData Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptx
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Data structure
Data structureData structure
Data structure
 
introduction about data structure_i.pptx
introduction about data structure_i.pptxintroduction about data structure_i.pptx
introduction about data structure_i.pptx
 
data structure is a storage that is used to store and organize data .pptx
data structure is a storage that is used to store and organize data .pptxdata structure is a storage that is used to store and organize data .pptx
data structure is a storage that is used to store and organize data .pptx
 
DSA - Copy.pptx
DSA - Copy.pptxDSA - Copy.pptx
DSA - Copy.pptx
 
DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS
 
104333 sri vidhya eng notes
104333 sri vidhya eng notes104333 sri vidhya eng notes
104333 sri vidhya eng notes
 
Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...
 
Data structures - Introduction
Data structures - IntroductionData structures - Introduction
Data structures - Introduction
 
DS-UNIT 1 FINAL (2).pptx
DS-UNIT 1 FINAL (2).pptxDS-UNIT 1 FINAL (2).pptx
DS-UNIT 1 FINAL (2).pptx
 
Data Structures_Introduction
Data Structures_IntroductionData Structures_Introduction
Data Structures_Introduction
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 

Recently uploaded

Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service PuneVIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service PuneCall girls in Ahmedabad High profile
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024APNIC
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirtrahman018755
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Complet Documnetation for Smart Assistant Application for Disabled Person
Complet Documnetation   for Smart Assistant Application for Disabled PersonComplet Documnetation   for Smart Assistant Application for Disabled Person
Complet Documnetation for Smart Assistant Application for Disabled Personfurqan222004
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一Fs
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebJames Anderson
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 

Recently uploaded (20)

Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service PuneVIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
Vip Call Girls Aerocity ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Aerocity ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Aerocity ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Aerocity ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Complet Documnetation for Smart Assistant Application for Disabled Person
Complet Documnetation   for Smart Assistant Application for Disabled PersonComplet Documnetation   for Smart Assistant Application for Disabled Person
Complet Documnetation for Smart Assistant Application for Disabled Person
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
 
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
 

Unit.1 Introduction to Data Structuresres

  • 1. Unit 1 – Introduction to Data Structures
  • 2. What is a Data Structure? Data structure is a way of storing and organizing data ef f i ciently such that the required operations on them can be performed be efficient with respect to time as well as memory. Simply, Data Structure are used to reduce complexity (mostly the time complexity) of the code. Data structures can be two types : 1. Static Data Structure 2. Dynamic Data Structure
  • 3. What is an Abstract Data Type? Abstract Data Type (ADT) - 1) An opportunity for an acronym 2) Mathematical description of an object and the set of operations on the object
  • 4. Data Structures : Algorithms ◦ ◦ Algorithm A high level, language independent description of a step-by-step process for solving a problem Data Structure A set of algorithms which implement an ADT
  • 5. Why so many data structures? ◦ ◦ ◦ ◦ Ideal data structure: fast, elegant, memory efficient Generates tensions: timevs. space performancevs. elegance generalityvs. simplicity one operation’s performancevs. another’s ◦ ◦ ◦ ◦ ◦ ◦ Dictionary ADT list binary search tree AVL tree Splay tree Red-Black tree hash table
  • 6. Code Implementation ◦ ◦ ◦ ◦ ◦ Theoretically abstract base class describes ADT inherited implementations implement data structures can change data structures transparently (to client code) Practice different implementations sometimes suggest different interfaces (generality vs . simplicity) performance of a data structure may influence form of client code (time vs . space, one operation vs . another)
  • 7. ADT Presentation Algorithm ◦ ◦ ◦ ◦ ◦ ◦ ◦ Present an ADT Motivate with some applications Repeat until browned entirely through develop a data structure for the ADT analyze its properties efficiency correctness limitations ease of programming Contrast data structure’s strengths and weaknesses understand when to use each one
  • 8. Static and Dynamic Data Structure • • Static Data Structure vs Dynamic Data Structure Static data structures, such as arrays, have a fixed size and are allocated at compile-time. Dynamic data structures, on the other hand, have a variable size and are allocated at run-time.
  • 9. Static Data Structure In Static data structure the size of the structure is fixed. The content of the data structure can be modified but without changing the memory space allocated to it. Example of Static Data Structures: Array
  • 10. Dynamic Data Structure In Dynamic data structure the size of the structure is not fixed and can be modified during the operations performed on it. Dynamic data structures are designed to facilitate change of data structures in the run time. Example of Dynamic Data Structures: Linked List
  • 11. Static and Dynamic Data Structure Aspect Static Data Structure Dynamic Data Structure Memory allocation Memory is allocated at compile- time Memory is allocated at run-time Size Size is fixed and cannot be modified Size can be modified during runtime Memory utilization Memory utilization may be inefficient Memory utilization is efficient as memory can be reused Access Access time is faster as it is fixed Access time may be slower due to indexing and pointer usage Examples Arrays, Stacks, Queues, Trees (with fixed size) Lists, Trees (with variable size), Hash tables
  • 12. Operations on Data Structures     There are different types of operations that can be performed for the manipulation of data in every data structure. Some operations are explained and illustrated below: Traversing Searching Insertion Deletion Other methods for operations. Create, select, update, sort, merge, split data
  • 13. Traversing Data Structure Traversing a Data Structure means to visit the element stored in it. It visits data in a systematic manner. This can be done with any type of DS. int main() { // Initialise array int arr[] = { 1, 2, 3, 4 }; // size of array int N = sizeof(arr) / sizeof(arr[0]); // Traverse the element of arr[] for (int i = 0; i N; i++) { // Print the element cout arr[i] ' '; } return 0; }
  • 14. Searching Data Structure Searching means to find a particular element in the given data-structure. It is considered as successful when the required element is found. Searching is the operation which we can performed on data-structures like array, linked-list, tree, graph, etc. for (int i = 0; i N; i++) { // If Element is present then // print the index and return if (arr[i] == K) { cout Element found!; return; } } cout Element Not found!; }
  • 15. Insertion Data Structure It is the operation which we apply on all the data-structures. Insertion means to add an element in the given data structure. The operation of insertion is successful when the required element is added to the required data-structure. It is unsuccessful in some cases when the size of the data structure is full and when there is no space in the data-structure to add any additional element. The insertion has the same name as an insertion in the data- structure as an array, linked-list, graph, tree. In stack, this operation is called Push. In the queue, this operation is called Enqueue.
  • 16. Insertion Data Structure int main() { // Initialise array int arr[4]; // size of array int N = 4; // Insert elements in array for (int i = 1; i 5; i++) { arr[i - 1] = i; } // Print array element printArray(arr, N); return 0; }
  • 17. Deletion Data Structure It is the operation which we apply on all the data-structures. Deletion means to delete an element in the given data structure. The operation of deletion is successful when the required element is deleted from the data structure. The deletion has the same name as a deletion in the data- structure as an array, linked-list, graph, tree, etc. In stack, this operation is called Pop. In Queue this operation is called Dequeue.
  • 18. Other methods for Data Structures       Create Select Update Sort Merge Split
  • 19. Types of Data Structures   Linear Data structure where data elements are arranged sequentially or linearly where each and every element is attached to its previous and next adjacent Non Linear Data structures where data elements are not arranged sequentially or linearly are called non-linear data structures
  • 20. Linear Data Structures     Array The array is a type of data structure that stores elements of the same type. These are the most basic and fundamental data structures Stack The data structure follows the rule of LIFO (Last In-First Out) where the data last added element is removed first. Queue This structure is almost similar to the stack as the data is stored sequentially. The difference is that the queue data structure follows FIFO which is the rule of First In-First Out Linked List Linked lists are the types where the data is stored in the form of nodes which consist of an element of data and a pointer.
  • 21. Non Linear Data Structure   Trees A tree data structure consists of various nodes linked together. The structure of a tree is hierarchical that forms a relationship like that of the parent and a child. Graphs Graphs are those types of non-linear data structures which consist of a definite quantity of vertices and edges.
  • 22. Linear and Non Linear Data Structures Linear Data Structures Non Linear Data Structures 1. In a linear data structure, data elements are arranged in a linear order where each and every element is attached to its previous and next adjacent. In a non-linear data structure, data elements are attached in hierarchically manner. 2. In linear data structure, single level is involved. Whereas in non-linear data structure, multiple levels are involved. 3. Its implementation is easy in comparison to non- linear data structure. While its implementation is complex in comparison to linear data structure. 4. In linear data structure, data elements can be traversed in a single run only. While in non-linear data structure, data elements can’t be traversed in a single run only.
  • 23. Linear Data Structure Non Linear Data Structure 5. In a linear data structure, memory is not utilized in an efficient way. While in a non-linear data structure, memory is utilized in an efficient way. 6. Its examples are: array, stack, queue, linked list, etc. While its examples are: trees and graphs. 7. Applications of linear data structures are mainly in application software development. Applications of non-linear data structures are in Artificial Intelligence and image processing. 8. Linear data structures are useful for simple data storage and manipulation. Non-linear data structures are useful for representing complex relationships and data hierarchies, such as in social networks, file systems, or computer networks. 9. Performance is usually good for simple operations like adding or removing at the ends, but slower for operations like searching or removing elements in the middle. Performance can vary depending on the structure and the operation, but can be optimized for specific operations.
  • 24. Data Structure and Data Type Data Type is the kind or form of a variable which is being used throughout the program. It defines that the particular variable will assign the values of the given data type only Data Structure is the collection of different kinds of data. That entire data can be represented using an object and can be used throughout the entire program.
  • 25. Data Structure and a Data Type Data Types Data Structures Implementation through Data Types is a form of abstract implementation Implementation through Data Structures is called concrete implementation Can hold values and not data, so it is data less Can hold different kind and types of data within one single object Values can directly be assigned to the data type variables The data is assigned to the data structure object using some set of algorithms and operations like push, pop and so on. No problem of time complexity Time complexity comes into play when working with data structures Examples: int, float, double Examples: stacks, queues, tree
  • 26. How to analyze the programs There are many criteria upon which we can judge a program, for instance: (i) Does it do what we want it to do? (ii) Does it work correctly according to the original specifications of the task? (iii) Is there documentation which describes how to use it and how it works? (iv) Are subroutines created in such a way that they perform logical sub- functions? (v) Is the code readable?
  • 27. Introduction to algorithm   An algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output. An algorithm as a tool for solving a well-specified computational problem
  • 28. Asymptotic Notation 1. 2. 3. The main idea of asymptotic analysis is to have a measure of the efficiency of algorithms that don’t depend on machine- specific constants and don’t require algorithms to be implemented and time taken by programs to be compared. There are mainly three asymptotic notations: Big-O Notation (O-notation) Omega Notation (Ω-notation) Theta Notation (Θ-notation)
  • 29. Big O Notation Big-O notation represents the upper bound of the running time of an algorithm. Therefore, it gives the worst-case complexity of an algorithm. If f(n) describes the running time of an algorithm, f(n) is O(g(n)) if there exist a positive constant C and n0 such that, 0 ≤ f(n) ≤ cg(n) for all n ≥ n0 It returns the highest possible output value (big-O)for a given input.
  • 30. Omega Notation Omega notation represents the lower bound of the running time of an algorithm. Thus, it provides the best case complexity of an algorithm. The execution time serves as a lower bound on the algorithm’s time complexity. It is defined as the condition that allows an algorithm to complete statement execution in the shortest amount of time.
  • 31. Theta Notation Theta notation encloses the function fro m abo v e and be l o w. Si nc e i t represents the upper and the lower bound of the running time of an algorithm, it is used for analyzing the average-case complexity of an algorithm. The execution time serves as both a l o w e r a n d u p p e r b o u n d o n t h e algorithm’s time complexity. It exist as both, most, and least boundaries for a given input value.
  • 32. Time Complexity and Space Complexity Time Complexity: The time complexity of an algorithm quantifies the amount of time taken by an algorithm to run as a function of the length of the input Space Complexity: Problem-solving using computer requires memory to hold temporary data or final result while the program is in execution. The amount of memory required by the algorithm to solve given problem is called space complexity of the algorithm.
  • 33. Analysis of Algorithm     Time Efficiency — Indicates how fasts algorithm runs Space Efficiency — How much extra memory the algorithm needs to complete its execution Simplicity — Generating sequence of instructions which are easy to understand Generality — Range of inputs it can accept .