SlideShare a Scribd company logo
STACK
Introduction to Array
An array is defined as a set of finite number of homogeneous
elements or same data items.
It means an array can contain one type of data only, either all
integer, all float-point number or all character.
Simply, declaration of array is as follows: int arr[10] ;
Where int specifies the data type or type of elements arrays
stores.
“arr” is the name of array & the number specified inside the
square brackets is the number of elements an array can store,
this is also called sized or length of array.
Introduction to Array
The elements of array will always be stored in the consecutive
(continues) memory location.
The number of elements that can be stored in an array, that is the
size of array or its length is given by the following equation:
(Upperbound-lowerbound)+1
For the above array it would be (9-0)+1=10,where 0 is the lower
bound of array and 9 is the upper bound of array.
Array can always be read or written through loop.
for(i=0;i<=9;i++)
{
scanf(“%d”,&arr[i]);
printf(“%d”,arr[i]);
}
Representation of One
Dimensional Array
An array with only one row or column is called one-dimensional
array.
It is finite collection of n number of elements of same type such
that:
◦ can be referred by indexing.
◦ The Elements are stored in continuous locations.
Syntax: Datatype Array_Name [Size];
Where,
Datatype : Type of value it can store (Example: int, char, float)
Array_Name: To identify the array.
Size : The maximum number of elements that an array can hold.
Initializing One Dimensional Array
An array can also be created by specifying the
size and assigning array elements at the time
of declaration.
Syntax for initialization:
int arr[10]= {2,4,6,7,5,8};
char word[5]= {‘h’, ‘e’, ‘l’, ‘l’, ‘o’};
Write program to show use of initializers.
Accessing One Dimensional Array
Elements
Individual element of array can be accessed using the
following syntax:
array_name[index];
e.g., to assign a value to second location of the array,
arr[1]=90;
Similarly to read a particular value,
scanf(“%d”, &arr[2]);
Above statement reads a value from keyboard and assigns
it to third location of the array.
Write a program to illustrate reading and writing of the
array.
Memory Allocation of Array
The elements of linear array are stored in consecutive
memory locations. It is shown below:
Address of element a[k]=B + w * k
Arrays types
Single Dimension Array
◦ Array with one subscript
Two Dimension Array
◦ Array with two subscripts (Rows and Column)
Multi Dimension Array
◦ Array with Multiple subscripts
Initializing Two Dimensional Array
An array can also be created by specifying the
size and assigning array elements at the time
of declaration.
Syntax for initialization:
int arr[3][3]= {2,4,6,7,5,8,9,3,1};
Write program to show use of initializers.
Accessing Two Dimensional Array
Elements
Individual element of array can be accessed using the following
syntax:
array_name[row_index][col_index];
e.g., to assign a value to first row and first column location
of the array,
arr[0][0]=9;
Similarly to read a particular value,
scanf(“%d”, &arr[1][0]);
Above statement reads a value from keyboard and assigns it to
second row and first column location of the array.
Write a program to illustrate reading and writing of the 2-D
array.
Basic operations of Arrays
Some common operation performed on array are:
◦ Traversing
◦ Searching
◦ Insertion
◦ Deletion
◦ Sorting
◦ Merging
STACK
• Common Example :
• Suppose at your home you have multiple chairs then you put them
together to form a vertical pile. From that vertical pile the chair which is
placed last is always removed first.
Chair which was placed first is removed last. In this way we can see how
stack is related to us.
What is Stack ?
• Stack is used as Linear data structure which can be
accessed from only one end .
• Stack is LIFO Structure [ Last in First Out ]
• Stack is Ordered List of Elements of Same Type.
• Stack is Linear List
• In Stack all Operations such as Insertion and
Deletion are permitted at only one end called Top
Visual Representation of Stack :
• View 1 : When Stack is Empty
When Stack is said to empty then it does not contain any element inside it.
Whenever the Stack is Empty the position of topmost element is -1.
• View 2 : When Stack is Not Empty
• Whenever we add very first element then topmost position will be
incremented by 1. After adding First Element top = 0.
• View 3 :
• After Deletion of 1 Element Top Will be Decremented by 1
Array Representation of Stack in C Programming :
• 1-D array is used to hold the element of the
stack.
• Variable “top” keeps track of “Topmost”
Element in the stack.
• “MAX” is used as Constant which gives
maximum size of Stack.
Linear Data Structures, array, stack, queue
Operations on Stack
Representation of Stack in Memory The stack

•PUSH:
It adds a new element to the top of the stack.
After every push operation top of stack incremented by
one.
If stack is full no new element can be accommodated, this
condition is called stack overflow or stack is full.
PUSH operation on stack
Operations on Stack
Representation of Stack in Memory The stack

•POP: I
It removes the top element from the stack.):
After every pop operation top of stack decremented by
one.
If stack is empty and pop operation performed this will
result into stack underflow condition or stack empty.
he stack
POP operation on stack
APPLICATION OF THE STACK
1. Mathematical Expression Evaluation
2. Calculation of Postfix Expression
3. Expression conversion
a.Infix to Postfix.
b.Infix to Prefix.
c.Postfix to Infix.
d.Prefix to Infix.
4. Function call and recursion
5. Stack frame
6. Reversing a String

