際際滷

際際滷Share a Scribd company logo
ESIT137: Fundamentals of Data Structure
Sanjivani Rural Education Societys
Sanjivani College of Engineering, Kopargaon-423603
(An Autonomous Institute Affiliated to Savitribai Phule Pune University, Pune)
NACC A Grade Accredited, ISO 9001:2015 Certified
Department of Information Technology
(UG Programme - NBAAccredited)
Dr. M.A. Jawale
Professor and Head, Dept. of IT
Stack & Queue
 Stack Applications
 Infix to postfix conversion,
 Evaluation of postfix expression,
 Decimal to Binary conversion.
 References
Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology
Decimal to Binary Conversion
 Decimal Number System: The number system that has a base value of 10 is
called Decimal Number System. Decimal Numbers are consist of the following
digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
 Binary Number System: A binary Number System is a base-2 number system
that uses two states 0 and 1 to represent a number. For example: 01, 111, etc.
Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology
How to Convert Decimal to Binary
 Step 1: Divide the given decimal number by 2, and find the remainder (Ri).
 Step 2: Now divide the quotient (Qi) that is obtained in the above step by 2, and
find the remainder.
 Step 3: Repeat the above steps 1 and 2, until 0 is obtained as a quotient.
 Step 4: Write down the remainder in the following manner: the last remainder is
written first, followed by the rest in the reverse order (Rn, R(n  1) . R1). Thus
binary conversion of the given decimal number will be obtained.
Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology
Decimal to Binary Examples
 Decimal 10 to Binary
 Divide 10 by 2 to get quotient 5 and remainder 0.
 Divide 5 by 2 to get quotient 2 and remainder 1.
 Divide 2 by 2 to get quotient 1 and remainder 0.
 Divide 1 by 2 to get quotient 0 and remainder 1.
Reading the remainders in reverse order: 1010.
Therefore, the binary equivalent of decimal 10 is 1010.
Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology
Decimal to Binary Examples
 Decimal 47 to Binary
 Divide 47 by 2 to get quotient 23 and remainder 1.
 Divide 23 by 2 to get quotient 11 and remainder 1.
 Divide 11 by 2 to get quotient 5 and remainder 1.
 Divide 5 by 2 to get quotient 2 and remainder 1.
 Divide 2 by 2 to get quotient 1 and remainder 0.
 Divide 1 by 2 to get quotient 0 and remainder 1.
Reading the remainders in reverse order: 101111.
Therefore, the binary equivalent of decimal 47 is 101111.
Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology
Decimal to Binary Examples
 We have 278 in Decimal. To Convert in Binary we will divide 278 successively
