SlideShare a Scribd company logo
1 of 51
Presentation on Data Structure
Made By:
Harsh Gupta
Topics We Will Cover in This Slide
1. Arrays
2. Types of Arrays
3. Operations in Arrays
4. Array Of Pointers
5. Concepts Of an Array
6. Linked List
7. Types Of Linked List
8. Operations in Linked List
9. Stacks
10.Stacks Operations
11.Infix Prefix Postfix Conversion (Stack)
Arrays
➢ An Array is a linear data structure which is a finite collection of similar data
items stored in successive or consecutive memory locations.
➢ An array may contain all integer or character elements, but not both.
➢ Each array can be accessed by using array index and it is must be positive
integer value enclosed in square braces. Ex: int arr [5]
➢ Array starts from the numeric value 0 and ends at 1 less than of the index
array value
Types of Array
1. One Dimensional Array
2. Two Dimensional or Multi Dimensional Array
One Dimensional Array
One dimensional array is also called as linear array. It stores the data elements
in single row or columns.
Syntax: <data type> <array name> [Size] = {Values}
Memory Representation of 1-D Array
Two Dimensional Array
➢ A two dimensional array is a collection of elements placed in rows and
columns.
➢ Two subscripts are used to reference an elements in an array of which one
specifies the number of rows and the other specifies number of columns.
Syntax: <data type> <array name> [row size] [column size] = {Values}
Memory Representation of 2-D Array
Operations in Arrays
★ Insertion
★ Deletion
★ Traversel
★ Reversing
★ Sorting
★ Merging
Insertion
1. Insertion is nothing but adding a new element in an array.
1. Here, through a loop, we will shift the numbers from a specific position,
one place to the right of their existing place.
Example
Deletion
1. Deletion is nothing but deleting an element from the array.
1. Here, we will shift the numbers from a specific position from where the
number is to be deleted, one place to the left of their existing place.
Example
Traversal
In traversing operation of an array, each element of an array is accessed
exactly for once for processing.
This is also called visiting of an array.
Example
Reversing
This program reverses the array elements.
For example:
if 'A' is an array of integers with three elements such that
A[0] = 1, A[1] = 2, A[2] = 3 [1, 2, 3]
Then after reversing, the array will be
A[0] = 3, A[1] = 2, A[0] = 1 [3, 2, 1]
Example
Sorting
Sorting means arranging a set of data in some order like ascending or
descending order.
Example
Searching
Searching is the process Of finding the location of an element With a given
element in a list.
Here, searching is start from 0 element And continue the process until the Given
specified number Is found or the end of the list is reached.
Example
Merging
Merging means combining two sorted list into one sorted list.
This involves Two Steps:
➔ sorting the arrays that are to be merged.
➔ adding the sorted elements of both the arrays a2a new array in sorted order.
Example
Array of Pointers
● An array of a pointer is nothing but a Collection of addresses.
● A pointer variable Always contains an addresses.
● The address present in an array of pointer can be address of isolated variables
or even the address of other variables.
● loginAn array of pointers widely used for storing several strings in the array.
● the rules that apply to an ordinary array also applied to an array of pointer as
well.
● the elements of an array of pointer are stored in the memory just like the
elements of any other kind of array.
Important concept of array
1. Array always fixed size of data elements (Declaration)
2. Array can be considered as a static data
3. Array elements are placed in sequential order thus
eliminating the gap in the memory allocation
4. The index value starts with 0
5. The data elements should be of same data type
6. Array can be used in search algorithms (Binary search)
7. Array can be used in sorting algorithms (Bubble sort)
8. An array can be declared, initialized and referred by
value.
Linked list
Linked list is a collection of elements called nodes.
Linked list is a linear Data Structure. Each node contains data part and link
part.
● the data contains elements and
● links contains address of other node.
Node
we can say links as an address
Linked List Representation
➔ Each node carries a data field and a link field called Next
➔ Each node is linked with its next node using next link.
➔ Last node carries a link as null to mark the end of the linked list.
Types of Linked List
1. Singly Linked List
2. Doubly Linked List
3. Circular Linked List
Singly Linked List
A single linked list is one in which all nodes are linked together in some sequential manner.
It contain nodes which have a data part as well as an address part i.e. next which points to
the next node in the sequence of nodes.
The operations in this linked list, we can perform are insertion, deletion and traversal.
Doubly Linked List
Doubly linked list is a variation of linked list in which navigation is possible in both
ways, either forward and backward easily as compared to single linked list.
In a doubly linked list, each node contains a data part and two addresses, one for
the previous note and one for the next node
The Operations in doubly linked list, that we can perform the are insertion deletion
and displaying the linked list
Circular Linked List
Circular Linked List is a variation of Linked List in which the first element point
to the last element and the last element points to the first element. Both singly
or doubly Linked List can be made into a circular linked list.
A circular Linked List is one which has no beginning or no ending. The Null
Pointer in the last node of a linked list is replaced with the address of its first.
Here, all nodes are connected to form a circle.
➢ Singly Linked List As Circular Linked List
In singly linked list, the next pointer of the last node points to the first node.
➢ Doubly Linked List As Circular Linked List
In doubly linked list, the next pointer of the last node points to the first node and
the previous pointer of the first node points to the last node making the circular in
both directions.
Operations in Linked List
➢ Insertion
➢ Deletion
➢ Traversing
Create
head = (node*) malloc (sizeof(node));
head -> data = 20;
head -> next = NULL;
Insert
node* nextnode = malloc(sizeof(node));
nextnode -> data = 22;
nextnode -> next = NULL;
head -> next = nextnode;
Deletion
➢ Delete a node from end
struct node* temp = head;
while(temp->next->next!=NULL)
{
temp = temp->next;
}
temp->next = NULL;
Traversing
struct node *temp = head;
printf("nnList elements are - n");
while(temp != NULL)
{
printf("%d --->",temp->data);
temp = temp->next;
}
Stacks
Stack is an abstract data type with a bounded(predefined) capacity. It is a simple
data structure that allows adding and removing elements in a particular order. Every
time an element is added, it goes on the top of the stack and the only element that
can be removed is the element that is at the top of the stack, just like a pile of
objects.
LIFO (Last In First Out)
Stacks Operations
➢ push()
➢ pop()
➢ peek()
➢ isFull()
➢ isEmpty()
Algorithms for push()
push(int x)
{
if(top >= 10)
{
cout << "Stack Overflow n";
}
else
{
a[++top] = x;
cout << "Element Inserted n";
}
}
❖ Check if the stack is full or not.
❖ If the stack is full, then print error of overflow and exit the program.
❖ If the stack is not full, then increment the top and add the element.
Algorithms for pop()
int pop()
{
if(top < 0)
{
cout << "Stack Underflow n";
return 0;
}
else
{
int d = a[top--];
return d;
}
}
❖ Check if the stack is empty or not.
❖ If the stack is empty, then print error of underflow and exit the program.
❖ If the stack is not empty, then print the element at the top and decrement the top.
Algorithms for isFull()
bool isfull()
{
if(top == MAXSIZE)
return true;
else
return false;
}
Algorithms for isEmpty()
void isEmpty()
{
if(top < 0)
{
cout << "Stack is empty n";
}
else
{
cout << "Stack is not empty n";
}
}
Algorithms for peek()
int peek()
{
return stack[top];
}
➢ It returns the top data element of the stack.
Infix Prefix Postfix Conversion (Stack)
Introduction
Operation:- A + B + C
Operand:- A, B, C, or 1, 2, 3
Operators:- +, -, *, /, etc.
Infix Notation
Infix is the day to day notation that we use of format A + B type.
The general form can be classified as (a op b) where a and b are operands(variables) and
op is Operator.
Examples:-
A + B
A * B + C / D
(A + B) * (C + D)
Prefix Notation
Postfix is notation that compiler uses/converts to while reading left to right and is of format AB+ type.
The general form can be classified as (ab op) where a and b are operands(variables) and op is Operator.
Example:-
AB+
AB*CD/+
* + AB + CD
Postfix Notation
Prefix is notation that compiler uses/converts to while reading right to left and is of format +AB
type.
The general form can be classified as (op ab) where a and b are operands(variables) and op is
Operator.
Examples:-
AB+
AB*CD/+
AB+CD+*
Examples
Thanks!
Contact us:
Harsh Gupta
B. Tech CSE
8764485661
harsh1248gupta@gmail.com