More Related Content

PPTX
Data Structure
PDF
Unit ii data structure-converted
PDF
Introduction to Arrays in C
PPTX
17-Arrays-And-Files-kkkkkkkkkkkkkkk.pptx
PPTX
Stack and Queue
PDF
02 arrays
PPTX
TMK_DSA_Unit 2 part1(array and stack).pptx
PPTX
Unit 6. Arrays
Data Structure
Unit ii data structure-converted
Introduction to Arrays in C
17-Arrays-And-Files-kkkkkkkkkkkkkkk.pptx
Stack and Queue
02 arrays
TMK_DSA_Unit 2 part1(array and stack).pptx
Unit 6. Arrays

Similar to Linear Data Structures, array, stack, queue (20)

PPSX
C Programming : Arrays
PDF
Homework Assignment – Array Technical DocumentWrite a technical .pdf
DOC
Arrays and Strings
PPTX
object oriented programing in python and pip
PPTX
Arrays in Data Structure and Algorithm
PPT
intr_ds.ppt
PPTX
Programming in c Arrays
PPTX
Chapter-Five.pptx
PPTX
Arrays in C.pptx
PDF
Array and its types and it's implemented programming Final.pdf
PDF
Arrays-Computer programming
PDF
PPTX
Array,string structures. Best presentation pptx
PPT
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
PPTX
Unit4pptx__2024_11_ 11_10_16_09.pptx
PDF
ARRAYS
PPTX
data structures study meterial array and sparse matric
PPTX
data structures array and sparse matrics
C Programming : Arrays
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Arrays and Strings
object oriented programing in python and pip
Arrays in Data Structure and Algorithm
intr_ds.ppt
Programming in c Arrays
Chapter-Five.pptx
Arrays in C.pptx
Array and its types and it's implemented programming Final.pdf
Arrays-Computer programming
Array,string structures. Best presentation pptx
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
Unit4pptx__2024_11_ 11_10_16_09.pptx
ARRAYS
data structures study meterial array and sparse matric
data structures array and sparse matrics
Ad

More from Minakshee Patil (18)

PPTX
Introduction, characteristics, Pseudocode.pptx
PPTX
0-1_knapsack_using_Dynamic Programming.pptx
PPTX
Introduction to Computational Complexity Theory pptx
PPTX
Different Searching and Sorting Methods.pptx
PPTX
Analysis of Algorithms (1).pptx, asymptotic
PPTX
0-1_knapsack_using_DP, types of knapsack
PPTX
Unit 5-BACKTRACKING- n queens, sum of subset, graph coloring problems
PPT
stack, opeartions on stack, applications of stack
PPTX
Algorithm Design Techiques, divide and conquer
PPTX
Analysis of Algorithms, recurrence relation, solving recurrences
PPT
Lecture2 (9).ppt
PPTX
oracle.pptx
PPT
Lecture1.ppt
PPT
Unit 1.ppt
PPTX
Hierarchical clustering algorithm.pptx
PPT
Lecture2 (1).ppt
PPT
Lecture3 (3).ppt
PPT
Lecture4.ppt
Introduction, characteristics, Pseudocode.pptx
0-1_knapsack_using_Dynamic Programming.pptx
Introduction to Computational Complexity Theory pptx
Different Searching and Sorting Methods.pptx
Analysis of Algorithms (1).pptx, asymptotic
0-1_knapsack_using_DP, types of knapsack
Unit 5-BACKTRACKING- n queens, sum of subset, graph coloring problems
stack, opeartions on stack, applications of stack
Algorithm Design Techiques, divide and conquer
Analysis of Algorithms, recurrence relation, solving recurrences
Lecture2 (9).ppt
oracle.pptx
Lecture1.ppt
Unit 1.ppt
Hierarchical clustering algorithm.pptx
Lecture2 (1).ppt
Lecture3 (3).ppt
Lecture4.ppt
Ad

Recently uploaded (20)

PPTX
AgentX UiPath Community Webinar series - Delhi
PPT
Project quality management in manufacturing
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
PDF
Geotechnical Engineering, Soil mechanics- Soil Testing.pdf
PDF
ETO & MEO Certificate of Competency Questions and Answers
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPT
Chapter 6 Design in software Engineeing.ppt
PDF
Structs to JSON How Go Powers REST APIs.pdf
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
composite construction of structures.pdf
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
Practice Questions on recent development part 1.pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
AgentX UiPath Community Webinar series - Delhi
Project quality management in manufacturing
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
Geotechnical Engineering, Soil mechanics- Soil Testing.pdf
ETO & MEO Certificate of Competency Questions and Answers
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Chapter 6 Design in software Engineeing.ppt
Structs to JSON How Go Powers REST APIs.pdf
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
bas. eng. economics group 4 presentation 1.pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
composite construction of structures.pdf
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Practice Questions on recent development part 1.pptx
Model Code of Practice - Construction Work - 21102022 .pdf
Fluid Mechanics, Module 3: Basics of Fluid Mechanics

