SlideShare a Scribd company logo
//later we create a specialstack class ,which inherits from stack class.there we return the smallest
integer
//implementation
#include
#include
using namespace std;
/* A simple stack class named IntStack with push and pop operations */
class IntStack
{
private:
static const int max = 100;
int arr[max];
int top;
public:
//constructor for initialising value of top
IntStack()
{
top = -1;
}
void push(int x);
int pop();
bool isEmpty();
bool isFull();
};
/* Stack's member method to check if the stack is iempty */
bool IntStack::isEmpty()
{
if(top == -1)
return true;
return false;
}
/* Stack's member method to check if the stack is full */
bool IntStack::isFull()
{
if(top == max - 1)
return true;
return false;
}
/* Stack's member method push() to insert an element */
void IntStack::push(int x)
{
if(isFull())
{
cout<<"Stack Overflow";
}
top++;
arr[top] = x;
}
/* Stack's member method pop() to remove an element from it */
int IntStack::pop()
{
if(isEmpty())
{
cout<<"Stack Underflow";
abort();
}
int x = arr[top];
top--;
return x;
}
/* A class that supports all the stack operations and one additional operation getMIN() that
returns the minimum element from stack at any time. This class inherits from the stack class and
uses an auxiliarry stack that holds minimum elements */
class SpecialStack: public IntStack
{
IntStack min;
public:
//function declarations
void push(int x);
int pop();
int getMIN();
};
/* SpecialStack's member method to insert an element to it. This method
makes sure that the min stack is also updated with appropriate minimum
values */
void SpecialStack::push(int x)
{
if(isEmpty()==true)
{
IntStack::push(x);
min.push(x);
}
else
{
IntStack::push(x);
int y = min.pop();
min.push(y);
/* push only when the incoming element of main stack is smaller
than or equal to top of auxiliary stack */
if( x <= y )
min.push(x);
}
}
/* SpecialStack's member method to remove an element from it. This method
removes top element from min stack also. */
int SpecialStack::pop()
{
int x = IntStack::pop();
int y = min.pop();
/* Push the popped element y back only if it is not equal to x */
if ( y != x )
min.push(y);
return x;
}
/* SpecialStack's member method to get minimum element from it. */
int SpecialStack::getMIN()
{
int x = min.pop();
min.push(x);
return x;
}
/* main program to test SpecialStack methods */
//execution starts here
int main()
{
SpecialStack s;
//push 3 elements and get the minimum
s.push(15);
s.push(25);
s.push(33);
cout<
#include
using namespace std;
/* A simple stack class named IntStack with push and pop operations */
class IntStack
{
private:
static const int max = 100;
int arr[max];
int top;
public:
//constructor for initialising value of top
IntStack()
{
top = -1;
}
void push(int x);
int pop();
bool isEmpty();
bool isFull();
};
/* Stack's member method to check if the stack is iempty */
bool IntStack::isEmpty()
{
if(top == -1)
return true;
return false;
}
/* Stack's member method to check if the stack is full */
bool IntStack::isFull()
{
if(top == max - 1)
return true;
return false;
}
/* Stack's member method push() to insert an element */
void IntStack::push(int x)
{
if(isFull())
{
cout<<"Stack Overflow";
}
top++;
arr[top] = x;
}
/* Stack's member method pop() to remove an element from it */
int IntStack::pop()
{
if(isEmpty())
{
cout<<"Stack Underflow";
abort();
}
int x = arr[top];
top--;
return x;
}
/* A class that supports all the stack operations and one additional operation getMIN() that
returns the minimum element from stack at any time. This class inherits from the stack class and
uses an auxiliarry stack that holds minimum elements */
class SpecialStack: public IntStack
{
IntStack min;
public:
//function declarations
void push(int x);
int pop();
int getMIN();
};
/* SpecialStack's member method to insert an element to it. This method
makes sure that the min stack is also updated with appropriate minimum
values */
void SpecialStack::push(int x)
{
if(isEmpty()==true)
{
IntStack::push(x);
min.push(x);
}
else
{
IntStack::push(x);
int y = min.pop();
min.push(y);
/* push only when the incoming element of main stack is smaller
than or equal to top of auxiliary stack */
if( x <= y )
min.push(x);
}
}
/* SpecialStack's member method to remove an element from it. This method
removes top element from min stack also. */
int SpecialStack::pop()
{
int x = IntStack::pop();
int y = min.pop();
/* Push the popped element y back only if it is not equal to x */
if ( y != x )
min.push(y);
return x;
}
/* SpecialStack's member method to get minimum element from it. */
int SpecialStack::getMIN()
{
int x = min.pop();
min.push(x);
return x;
}
/* main program to test SpecialStack methods */
//execution starts here
int main()
{
SpecialStack s;
//push 3 elements and get the minimum
s.push(15);
s.push(25);
s.push(33);
cout<
Solution
//later we create a specialstack class ,which inherits from stack class.there we return the smallest
integer
//implementation
#include
#include
using namespace std;
/* A simple stack class named IntStack with push and pop operations */
class IntStack
{
private:
static const int max = 100;
int arr[max];
int top;
public:
//constructor for initialising value of top
IntStack()
{
top = -1;
}
void push(int x);
int pop();
bool isEmpty();
bool isFull();
};
/* Stack's member method to check if the stack is iempty */
bool IntStack::isEmpty()
{
if(top == -1)
return true;
return false;
}
/* Stack's member method to check if the stack is full */
bool IntStack::isFull()
{
if(top == max - 1)
return true;
return false;
}
/* Stack's member method push() to insert an element */
void IntStack::push(int x)
{
if(isFull())
{
cout<<"Stack Overflow";
}
top++;
arr[top] = x;
}
/* Stack's member method pop() to remove an element from it */
int IntStack::pop()
{
if(isEmpty())
{
cout<<"Stack Underflow";
abort();
}
int x = arr[top];
top--;
return x;
}
/* A class that supports all the stack operations and one additional operation getMIN() that
returns the minimum element from stack at any time. This class inherits from the stack class and
uses an auxiliarry stack that holds minimum elements */
class SpecialStack: public IntStack
{
IntStack min;
public:
//function declarations
void push(int x);
int pop();
int getMIN();
};
/* SpecialStack's member method to insert an element to it. This method
makes sure that the min stack is also updated with appropriate minimum
values */
void SpecialStack::push(int x)
{
if(isEmpty()==true)
{
IntStack::push(x);
min.push(x);
}
else
{
IntStack::push(x);
int y = min.pop();
min.push(y);
/* push only when the incoming element of main stack is smaller
than or equal to top of auxiliary stack */
if( x <= y )
min.push(x);
}
}
/* SpecialStack's member method to remove an element from it. This method
removes top element from min stack also. */
int SpecialStack::pop()
{
int x = IntStack::pop();
int y = min.pop();
/* Push the popped element y back only if it is not equal to x */
if ( y != x )
min.push(y);
return x;
}
/* SpecialStack's member method to get minimum element from it. */
int SpecialStack::getMIN()
{
int x = min.pop();
min.push(x);
return x;
}
/* main program to test SpecialStack methods */
//execution starts here
int main()
{
SpecialStack s;
//push 3 elements and get the minimum
s.push(15);
s.push(25);
s.push(33);
cout<
#include
using namespace std;
/* A simple stack class named IntStack with push and pop operations */
class IntStack
{
private:
static const int max = 100;
int arr[max];
int top;
public:
//constructor for initialising value of top
IntStack()
{
top = -1;
}
void push(int x);
int pop();
bool isEmpty();
bool isFull();
};
/* Stack's member method to check if the stack is iempty */
bool IntStack::isEmpty()
{
if(top == -1)
return true;
return false;
}
/* Stack's member method to check if the stack is full */
bool IntStack::isFull()
{
if(top == max - 1)
return true;
return false;
}
/* Stack's member method push() to insert an element */
void IntStack::push(int x)
{
if(isFull())
{
cout<<"Stack Overflow";
}
top++;
arr[top] = x;
}
/* Stack's member method pop() to remove an element from it */
int IntStack::pop()
{
if(isEmpty())
{
cout<<"Stack Underflow";
abort();
}
int x = arr[top];
top--;
return x;
}
/* A class that supports all the stack operations and one additional operation getMIN() that
returns the minimum element from stack at any time. This class inherits from the stack class and
uses an auxiliarry stack that holds minimum elements */
class SpecialStack: public IntStack
{
IntStack min;
public:
//function declarations
void push(int x);
int pop();
int getMIN();
};
/* SpecialStack's member method to insert an element to it. This method
makes sure that the min stack is also updated with appropriate minimum
values */
void SpecialStack::push(int x)
{
if(isEmpty()==true)
{
IntStack::push(x);
min.push(x);
}
else
{
IntStack::push(x);
int y = min.pop();
min.push(y);
/* push only when the incoming element of main stack is smaller
than or equal to top of auxiliary stack */
if( x <= y )
min.push(x);
}
}
/* SpecialStack's member method to remove an element from it. This method
removes top element from min stack also. */
int SpecialStack::pop()
{
int x = IntStack::pop();
int y = min.pop();
/* Push the popped element y back only if it is not equal to x */
if ( y != x )
min.push(y);
return x;
}
/* SpecialStack's member method to get minimum element from it. */
int SpecialStack::getMIN()
{
int x = min.pop();
min.push(x);
return x;
}
/* main program to test SpecialStack methods */
//execution starts here
int main()
{
SpecialStack s;
//push 3 elements and get the minimum
s.push(15);
s.push(25);
s.push(33);
cout<

More Related Content

Similar to later we create a specialstack class ,which inherits from stack cl.pdf

(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manual(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manual
Chandrapriya Jayabal
 
Implement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdfImplement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdf
SIGMATAX1
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
ARCHANASTOREKOTA
 
Please review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdfPlease review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdf
fathimafancyjeweller
 
Need help with writing the test cases for the following code in java-.docx
Need help with writing the test cases for the following code in java-.docxNeed help with writing the test cases for the following code in java-.docx
Need help with writing the test cases for the following code in java-.docx
LucasmHKChapmant
 
C program for array implementation of stack#include stdio.h.pdf
 C program for array implementation of stack#include stdio.h.pdf C program for array implementation of stack#include stdio.h.pdf
C program for array implementation of stack#include stdio.h.pdf
mohammadirfan136964
 
#includeiostream#includestdlib.husing namespace std;class .pdf
#includeiostream#includestdlib.husing namespace std;class .pdf#includeiostream#includestdlib.husing namespace std;class .pdf
#includeiostream#includestdlib.husing namespace std;class .pdf
asif1401
 
Stack queue
Stack queueStack queue
Stack queue
Tony Nguyen
 
Stack queue
Stack queueStack queue
Stack queue
James Wong
 
Stack queue
Stack queueStack queue
Stack queue
Harry Potter
 
Stack queue
Stack queueStack queue
Stack queue
Young Alista
 
Stack queue
Stack queueStack queue
Stack queue
Fraboni Ec
 
Stack queue
Stack queueStack queue
Stack queue
Luis Goldster
 
Stack queue
Stack queueStack queue
Stack queue
Hoang Nguyen
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
maamir farooq
 
Java Foundations StackADT-java --- - Defines the interface to a stack.docx
Java Foundations StackADT-java ---  - Defines the interface to a stack.docxJava Foundations StackADT-java ---  - Defines the interface to a stack.docx
Java Foundations StackADT-java --- - Defines the interface to a stack.docx
VictorXUQGloverl
 
Stack and its applications
Stack and its applicationsStack and its applications
Stack and its applications
Ahsan Mansiv
 
ReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdfReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdf
ravikapoorindia
 
All code should be in C++Using the UnsortedList class (UnsortedLis.pdf
All code should be in C++Using the UnsortedList class (UnsortedLis.pdfAll code should be in C++Using the UnsortedList class (UnsortedLis.pdf
All code should be in C++Using the UnsortedList class (UnsortedLis.pdf
akashenterprises93
 
Algo>Stacks
Algo>StacksAlgo>Stacks
Algo>Stacks
Ain-ul-Moiz Khawaja
 

Similar to later we create a specialstack class ,which inherits from stack cl.pdf (20)

(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manual(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manual
 
Implement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdfImplement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdf
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
 
Please review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdfPlease review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdf
 
Need help with writing the test cases for the following code in java-.docx
Need help with writing the test cases for the following code in java-.docxNeed help with writing the test cases for the following code in java-.docx
Need help with writing the test cases for the following code in java-.docx
 
C program for array implementation of stack#include stdio.h.pdf
 C program for array implementation of stack#include stdio.h.pdf C program for array implementation of stack#include stdio.h.pdf
C program for array implementation of stack#include stdio.h.pdf
 
#includeiostream#includestdlib.husing namespace std;class .pdf
#includeiostream#includestdlib.husing namespace std;class .pdf#includeiostream#includestdlib.husing namespace std;class .pdf
#includeiostream#includestdlib.husing namespace std;class .pdf
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
 
Java Foundations StackADT-java --- - Defines the interface to a stack.docx
Java Foundations StackADT-java ---  - Defines the interface to a stack.docxJava Foundations StackADT-java ---  - Defines the interface to a stack.docx
Java Foundations StackADT-java --- - Defines the interface to a stack.docx
 
Stack and its applications
Stack and its applicationsStack and its applications
Stack and its applications
 
ReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdfReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdf
 
All code should be in C++Using the UnsortedList class (UnsortedLis.pdf
All code should be in C++Using the UnsortedList class (UnsortedLis.pdfAll code should be in C++Using the UnsortedList class (UnsortedLis.pdf
All code should be in C++Using the UnsortedList class (UnsortedLis.pdf
 
Algo>Stacks
Algo>StacksAlgo>Stacks
Algo>Stacks
 

More from anandhomeneeds

Driver.java import java.util.Scanner; import java.text.Decimal.pdf
Driver.java import java.util.Scanner; import java.text.Decimal.pdfDriver.java import java.util.Scanner; import java.text.Decimal.pdf
Driver.java import java.util.Scanner; import java.text.Decimal.pdf
anandhomeneeds
 
Question 1,2,4 ------------------------------------Please check.pdf
Question 1,2,4 ------------------------------------Please check.pdfQuestion 1,2,4 ------------------------------------Please check.pdf
Question 1,2,4 ------------------------------------Please check.pdf
anandhomeneeds
 
The answer is C. securin.APC degrade securin to release separase .pdf
The answer is C. securin.APC degrade securin to release separase .pdfThe answer is C. securin.APC degrade securin to release separase .pdf
The answer is C. securin.APC degrade securin to release separase .pdf
anandhomeneeds
 
HiCan you please summarise the question. More information confuse .pdf
HiCan you please summarise the question. More information confuse .pdfHiCan you please summarise the question. More information confuse .pdf
HiCan you please summarise the question. More information confuse .pdf
anandhomeneeds
 
What property of proteins us used to separate them in HICHydrophob.pdf
What property of proteins us used to separate them in HICHydrophob.pdfWhat property of proteins us used to separate them in HICHydrophob.pdf
What property of proteins us used to separate them in HICHydrophob.pdf
anandhomeneeds
 
upload complete priblem somthing is missingSolutionupload comp.pdf
upload complete priblem somthing is missingSolutionupload comp.pdfupload complete priblem somthing is missingSolutionupload comp.pdf
upload complete priblem somthing is missingSolutionupload comp.pdf
anandhomeneeds
 
the phenomena responsible for this type of inheritancce is Epistasis.pdf
the phenomena responsible for this type of inheritancce is Epistasis.pdfthe phenomena responsible for this type of inheritancce is Epistasis.pdf
the phenomena responsible for this type of inheritancce is Epistasis.pdf
anandhomeneeds
 
The substrate in urease test is urea.The end products in urease te.pdf
The substrate in urease test is urea.The end products in urease te.pdfThe substrate in urease test is urea.The end products in urease te.pdf
The substrate in urease test is urea.The end products in urease te.pdf
anandhomeneeds
 
I think that 34SolutionI think that 34.pdf
I think that 34SolutionI think that 34.pdfI think that 34SolutionI think that 34.pdf
I think that 34SolutionI think that 34.pdf
anandhomeneeds
 
D(ANSWER)Polycrystalline or multicrystalline materials, or polycry.pdf
D(ANSWER)Polycrystalline or multicrystalline materials, or polycry.pdfD(ANSWER)Polycrystalline or multicrystalline materials, or polycry.pdf
D(ANSWER)Polycrystalline or multicrystalline materials, or polycry.pdf
anandhomeneeds
 
1.It is the process of directing the television assistances are tran.pdf
1.It is the process of directing the television assistances are tran.pdf1.It is the process of directing the television assistances are tran.pdf
1.It is the process of directing the television assistances are tran.pdf
anandhomeneeds
 
Answer The major objective of implementing a health information man.pdf
Answer The major objective of implementing a health information man.pdfAnswer The major objective of implementing a health information man.pdf
Answer The major objective of implementing a health information man.pdf
anandhomeneeds
 
The key assumptions made by the Hadoop Distributed File System(HDFS).pdf
The key assumptions made by the Hadoop Distributed File System(HDFS).pdfThe key assumptions made by the Hadoop Distributed File System(HDFS).pdf
The key assumptions made by the Hadoop Distributed File System(HDFS).pdf
anandhomeneeds
 
Properties areMeanModeMedianQuartilesPercentilesRan.pdf
Properties areMeanModeMedianQuartilesPercentilesRan.pdfProperties areMeanModeMedianQuartilesPercentilesRan.pdf
Properties areMeanModeMedianQuartilesPercentilesRan.pdf
anandhomeneeds
 
MgCO3 Increasing acidity will cause the following reaction Mg.pdf
 MgCO3 Increasing acidity will cause the following reaction Mg.pdf MgCO3 Increasing acidity will cause the following reaction Mg.pdf
MgCO3 Increasing acidity will cause the following reaction Mg.pdf
anandhomeneeds
 
Environmental conditions play a key role in defining the function an.pdf
Environmental conditions play a key role in defining the function an.pdfEnvironmental conditions play a key role in defining the function an.pdf
Environmental conditions play a key role in defining the function an.pdf
anandhomeneeds
 
1. Autralopith is a known genus of hominids which is extinct today..pdf
1. Autralopith is a known genus of hominids which is extinct today..pdf1. Autralopith is a known genus of hominids which is extinct today..pdf
1. Autralopith is a known genus of hominids which is extinct today..pdf
anandhomeneeds
 
Mobile IP1) Mobile IP(MIP) is an Internet Engineering Task Force(.pdf
Mobile IP1) Mobile IP(MIP) is an Internet Engineering Task Force(.pdfMobile IP1) Mobile IP(MIP) is an Internet Engineering Task Force(.pdf
Mobile IP1) Mobile IP(MIP) is an Internet Engineering Task Force(.pdf
anandhomeneeds
 
Answer1. Cells can generate many different tissue types endoderm,.pdf
Answer1. Cells can generate many different tissue types endoderm,.pdfAnswer1. Cells can generate many different tissue types endoderm,.pdf
Answer1. Cells can generate many different tissue types endoderm,.pdf
anandhomeneeds
 
3 a) The trace of an nSolution3 a) The trace of an n.pdf
3 a) The trace of an nSolution3 a) The trace of an n.pdf3 a) The trace of an nSolution3 a) The trace of an n.pdf
3 a) The trace of an nSolution3 a) The trace of an n.pdf
anandhomeneeds
 

More from anandhomeneeds (20)

Driver.java import java.util.Scanner; import java.text.Decimal.pdf
Driver.java import java.util.Scanner; import java.text.Decimal.pdfDriver.java import java.util.Scanner; import java.text.Decimal.pdf
Driver.java import java.util.Scanner; import java.text.Decimal.pdf
 
Question 1,2,4 ------------------------------------Please check.pdf
Question 1,2,4 ------------------------------------Please check.pdfQuestion 1,2,4 ------------------------------------Please check.pdf
Question 1,2,4 ------------------------------------Please check.pdf
 
The answer is C. securin.APC degrade securin to release separase .pdf
The answer is C. securin.APC degrade securin to release separase .pdfThe answer is C. securin.APC degrade securin to release separase .pdf
The answer is C. securin.APC degrade securin to release separase .pdf
 
HiCan you please summarise the question. More information confuse .pdf
HiCan you please summarise the question. More information confuse .pdfHiCan you please summarise the question. More information confuse .pdf
HiCan you please summarise the question. More information confuse .pdf
 
What property of proteins us used to separate them in HICHydrophob.pdf
What property of proteins us used to separate them in HICHydrophob.pdfWhat property of proteins us used to separate them in HICHydrophob.pdf
What property of proteins us used to separate them in HICHydrophob.pdf
 
upload complete priblem somthing is missingSolutionupload comp.pdf
upload complete priblem somthing is missingSolutionupload comp.pdfupload complete priblem somthing is missingSolutionupload comp.pdf
upload complete priblem somthing is missingSolutionupload comp.pdf
 
the phenomena responsible for this type of inheritancce is Epistasis.pdf
the phenomena responsible for this type of inheritancce is Epistasis.pdfthe phenomena responsible for this type of inheritancce is Epistasis.pdf
the phenomena responsible for this type of inheritancce is Epistasis.pdf
 
The substrate in urease test is urea.The end products in urease te.pdf
The substrate in urease test is urea.The end products in urease te.pdfThe substrate in urease test is urea.The end products in urease te.pdf
The substrate in urease test is urea.The end products in urease te.pdf
 
I think that 34SolutionI think that 34.pdf
I think that 34SolutionI think that 34.pdfI think that 34SolutionI think that 34.pdf
I think that 34SolutionI think that 34.pdf
 
D(ANSWER)Polycrystalline or multicrystalline materials, or polycry.pdf
D(ANSWER)Polycrystalline or multicrystalline materials, or polycry.pdfD(ANSWER)Polycrystalline or multicrystalline materials, or polycry.pdf
D(ANSWER)Polycrystalline or multicrystalline materials, or polycry.pdf
 
1.It is the process of directing the television assistances are tran.pdf
1.It is the process of directing the television assistances are tran.pdf1.It is the process of directing the television assistances are tran.pdf
1.It is the process of directing the television assistances are tran.pdf
 
Answer The major objective of implementing a health information man.pdf
Answer The major objective of implementing a health information man.pdfAnswer The major objective of implementing a health information man.pdf
Answer The major objective of implementing a health information man.pdf
 
The key assumptions made by the Hadoop Distributed File System(HDFS).pdf
The key assumptions made by the Hadoop Distributed File System(HDFS).pdfThe key assumptions made by the Hadoop Distributed File System(HDFS).pdf
The key assumptions made by the Hadoop Distributed File System(HDFS).pdf
 
Properties areMeanModeMedianQuartilesPercentilesRan.pdf
Properties areMeanModeMedianQuartilesPercentilesRan.pdfProperties areMeanModeMedianQuartilesPercentilesRan.pdf
Properties areMeanModeMedianQuartilesPercentilesRan.pdf
 
MgCO3 Increasing acidity will cause the following reaction Mg.pdf
 MgCO3 Increasing acidity will cause the following reaction Mg.pdf MgCO3 Increasing acidity will cause the following reaction Mg.pdf
MgCO3 Increasing acidity will cause the following reaction Mg.pdf
 
Environmental conditions play a key role in defining the function an.pdf
Environmental conditions play a key role in defining the function an.pdfEnvironmental conditions play a key role in defining the function an.pdf
Environmental conditions play a key role in defining the function an.pdf
 
1. Autralopith is a known genus of hominids which is extinct today..pdf
1. Autralopith is a known genus of hominids which is extinct today..pdf1. Autralopith is a known genus of hominids which is extinct today..pdf
1. Autralopith is a known genus of hominids which is extinct today..pdf
 
Mobile IP1) Mobile IP(MIP) is an Internet Engineering Task Force(.pdf
Mobile IP1) Mobile IP(MIP) is an Internet Engineering Task Force(.pdfMobile IP1) Mobile IP(MIP) is an Internet Engineering Task Force(.pdf
Mobile IP1) Mobile IP(MIP) is an Internet Engineering Task Force(.pdf
 
Answer1. Cells can generate many different tissue types endoderm,.pdf
Answer1. Cells can generate many different tissue types endoderm,.pdfAnswer1. Cells can generate many different tissue types endoderm,.pdf
Answer1. Cells can generate many different tissue types endoderm,.pdf
 
3 a) The trace of an nSolution3 a) The trace of an n.pdf
3 a) The trace of an nSolution3 a) The trace of an n.pdf3 a) The trace of an nSolution3 a) The trace of an n.pdf
3 a) The trace of an nSolution3 a) The trace of an n.pdf
 