More Related Content

What's hot

Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Poojith Chowdhary
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.pptTirthika Bandi
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#Shahzad
 
Linked list
Linked listLinked list
Linked listVONI
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its typesNavtar Sidhu Brar
 
Data structure &amp; algorithms introduction
Data structure &amp; algorithms introductionData structure &amp; algorithms introduction
Data structure &amp; algorithms introductionSugandh Wafai
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queueRajkiran Nadar
 
Sorting & Linked Lists
Sorting & Linked ListsSorting & Linked Lists
Sorting & Linked ListsJ.T.A.JONES
 
Lecture 3 data structures and algorithms
Lecture 3 data structures and algorithmsLecture 3 data structures and algorithms
Lecture 3 data structures and algorithmsAakash deep Singhal
 
Data Structure Using C
Data Structure Using CData Structure Using C
Data Structure Using Ccpjcollege
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure shameen khan
 

What's hot (20)

Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Data structures & algorithms lecture 3
Data structures & algorithms lecture 3
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.ppt
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#
 
Lecture 2a arrays
Lecture 2a arraysLecture 2a arrays
Lecture 2a arrays
 
Data structure
Data structureData structure
Data structure
 
Data structure ppt
Data structure pptData structure ppt
Data structure ppt
 
Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 
Data structure &amp; algorithms introduction
Data structure &amp; algorithms introductionData structure &amp; algorithms introduction
Data structure &amp; algorithms introduction
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queue
 
