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

PPT
PDF
Unit ii data structure-converted
PPTX
Ch8 Arrays
PPTX
Unit4pptx__2024_11_ 11_10_16_09.pptx
PDF
Array&amp;string
PPTX
TMK_DSA_Unit 2 part1(array and stack).pptx
PDF
Arrays-Computer programming
PPTX
Module_3_Arrays - Updated.pptx............
Unit ii data structure-converted
Ch8 Arrays
Unit4pptx__2024_11_ 11_10_16_09.pptx
Array&amp;string
TMK_DSA_Unit 2 part1(array and stack).pptx
Arrays-Computer programming
Module_3_Arrays - Updated.pptx............

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

PPTX
Data Structure
PDF
Homework Assignment – Array Technical DocumentWrite a technical .pdf
PPTX
Chapter 13.pptx
PPTX
The document discusses arrays in data structures using Cpp programming langua...
PDF
SlideSet_4_Arraysnew.pdf
PDF
Arrays
PPT
Arrays Basics
PPTX
unit 2.pptx
PDF
PPTX
Arrays in C language
PPTX
Arrays
PPT
Array 31.8.2020 updated
PPTX
Data structures Lecture 5
PPTX
Array ppt you can learn in very few slides.
PPTX
01-Introduction of DSA-1.pptx
PPTX
PDF
02 arrays
PDF
Array in C.pdf
PDF
Array.pdf
PPTX
هياكلبيانات
Data Structure
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Chapter 13.pptx
The document discusses arrays in data structures using Cpp programming langua...
SlideSet_4_Arraysnew.pdf
Arrays
Arrays Basics
unit 2.pptx
Arrays in C language
Arrays
Array 31.8.2020 updated
Data structures Lecture 5
Array ppt you can learn in very few slides.
01-Introduction of DSA-1.pptx
02 arrays
Array in C.pdf
Array.pdf
هياكلبيانات
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)

PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Digital Logic Computer Design lecture notes
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPT
introduction to datamining and warehousing
PDF
PPT on Performance Review to get promotions
PPTX
Sustainable Sites - Green Building Construction
PPTX
Current and future trends in Computer Vision.pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
Construction Project Organization Group 2.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Safety Seminar civil to be ensured for safe working.
PPTX
web development for engineering and engineering
PPT
Project quality management in manufacturing
Operating System & Kernel Study Guide-1 - converted.pdf
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Digital Logic Computer Design lecture notes
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
R24 SURVEYING LAB MANUAL for civil enggi
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
introduction to datamining and warehousing
PPT on Performance Review to get promotions
Sustainable Sites - Green Building Construction
Current and future trends in Computer Vision.pptx
Model Code of Practice - Construction Work - 21102022 .pdf
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Construction Project Organization Group 2.pptx
Foundation to blockchain - A guide to Blockchain Tech
bas. eng. economics group 4 presentation 1.pptx
Safety Seminar civil to be ensured for safe working.
web development for engineering and engineering
Project quality management in manufacturing

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