Recently uploaded

How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 

Recently uploaded (20)

How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 

later we create a specialstack class ,which inherits from stack cl.pdf

  • 1. //later we create a specialstack class ,which inherits from stack class.there we return the smallest integer //implementation #include #include using namespace std; /* A simple stack class named IntStack with push and pop operations */ class IntStack { private: static const int max = 100; int arr[max]; int top; public: //constructor for initialising value of top IntStack() { top = -1; } void push(int x); int pop(); bool isEmpty(); bool isFull(); }; /* Stack's member method to check if the stack is iempty */ bool IntStack::isEmpty() { if(top == -1) return true; return false; } /* Stack's member method to check if the stack is full */ bool IntStack::isFull() { if(top == max - 1)
  • 2. return true; return false; } /* Stack's member method push() to insert an element */ void IntStack::push(int x) { if(isFull()) { cout<<"Stack Overflow"; } top++; arr[top] = x; } /* Stack's member method pop() to remove an element from it */ int IntStack::pop() { if(isEmpty()) { cout<<"Stack Underflow"; abort(); } int x = arr[top]; top--; return x; } /* A class that supports all the stack operations and one additional operation getMIN() that returns the minimum element from stack at any time. This class inherits from the stack class and uses an auxiliarry stack that holds minimum elements */ class SpecialStack: public IntStack { IntStack min; public: //function declarations void push(int x); int pop(); int getMIN();
  • 3. }; /* SpecialStack's member method to insert an element to it. This method makes sure that the min stack is also updated with appropriate minimum values */ void SpecialStack::push(int x) { if(isEmpty()==true) { IntStack::push(x); min.push(x); } else { IntStack::push(x); int y = min.pop(); min.push(y); /* push only when the incoming element of main stack is smaller than or equal to top of auxiliary stack */ if( x <= y ) min.push(x); } } /* SpecialStack's member method to remove an element from it. This method removes top element from min stack also. */ int SpecialStack::pop() { int x = IntStack::pop(); int y = min.pop(); /* Push the popped element y back only if it is not equal to x */ if ( y != x ) min.push(y); return x; } /* SpecialStack's member method to get minimum element from it. */ int SpecialStack::getMIN()
  • 4. { int x = min.pop(); min.push(x); return x; } /* main program to test SpecialStack methods */ //execution starts here int main() { SpecialStack s; //push 3 elements and get the minimum s.push(15); s.push(25); s.push(33); cout< #include using namespace std; /* A simple stack class named IntStack with push and pop operations */ class IntStack { private: static const int max = 100; int arr[max]; int top; public: //constructor for initialising value of top IntStack() { top = -1; } void push(int x); int pop(); bool isEmpty(); bool isFull(); };
  • 5. /* Stack's member method to check if the stack is iempty */ bool IntStack::isEmpty() { if(top == -1) return true; return false; } /* Stack's member method to check if the stack is full */ bool IntStack::isFull() { if(top == max - 1) return true; return false; } /* Stack's member method push() to insert an element */ void IntStack::push(int x) { if(isFull()) { cout<<"Stack Overflow"; } top++; arr[top] = x; } /* Stack's member method pop() to remove an element from it */ int IntStack::pop() { if(isEmpty()) { cout<<"Stack Underflow"; abort(); } int x = arr[top]; top--; return x; }
  • 6. /* A class that supports all the stack operations and one additional operation getMIN() that returns the minimum element from stack at any time. This class inherits from the stack class and uses an auxiliarry stack that holds minimum elements */ class SpecialStack: public IntStack { IntStack min; public: //function declarations void push(int x); int pop(); int getMIN(); }; /* SpecialStack's member method to insert an element to it. This method makes sure that the min stack is also updated with appropriate minimum values */ void SpecialStack::push(int x) { if(isEmpty()==true) { IntStack::push(x); min.push(x); } else { IntStack::push(x); int y = min.pop(); min.push(y); /* push only when the incoming element of main stack is smaller than or equal to top of auxiliary stack */ if( x <= y ) min.push(x); } } /* SpecialStack's member method to remove an element from it. This method removes top element from min stack also. */
  • 7. int SpecialStack::pop() { int x = IntStack::pop(); int y = min.pop(); /* Push the popped element y back only if it is not equal to x */ if ( y != x ) min.push(y); return x; } /* SpecialStack's member method to get minimum element from it. */ int SpecialStack::getMIN() { int x = min.pop(); min.push(x); return x; } /* main program to test SpecialStack methods */ //execution starts here int main() { SpecialStack s; //push 3 elements and get the minimum s.push(15); s.push(25); s.push(33); cout< Solution //later we create a specialstack class ,which inherits from stack class.there we return the smallest integer //implementation #include #include using namespace std; /* A simple stack class named IntStack with push and pop operations */
  • 8. class IntStack { private: static const int max = 100; int arr[max]; int top; public: //constructor for initialising value of top IntStack() { top = -1; } void push(int x); int pop(); bool isEmpty(); bool isFull(); }; /* Stack's member method to check if the stack is iempty */ bool IntStack::isEmpty() { if(top == -1) return true; return false; } /* Stack's member method to check if the stack is full */ bool IntStack::isFull() { if(top == max - 1) return true; return false; } /* Stack's member method push() to insert an element */ void IntStack::push(int x) { if(isFull()) {
  • 9. cout<<"Stack Overflow"; } top++; arr[top] = x; } /* Stack's member method pop() to remove an element from it */ int IntStack::pop() { if(isEmpty()) { cout<<"Stack Underflow"; abort(); } int x = arr[top]; top--; return x; } /* A class that supports all the stack operations and one additional operation getMIN() that returns the minimum element from stack at any time. This class inherits from the stack class and uses an auxiliarry stack that holds minimum elements */ class SpecialStack: public IntStack { IntStack min; public: //function declarations void push(int x); int pop(); int getMIN(); }; /* SpecialStack's member method to insert an element to it. This method makes sure that the min stack is also updated with appropriate minimum values */ void SpecialStack::push(int x) { if(isEmpty()==true) {
  • 10. IntStack::push(x); min.push(x); } else { IntStack::push(x); int y = min.pop(); min.push(y); /* push only when the incoming element of main stack is smaller than or equal to top of auxiliary stack */ if( x <= y ) min.push(x); } } /* SpecialStack's member method to remove an element from it. This method removes top element from min stack also. */ int SpecialStack::pop() { int x = IntStack::pop(); int y = min.pop(); /* Push the popped element y back only if it is not equal to x */ if ( y != x ) min.push(y); return x; } /* SpecialStack's member method to get minimum element from it. */ int SpecialStack::getMIN() { int x = min.pop(); min.push(x); return x; } /* main program to test SpecialStack methods */ //execution starts here
  • 11. int main() { SpecialStack s; //push 3 elements and get the minimum s.push(15); s.push(25); s.push(33); cout< #include using namespace std; /* A simple stack class named IntStack with push and pop operations */ class IntStack { private: static const int max = 100; int arr[max]; int top; public: //constructor for initialising value of top IntStack() { top = -1; } void push(int x); int pop(); bool isEmpty(); bool isFull(); }; /* Stack's member method to check if the stack is iempty */ bool IntStack::isEmpty() { if(top == -1) return true; return false; } /* Stack's member method to check if the stack is full */
  • 12. bool IntStack::isFull() { if(top == max - 1) return true; return false; } /* Stack's member method push() to insert an element */ void IntStack::push(int x) { if(isFull()) { cout<<"Stack Overflow"; } top++; arr[top] = x; } /* Stack's member method pop() to remove an element from it */ int IntStack::pop() { if(isEmpty()) { cout<<"Stack Underflow"; abort(); } int x = arr[top]; top--; return x; } /* A class that supports all the stack operations and one additional operation getMIN() that returns the minimum element from stack at any time. This class inherits from the stack class and uses an auxiliarry stack that holds minimum elements */ class SpecialStack: public IntStack { IntStack min; public: //function declarations
  • 13. void push(int x); int pop(); int getMIN(); }; /* SpecialStack's member method to insert an element to it. This method makes sure that the min stack is also updated with appropriate minimum values */ void SpecialStack::push(int x) { if(isEmpty()==true) { IntStack::push(x); min.push(x); } else { IntStack::push(x); int y = min.pop(); min.push(y); /* push only when the incoming element of main stack is smaller than or equal to top of auxiliary stack */ if( x <= y ) min.push(x); } } /* SpecialStack's member method to remove an element from it. This method removes top element from min stack also. */ int SpecialStack::pop() { int x = IntStack::pop(); int y = min.pop(); /* Push the popped element y back only if it is not equal to x */ if ( y != x ) min.push(y); return x;
  • 14. } /* SpecialStack's member method to get minimum element from it. */ int SpecialStack::getMIN() { int x = min.pop(); min.push(x); return x; } /* main program to test SpecialStack methods */ //execution starts here int main() { SpecialStack s; //push 3 elements and get the minimum s.push(15); s.push(25); s.push(33); cout<