Linked list
Linked listLinked list
Linked list
 
Sorting & Linked Lists
Sorting & Linked ListsSorting & Linked Lists
Sorting & Linked Lists
 
Data Structures (BE)
Data Structures (BE)Data Structures (BE)
Data Structures (BE)
 
Data structures using c
Data structures using cData structures using c
Data structures using c
 
Lecture 3 data structures and algorithms
Lecture 3 data structures and algorithmsLecture 3 data structures and algorithms
Lecture 3 data structures and algorithms
 
linked list
linked list linked list
linked list
 
Data structures
Data structuresData structures
Data structures
 
Data Structure Using C
Data Structure Using CData Structure Using C
Data Structure Using C
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 

Similar to Data Structure

Similar to Data Structure (20)

Data structure
Data  structureData  structure
Data structure
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructures
 
DSA UNIT II ARRAY AND LIST - notes
DSA UNIT II ARRAY AND LIST - notesDSA UNIT II ARRAY AND LIST - notes
DSA UNIT II ARRAY AND LIST - notes
 
intr_ds.ppt
intr_ds.pptintr_ds.ppt
intr_ds.ppt
 
Data Structures & Algorithms Unit 1.pptx
Data Structures & Algorithms Unit 1.pptxData Structures & Algorithms Unit 1.pptx
Data Structures & Algorithms Unit 1.pptx
 
Unit - 2.pdf
Unit - 2.pdfUnit - 2.pdf
Unit - 2.pdf
 
3.ppt
3.ppt3.ppt
3.ppt
 
3.ppt
3.ppt3.ppt
3.ppt
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
 
1597380885789.ppt
1597380885789.ppt1597380885789.ppt
1597380885789.ppt
 
unit 5 stack & queue.ppt
unit 5 stack & queue.pptunit 5 stack & queue.ppt
unit 5 stack & queue.ppt
 
Ch 1 intriductions
Ch 1 intriductionsCh 1 intriductions
Ch 1 intriductions
 
هياكلبيانات
هياكلبياناتهياكلبيانات
هياكلبيانات
 
Unit ii(dsc++)
Unit ii(dsc++)Unit ii(dsc++)
Unit ii(dsc++)
 
unit 2.pptx
unit 2.pptxunit 2.pptx
unit 2.pptx
 
Array ppt
Array pptArray ppt
Array ppt
 
Array.pdf
Array.pdfArray.pdf
Array.pdf
 
data structure programing language in c.ppt
data structure programing language in c.pptdata structure programing language in c.ppt
data structure programing language in c.ppt
 
Data structures arrays
Data structures   arraysData structures   arrays
Data structures arrays
 
DS Unit 2.ppt
DS Unit 2.pptDS Unit 2.ppt
DS Unit 2.ppt
 

Recently uploaded

Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 

Recently uploaded (20)

Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 