by 2.
Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology
Hence,
(278) in decimal is equivalent to (100010110) in binary.
Implementation of Decimal to Binary Conversion
Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology
#include <stdio.h>
#include <conio.h>
void main()
{
int n;
clrscr();
printf("n Enter the Decimal Number:");
scanf("%d",&n);
decToBinary(n);
getch();
}
Continue..
Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology
// function to convert decimal to binary
void decToBinary(int n)
{
// stack to store binary number
int stack[100],top=-1;
while (n > 0)
{
// storing remainder in stack
top++;
stack[top] = n % 2;
n = n / 2;
}
// printing stack element to display binary number
while(top!=-1)
{
printf("%d", stack[top]);
top--;
}
Reference
1. Richard F. Gilberg & Behrouz A. Forouzan, Data Structures: A Pseudocode
Approach with C, Second Edition, Cengage Learning.
2. Ellis Horowitz, Sartaj Sahani, Susan Anderson-Freed Fundamentals of Data
Structures in C, Universities Press, 2008.
Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology

More Related Content

Similar to Stack Applications : Infix to postfix conversion, Evaluation of postfix expression, Decimal to Binary conversion. (20)

microprocessor
microprocessormicroprocessor
microprocessor
Rana Mukherji
DCF QNA edited
DCF QNA editedDCF QNA edited
DCF QNA edited
Emmanuel Eniola Falade
Quantitative Analysis 2
Quantitative Analysis 2Quantitative Analysis 2
Quantitative Analysis 2
爨萎爨爨爭爨鉦Θ 爨項爨爭
Binary no
Binary noBinary no
Binary no
Jean Dcedric
1.2 Digital Number Systems.pptx, Digital Electronics
1.2 Digital Number Systems.pptx, Digital Electronics1.2 Digital Number Systems.pptx, Digital Electronics
1.2 Digital Number Systems.pptx, Digital Electronics
nicedeb699
Module 1 number systems and code1
Module 1  number systems and code1Module 1  number systems and code1
Module 1 number systems and code1
Deepak John
Number system
Number systemNumber system
Number system
Amit Shaw
B sc ii sem unit 2(a) ns
B sc ii sem  unit 2(a) nsB sc ii sem  unit 2(a) ns
B sc ii sem unit 2(a) ns
MahiboobAliMulla
Digital Logic
Digital LogicDigital Logic
Digital Logic
NabeelaNousheen
Module 4
Module 4Module 4
Module 4
sadhanakumble
Number Systems Basic Concepts
Number Systems Basic ConceptsNumber Systems Basic Concepts
Number Systems Basic Concepts
Laguna State Polytechnic University
Computer Oraganizaation.pptx
Computer Oraganizaation.pptxComputer Oraganizaation.pptx
Computer Oraganizaation.pptx
bmangesh
Number Systems.pdf .
Number Systems.pdf                        .Number Systems.pdf                        .
Number Systems.pdf .
happycocoman
2s complement arithmetic
2s complement arithmetic2s complement arithmetic
2s complement arithmetic
Sanjay Saluth
Logic Design
Logic DesignLogic Design
Logic Design
Partha_bappa
NumberConversionSystem_819150c7116bea81fd90485ea1028868.pptx
NumberConversionSystem_819150c7116bea81fd90485ea1028868.pptxNumberConversionSystem_819150c7116bea81fd90485ea1028868.pptx
NumberConversionSystem_819150c7116bea81fd90485ea1028868.pptx
2022a6r051
NumberConversionSystem_819150c7116bea81fd90485ea1028868 (1).pptx
NumberConversionSystem_819150c7116bea81fd90485ea1028868 (1).pptxNumberConversionSystem_819150c7116bea81fd90485ea1028868 (1).pptx
NumberConversionSystem_819150c7116bea81fd90485ea1028868 (1).pptx
2022a6r051
Dee 2034 chapter 1 number and code system (Baia)
Dee 2034 chapter 1 number and code system (Baia)Dee 2034 chapter 1 number and code system (Baia)
Dee 2034 chapter 1 number and code system (Baia)
SITI SABARIAH SALIHIN
De presantation
De presantationDe presantation
De presantation
jani
CMSC 131 Discussion 09-07-2011
CMSC 131 Discussion  09-07-2011CMSC 131 Discussion  09-07-2011
CMSC 131 Discussion 09-07-2011
daslerpc
1.2 Digital Number Systems.pptx, Digital Electronics
1.2 Digital Number Systems.pptx, Digital Electronics1.2 Digital Number Systems.pptx, Digital Electronics
1.2 Digital Number Systems.pptx, Digital Electronics
nicedeb699
Module 1 number systems and code1
Module 1  number systems and code1Module 1  number systems and code1
Module 1 number systems and code1
Deepak John
Number system
Number systemNumber system
Number system
Amit Shaw
B sc ii sem unit 2(a) ns
B sc ii sem  unit 2(a) nsB sc ii sem  unit 2(a) ns
B sc ii sem unit 2(a) ns
MahiboobAliMulla
Computer Oraganizaation.pptx
Computer Oraganizaation.pptxComputer Oraganizaation.pptx
Computer Oraganizaation.pptx
bmangesh
Number Systems.pdf .
Number Systems.pdf                        .Number Systems.pdf                        .
Number Systems.pdf .
happycocoman
2s complement arithmetic
2s complement arithmetic2s complement arithmetic
2s complement arithmetic
Sanjay Saluth
NumberConversionSystem_819150c7116bea81fd90485ea1028868.pptx
NumberConversionSystem_819150c7116bea81fd90485ea1028868.pptxNumberConversionSystem_819150c7116bea81fd90485ea1028868.pptx
NumberConversionSystem_819150c7116bea81fd90485ea1028868.pptx
2022a6r051
NumberConversionSystem_819150c7116bea81fd90485ea1028868 (1).pptx
NumberConversionSystem_819150c7116bea81fd90485ea1028868 (1).pptxNumberConversionSystem_819150c7116bea81fd90485ea1028868 (1).pptx
NumberConversionSystem_819150c7116bea81fd90485ea1028868 (1).pptx
2022a6r051
Dee 2034 chapter 1 number and code system (Baia)
Dee 2034 chapter 1 number and code system (Baia)Dee 2034 chapter 1 number and code system (Baia)
Dee 2034 chapter 1 number and code system (Baia)
SITI SABARIAH SALIHIN
De presantation
De presantationDe presantation
De presantation
jani
CMSC 131 Discussion 09-07-2011
CMSC 131 Discussion  09-07-2011CMSC 131 Discussion  09-07-2011
CMSC 131 Discussion 09-07-2011
daslerpc

More from Dr. Madhuri Jawale (7)

Introduction to Stack, Stack ADT, Implementation of Stack using array, ...
Introduction to Stack,   Stack ADT,   Implementation of Stack using array, ...Introduction to Stack,   Stack ADT,   Implementation of Stack using array, ...
Introduction to Stack, Stack ADT, Implementation of Stack using array, ...
Dr. Madhuri Jawale
Insertion Sort, Merge Sort. Time complexity of all sorting algorithms and t...
Insertion Sort,  Merge Sort.  Time complexity of all sorting algorithms and t...Insertion Sort,  Merge Sort.  Time complexity of all sorting algorithms and t...
Insertion Sort, Merge Sort. Time complexity of all sorting algorithms and t...
Dr. Madhuri Jawale
Sorting Algorithms: Bubble Sort, Selection Sort,
Sorting Algorithms: Bubble Sort, Selection Sort,Sorting Algorithms: Bubble Sort, Selection Sort,
Sorting Algorithms: Bubble Sort, Selection Sort,
Dr. Madhuri Jawale
Searching and Sorting Unit II Part I.pptx
Searching and Sorting Unit II Part I.pptxSearching and Sorting Unit II Part I.pptx
Searching and Sorting Unit II Part I.pptx
Dr. Madhuri Jawale
Fundamentals of Data Structure_Unit I.pptx
Fundamentals of Data Structure_Unit I.pptxFundamentals of Data Structure_Unit I.pptx
Fundamentals of Data Structure_Unit I.pptx
Dr. Madhuri Jawale
The loop control structure
The loop control structureThe loop control structure
The loop control structure
Dr. Madhuri Jawale
Arrays
ArraysArrays
Arrays
Dr. Madhuri Jawale
Introduction to Stack, Stack ADT, Implementation of Stack using array, ...
Introduction to Stack,   Stack ADT,   Implementation of Stack using array, ...Introduction to Stack,   Stack ADT,   Implementation of Stack using array, ...
Introduction to Stack, Stack ADT, Implementation of Stack using array, ...
Dr. Madhuri Jawale
Insertion Sort, Merge Sort. Time complexity of all sorting algorithms and t...
Insertion Sort,  Merge Sort.  Time complexity of all sorting algorithms and t...Insertion Sort,  Merge Sort.  Time complexity of all sorting algorithms and t...
Insertion Sort, Merge Sort. Time complexity of all sorting algorithms and t...
Dr. Madhuri Jawale
Sorting Algorithms: Bubble Sort, Selection Sort,
Sorting Algorithms: Bubble Sort, Selection Sort,Sorting Algorithms: Bubble Sort, Selection Sort,
Sorting Algorithms: Bubble Sort, Selection Sort,
Dr. Madhuri Jawale
Searching and Sorting Unit II Part I.pptx
Searching and Sorting Unit II Part I.pptxSearching and Sorting Unit II Part I.pptx
Searching and Sorting Unit II Part I.pptx
Dr. Madhuri Jawale
Fundamentals of Data Structure_Unit I.pptx
Fundamentals of Data Structure_Unit I.pptxFundamentals of Data Structure_Unit I.pptx
Fundamentals of Data Structure_Unit I.pptx
Dr. Madhuri Jawale

Recently uploaded (20)

Hackathon-Problem-Statements-Technology-Track-with-Link.pptx
Hackathon-Problem-Statements-Technology-Track-with-Link.pptxHackathon-Problem-Statements-Technology-Track-with-Link.pptx
Hackathon-Problem-Statements-Technology-Track-with-Link.pptx
datahiverecruitment
Artificial intelligence and Machine learning in remote sensing and GIS
Artificial intelligence  and Machine learning in remote sensing and GISArtificial intelligence  and Machine learning in remote sensing and GIS
Artificial intelligence and Machine learning in remote sensing and GIS
amirthamm2083
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptxUHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
ariomthermal2031
Distributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdfDistributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdf
SantiagoCardonaGallo
pptforclass10kkkkkkkclasseee2eewsw10scienve
pptforclass10kkkkkkkclasseee2eewsw10scienvepptforclass10kkkkkkkclasseee2eewsw10scienve
pptforclass10kkkkkkkclasseee2eewsw10scienve
jeevasreemurali
UHV UNIT-5 IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
UHV UNIT-5    IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...UHV UNIT-5    IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
UHV UNIT-5 IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
ariomthermal2031
Cloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdfCloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdf
Nguy畛n H畉i
Lecture 16 - 17 - NonTraditional Machining Presentation.ppt
Lecture 16 - 17 - NonTraditional Machining Presentation.pptLecture 16 - 17 - NonTraditional Machining Presentation.ppt
Lecture 16 - 17 - NonTraditional Machining Presentation.ppt
INSTITUTE OF ENGINEERING /BKC
Requirements Engineering for Secure Software
Requirements Engineering for Secure SoftwareRequirements Engineering for Secure Software
Requirements Engineering for Secure Software
Dr Sarika Jadhav
CCNA_Product_OverviewCCNA_Productsa.pptx
CCNA_Product_OverviewCCNA_Productsa.pptxCCNA_Product_OverviewCCNA_Productsa.pptx
CCNA_Product_OverviewCCNA_Productsa.pptx
UdayakumarAllimuthu
LA2-64 -bit assemby language program to count number of positive and negative...
LA2-64 -bit assemby language program to count number of positive and negative...LA2-64 -bit assemby language program to count number of positive and negative...
LA2-64 -bit assemby language program to count number of positive and negative...
VidyaAshokNemade
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANEAirport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Priyanka Dange
GDGoC Artificial Intelligence Workshop.pptx
GDGoC Artificial Intelligence Workshop.pptxGDGoC Artificial Intelligence Workshop.pptx
GDGoC Artificial Intelligence Workshop.pptx
Aditi330605
Unit-03 Cams and Followers in Mechanisms of Machines.pptx
Unit-03 Cams and Followers in Mechanisms of Machines.pptxUnit-03 Cams and Followers in Mechanisms of Machines.pptx
Unit-03 Cams and Followers in Mechanisms of Machines.pptx
Kirankumar Jagtap
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION .pptx
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION  .pptxUHV UNIT-I INTRODUCTION TO VALUE EDUCATION  .pptx
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION .pptx
ariomthermal2031
Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...
Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...
Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...
Ignacio J. J. Palma Carazo
Chapter1-Introduction 旅留粒粒旅虜劉 劉僚僚凌旅竜
Chapter1-Introduction 旅留粒粒旅虜劉 劉僚僚凌旅竜Chapter1-Introduction 旅留粒粒旅虜劉 劉僚僚凌旅竜
Chapter1-Introduction 旅留粒粒旅虜劉 劉僚僚凌旅竜
ssuserb91a20
Introduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital ForensicsIntroduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital Forensics
SaanviMisar
Introduction to 3D Printing Technology.pptx
Introduction to 3D Printing Technology.pptxIntroduction to 3D Printing Technology.pptx
Introduction to 3D Printing Technology.pptx
pprakash21252
Call for Papers - 6th International Conference on Big Data and Machine Learni...
Call for Papers - 6th International Conference on Big Data and Machine Learni...Call for Papers - 6th International Conference on Big Data and Machine Learni...
Call for Papers - 6th International Conference on Big Data and Machine Learni...
IJDKP
Hackathon-Problem-Statements-Technology-Track-with-Link.pptx
Hackathon-Problem-Statements-Technology-Track-with-Link.pptxHackathon-Problem-Statements-Technology-Track-with-Link.pptx
Hackathon-Problem-Statements-Technology-Track-with-Link.pptx
datahiverecruitment
Artificial intelligence and Machine learning in remote sensing and GIS
Artificial intelligence  and Machine learning in remote sensing and GISArtificial intelligence  and Machine learning in remote sensing and GIS
Artificial intelligence and Machine learning in remote sensing and GIS
amirthamm2083
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptxUHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
ariomthermal2031
Distributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdfDistributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdf
SantiagoCardonaGallo
pptforclass10kkkkkkkclasseee2eewsw10scienve
pptforclass10kkkkkkkclasseee2eewsw10scienvepptforclass10kkkkkkkclasseee2eewsw10scienve
pptforclass10kkkkkkkclasseee2eewsw10scienve
jeevasreemurali
UHV UNIT-5 IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
UHV UNIT-5    IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...UHV UNIT-5    IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
UHV UNIT-5 IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
ariomthermal2031
Cloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdfCloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdf
Nguy畛n H畉i
Lecture 16 - 17 - NonTraditional Machining Presentation.ppt
Lecture 16 - 17 - NonTraditional Machining Presentation.pptLecture 16 - 17 - NonTraditional Machining Presentation.ppt
Lecture 16 - 17 - NonTraditional Machining Presentation.ppt
INSTITUTE OF ENGINEERING /BKC
Requirements Engineering for Secure Software
Requirements Engineering for Secure SoftwareRequirements Engineering for Secure Software
Requirements Engineering for Secure Software
Dr Sarika Jadhav
CCNA_Product_OverviewCCNA_Productsa.pptx
CCNA_Product_OverviewCCNA_Productsa.pptxCCNA_Product_OverviewCCNA_Productsa.pptx
CCNA_Product_OverviewCCNA_Productsa.pptx
UdayakumarAllimuthu
LA2-64 -bit assemby language program to count number of positive and negative...
LA2-64 -bit assemby language program to count number of positive and negative...LA2-64 -bit assemby language program to count number of positive and negative...
LA2-64 -bit assemby language program to count number of positive and negative...
VidyaAshokNemade
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANEAirport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Priyanka Dange
GDGoC Artificial Intelligence Workshop.pptx
GDGoC Artificial Intelligence Workshop.pptxGDGoC Artificial Intelligence Workshop.pptx
GDGoC Artificial Intelligence Workshop.pptx
Aditi330605
Unit-03 Cams and Followers in Mechanisms of Machines.pptx
Unit-03 Cams and Followers in Mechanisms of Machines.pptxUnit-03 Cams and Followers in Mechanisms of Machines.pptx
Unit-03 Cams and Followers in Mechanisms of Machines.pptx
Kirankumar Jagtap
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION .pptx
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION  .pptxUHV UNIT-I INTRODUCTION TO VALUE EDUCATION  .pptx
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION .pptx
ariomthermal2031
Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...
Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...
Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...
Ignacio J. J. Palma Carazo
Chapter1-Introduction 旅留粒粒旅虜劉 劉僚僚凌旅竜
Chapter1-Introduction 旅留粒粒旅虜劉 劉僚僚凌旅竜Chapter1-Introduction 旅留粒粒旅虜劉 劉僚僚凌旅竜
Chapter1-Introduction 旅留粒粒旅虜劉 劉僚僚凌旅竜
ssuserb91a20
Introduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital ForensicsIntroduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital Forensics
SaanviMisar
Introduction to 3D Printing Technology.pptx
Introduction to 3D Printing Technology.pptxIntroduction to 3D Printing Technology.pptx
Introduction to 3D Printing Technology.pptx
pprakash21252
Call for Papers - 6th International Conference on Big Data and Machine Learni...
Call for Papers - 6th International Conference on Big Data and Machine Learni...Call for Papers - 6th International Conference on Big Data and Machine Learni...
Call for Papers - 6th International Conference on Big Data and Machine Learni...
IJDKP

Stack Applications : Infix to postfix conversion, Evaluation of postfix expression, Decimal to Binary conversion.

  • 1. ESIT137: Fundamentals of Data Structure Sanjivani Rural Education Societys Sanjivani College of Engineering, Kopargaon-423603 (An Autonomous Institute Affiliated to Savitribai Phule Pune University, Pune) NACC A Grade Accredited, ISO 9001:2015 Certified Department of Information Technology (UG Programme - NBAAccredited) Dr. M.A. Jawale Professor and Head, Dept. of IT
  • 2. Stack & Queue Stack Applications Infix to postfix conversion, Evaluation of postfix expression, Decimal to Binary conversion. References Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology
  • 3. Decimal to Binary Conversion Decimal Number System: The number system that has a base value of 10 is called Decimal Number System. Decimal Numbers are consist of the following digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Binary Number System: A binary Number System is a base-2 number system that uses two states 0 and 1 to represent a number. For example: 01, 111, etc. Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology
  • 4. How to Convert Decimal to Binary Step 1: Divide the given decimal number by 2, and find the remainder (Ri). Step 2: Now divide the quotient (Qi) that is obtained in the above step by 2, and find the remainder. Step 3: Repeat the above steps 1 and 2, until 0 is obtained as a quotient. Step 4: Write down the remainder in the following manner: the last remainder is written first, followed by the rest in the reverse order (Rn, R(n 1) . R1). Thus binary conversion of the given decimal number will be obtained. Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology
  • 5. Decimal to Binary Examples Decimal 10 to Binary Divide 10 by 2 to get quotient 5 and remainder 0. Divide 5 by 2 to get quotient 2 and remainder 1. Divide 2 by 2 to get quotient 1 and remainder 0. Divide 1 by 2 to get quotient 0 and remainder 1. Reading the remainders in reverse order: 1010. Therefore, the binary equivalent of decimal 10 is 1010. Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology
  • 6. Decimal to Binary Examples Decimal 47 to Binary Divide 47 by 2 to get quotient 23 and remainder 1. Divide 23 by 2 to get quotient 11 and remainder 1. Divide 11 by 2 to get quotient 5 and remainder 1. Divide 5 by 2 to get quotient 2 and remainder 1. Divide 2 by 2 to get quotient 1 and remainder 0. Divide 1 by 2 to get quotient 0 and remainder 1. Reading the remainders in reverse order: 101111. Therefore, the binary equivalent of decimal 47 is 101111. Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology
  • 7. Decimal to Binary Examples We have 278 in Decimal. To Convert in Binary we will divide 278 successively by 2. Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology Hence, (278) in decimal is equivalent to (100010110) in binary.
  • 8. Implementation of Decimal to Binary Conversion Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology #include <stdio.h> #include <conio.h> void main() { int n; clrscr(); printf("n Enter the Decimal Number:"); scanf("%d",&n); decToBinary(n); getch(); }
  • 9. Continue.. Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology // function to convert decimal to binary void decToBinary(int n) { // stack to store binary number int stack[100],top=-1; while (n > 0) { // storing remainder in stack top++; stack[top] = n % 2; n = n / 2; } // printing stack element to display binary number while(top!=-1) { printf("%d", stack[top]); top--; }
  • 10. Reference 1. Richard F. Gilberg & Behrouz A. Forouzan, Data Structures: A Pseudocode Approach with C, Second Edition, Cengage Learning. 2. Ellis Horowitz, Sartaj Sahani, Susan Anderson-Freed Fundamentals of Data Structures in C, Universities Press, 2008. Unit-III: Part-II Stack & Queue Dr. Madhuri Jawale Department of Information Technology