Linear Data Structures, array, stack, queue

  • 2. Introduction to Array An array is defined as a set of finite number of homogeneous elements or same data items. It means an array can contain one type of data only, either all integer, all float-point number or all character. Simply, declaration of array is as follows: int arr[10] ; Where int specifies the data type or type of elements arrays stores. “arr” is the name of array & the number specified inside the square brackets is the number of elements an array can store, this is also called sized or length of array.
  • 3. Introduction to Array The elements of array will always be stored in the consecutive (continues) memory location. The number of elements that can be stored in an array, that is the size of array or its length is given by the following equation: (Upperbound-lowerbound)+1 For the above array it would be (9-0)+1=10,where 0 is the lower bound of array and 9 is the upper bound of array. Array can always be read or written through loop. for(i=0;i<=9;i++) { scanf(“%d”,&arr[i]); printf(“%d”,arr[i]); }
  • 4. Representation of One Dimensional Array An array with only one row or column is called one-dimensional array. It is finite collection of n number of elements of same type such that: ◦ can be referred by indexing. ◦ The Elements are stored in continuous locations. Syntax: Datatype Array_Name [Size]; Where, Datatype : Type of value it can store (Example: int, char, float) Array_Name: To identify the array. Size : The maximum number of elements that an array can hold.
  • 5. Initializing One Dimensional Array An array can also be created by specifying the size and assigning array elements at the time of declaration. Syntax for initialization: int arr[10]= {2,4,6,7,5,8}; char word[5]= {‘h’, ‘e’, ‘l’, ‘l’, ‘o’}; Write program to show use of initializers.
  • 6. Accessing One Dimensional Array Elements Individual element of array can be accessed using the following syntax: array_name[index]; e.g., to assign a value to second location of the array, arr[1]=90; Similarly to read a particular value, scanf(“%d”, &arr[2]); Above statement reads a value from keyboard and assigns it to third location of the array. Write a program to illustrate reading and writing of the array.
  • 7. Memory Allocation of Array The elements of linear array are stored in consecutive memory locations. It is shown below: Address of element a[k]=B + w * k
  • 8. Arrays types Single Dimension Array ◦ Array with one subscript Two Dimension Array ◦ Array with two subscripts (Rows and Column) Multi Dimension Array ◦ Array with Multiple subscripts
  • 9. Initializing Two Dimensional Array An array can also be created by specifying the size and assigning array elements at the time of declaration. Syntax for initialization: int arr[3][3]= {2,4,6,7,5,8,9,3,1}; Write program to show use of initializers.
  • 10. Accessing Two Dimensional Array Elements Individual element of array can be accessed using the following syntax: array_name[row_index][col_index]; e.g., to assign a value to first row and first column location of the array, arr[0][0]=9; Similarly to read a particular value, scanf(“%d”, &arr[1][0]); Above statement reads a value from keyboard and assigns it to second row and first column location of the array. Write a program to illustrate reading and writing of the 2-D array.
  • 11. Basic operations of Arrays Some common operation performed on array are: ◦ Traversing ◦ Searching ◦ Insertion ◦ Deletion ◦ Sorting ◦ Merging
  • 12. STACK • Common Example : • Suppose at your home you have multiple chairs then you put them together to form a vertical pile. From that vertical pile the chair which is placed last is always removed first. Chair which was placed first is removed last. In this way we can see how stack is related to us.
  • 13. What is Stack ? • Stack is used as Linear data structure which can be accessed from only one end . • Stack is LIFO Structure [ Last in First Out ] • Stack is Ordered List of Elements of Same Type. • Stack is Linear List • In Stack all Operations such as Insertion and Deletion are permitted at only one end called Top
  • 14. Visual Representation of Stack : • View 1 : When Stack is Empty When Stack is said to empty then it does not contain any element inside it. Whenever the Stack is Empty the position of topmost element is -1.
  • 15. • View 2 : When Stack is Not Empty • Whenever we add very first element then topmost position will be incremented by 1. After adding First Element top = 0.
  • 16. • View 3 : • After Deletion of 1 Element Top Will be Decremented by 1
  • 17. Array Representation of Stack in C Programming : • 1-D array is used to hold the element of the stack. • Variable “top” keeps track of “Topmost” Element in the stack. • “MAX” is used as Constant which gives maximum size of Stack.
  • 19. Operations on Stack Representation of Stack in Memory The stack  •PUSH: It adds a new element to the top of the stack. After every push operation top of stack incremented by one. If stack is full no new element can be accommodated, this condition is called stack overflow or stack is full.
  • 21. Operations on Stack Representation of Stack in Memory The stack  •POP: I It removes the top element from the stack.): After every pop operation top of stack decremented by one. If stack is empty and pop operation performed this will result into stack underflow condition or stack empty. he stack
  • 23. APPLICATION OF THE STACK 1. Mathematical Expression Evaluation 2. Calculation of Postfix Expression 3. Expression conversion a.Infix to Postfix. b.Infix to Prefix. c.Postfix to Infix. d.Prefix to Infix. 4. Function call and recursion 5. Stack frame 6. Reversing a String