Data Structure

  • 1. Presentation on Data Structure Made By: Harsh Gupta
  • 2. Topics We Will Cover in This Slide 1. Arrays 2. Types of Arrays 3. Operations in Arrays 4. Array Of Pointers 5. Concepts Of an Array 6. Linked List 7. Types Of Linked List 8. Operations in Linked List 9. Stacks 10.Stacks Operations 11.Infix Prefix Postfix Conversion (Stack)
  • 3. Arrays ➢ An Array is a linear data structure which is a finite collection of similar data items stored in successive or consecutive memory locations. ➢ An array may contain all integer or character elements, but not both. ➢ Each array can be accessed by using array index and it is must be positive integer value enclosed in square braces. Ex: int arr [5] ➢ Array starts from the numeric value 0 and ends at 1 less than of the index array value
  • 4. Types of Array 1. One Dimensional Array 2. Two Dimensional or Multi Dimensional Array
  • 5. One Dimensional Array One dimensional array is also called as linear array. It stores the data elements in single row or columns. Syntax: <data type> <array name> [Size] = {Values}
  • 7. Two Dimensional Array ➢ A two dimensional array is a collection of elements placed in rows and columns. ➢ Two subscripts are used to reference an elements in an array of which one specifies the number of rows and the other specifies number of columns. Syntax: <data type> <array name> [row size] [column size] = {Values}
  • 9. Operations in Arrays ★ Insertion ★ Deletion ★ Traversel ★ Reversing ★ Sorting ★ Merging
  • 10. Insertion 1. Insertion is nothing but adding a new element in an array. 1. Here, through a loop, we will shift the numbers from a specific position, one place to the right of their existing place.
  • 12. Deletion 1. Deletion is nothing but deleting an element from the array. 1. Here, we will shift the numbers from a specific position from where the number is to be deleted, one place to the left of their existing place.
  • 14. Traversal In traversing operation of an array, each element of an array is accessed exactly for once for processing. This is also called visiting of an array.
  • 16. Reversing This program reverses the array elements. For example: if 'A' is an array of integers with three elements such that A[0] = 1, A[1] = 2, A[2] = 3 [1, 2, 3] Then after reversing, the array will be A[0] = 3, A[1] = 2, A[0] = 1 [3, 2, 1]
  • 18. Sorting Sorting means arranging a set of data in some order like ascending or descending order.
  • 20. Searching Searching is the process Of finding the location of an element With a given element in a list. Here, searching is start from 0 element And continue the process until the Given specified number Is found or the end of the list is reached.
  • 22. Merging Merging means combining two sorted list into one sorted list. This involves Two Steps: ➔ sorting the arrays that are to be merged. ➔ adding the sorted elements of both the arrays a2a new array in sorted order.
  • 24. Array of Pointers ● An array of a pointer is nothing but a Collection of addresses. ● A pointer variable Always contains an addresses. ● The address present in an array of pointer can be address of isolated variables or even the address of other variables. ● loginAn array of pointers widely used for storing several strings in the array. ● the rules that apply to an ordinary array also applied to an array of pointer as well. ● the elements of an array of pointer are stored in the memory just like the elements of any other kind of array.
  • 25. Important concept of array 1. Array always fixed size of data elements (Declaration) 2. Array can be considered as a static data 3. Array elements are placed in sequential order thus eliminating the gap in the memory allocation 4. The index value starts with 0 5. The data elements should be of same data type 6. Array can be used in search algorithms (Binary search) 7. Array can be used in sorting algorithms (Bubble sort) 8. An array can be declared, initialized and referred by value.
  • 26. Linked list Linked list is a collection of elements called nodes. Linked list is a linear Data Structure. Each node contains data part and link part. ● the data contains elements and ● links contains address of other node. Node we can say links as an address
  • 27. Linked List Representation ➔ Each node carries a data field and a link field called Next ➔ Each node is linked with its next node using next link. ➔ Last node carries a link as null to mark the end of the linked list.
  • 28. Types of Linked List 1. Singly Linked List 2. Doubly Linked List 3. Circular Linked List
  • 29. Singly Linked List A single linked list is one in which all nodes are linked together in some sequential manner. It contain nodes which have a data part as well as an address part i.e. next which points to the next node in the sequence of nodes. The operations in this linked list, we can perform are insertion, deletion and traversal.
  • 30. Doubly Linked List Doubly linked list is a variation of linked list in which navigation is possible in both ways, either forward and backward easily as compared to single linked list. In a doubly linked list, each node contains a data part and two addresses, one for the previous note and one for the next node The Operations in doubly linked list, that we can perform the are insertion deletion and displaying the linked list
  • 31. Circular Linked List Circular Linked List is a variation of Linked List in which the first element point to the last element and the last element points to the first element. Both singly or doubly Linked List can be made into a circular linked list. A circular Linked List is one which has no beginning or no ending. The Null Pointer in the last node of a linked list is replaced with the address of its first. Here, all nodes are connected to form a circle.
  • 32. ➢ Singly Linked List As Circular Linked List In singly linked list, the next pointer of the last node points to the first node. ➢ Doubly Linked List As Circular Linked List In doubly linked list, the next pointer of the last node points to the first node and the previous pointer of the first node points to the last node making the circular in both directions.
  • 33. Operations in Linked List ➢ Insertion ➢ Deletion ➢ Traversing
  • 34. Create head = (node*) malloc (sizeof(node)); head -> data = 20; head -> next = NULL;
  • 35. Insert node* nextnode = malloc(sizeof(node)); nextnode -> data = 22; nextnode -> next = NULL; head -> next = nextnode;
  • 36. Deletion ➢ Delete a node from end struct node* temp = head; while(temp->next->next!=NULL) { temp = temp->next; } temp->next = NULL;
  • 37. Traversing struct node *temp = head; printf("nnList elements are - n"); while(temp != NULL) { printf("%d --->",temp->data); temp = temp->next; }
  • 38. Stacks Stack is an abstract data type with a bounded(predefined) capacity. It is a simple data structure that allows adding and removing elements in a particular order. Every time an element is added, it goes on the top of the stack and the only element that can be removed is the element that is at the top of the stack, just like a pile of objects.
  • 39. LIFO (Last In First Out)
  • 40. Stacks Operations ➢ push() ➢ pop() ➢ peek() ➢ isFull() ➢ isEmpty()
  • 41. Algorithms for push() push(int x) { if(top >= 10) { cout << "Stack Overflow n"; } else { a[++top] = x; cout << "Element Inserted n"; } } ❖ Check if the stack is full or not. ❖ If the stack is full, then print error of overflow and exit the program. ❖ If the stack is not full, then increment the top and add the element.
  • 42. Algorithms for pop() int pop() { if(top < 0) { cout << "Stack Underflow n"; return 0; } else { int d = a[top--]; return d; } } ❖ Check if the stack is empty or not. ❖ If the stack is empty, then print error of underflow and exit the program. ❖ If the stack is not empty, then print the element at the top and decrement the top.
  • 43. Algorithms for isFull() bool isfull() { if(top == MAXSIZE) return true; else return false; }
  • 44. Algorithms for isEmpty() void isEmpty() { if(top < 0) { cout << "Stack is empty n"; } else { cout << "Stack is not empty n"; } }
  • 45. Algorithms for peek() int peek() { return stack[top]; } ➢ It returns the top data element of the stack.
  • 46. Infix Prefix Postfix Conversion (Stack) Introduction Operation:- A + B + C Operand:- A, B, C, or 1, 2, 3 Operators:- +, -, *, /, etc.
  • 47. Infix Notation Infix is the day to day notation that we use of format A + B type. The general form can be classified as (a op b) where a and b are operands(variables) and op is Operator. Examples:- A + B A * B + C / D (A + B) * (C + D)
  • 48. Prefix Notation Postfix is notation that compiler uses/converts to while reading left to right and is of format AB+ type. The general form can be classified as (ab op) where a and b are operands(variables) and op is Operator. Example:- AB+ AB*CD/+ * + AB + CD
  • 49. Postfix Notation Prefix is notation that compiler uses/converts to while reading right to left and is of format +AB type. The general form can be classified as (op ab) where a and b are operands(variables) and op is Operator. Examples:- AB+ AB*CD/+ AB+CD+*
  • 51. Thanks! Contact us: Harsh Gupta B. Tech CSE 8764485661 harsh1248gupta@gmail.com

Editor's Notes

  1. Of finding the location of an element With a given element in a list. Here, searching is start from 0 element And continue the process until the Given specified number Is found or the end of the list is reached.
  2. Merging means combining two sorted list into one sorted list. This involves Two Steps: sorting the arrays that are to be merged. adding the sorted elements of both the arrays a2a new array in sorted order