From 25bc915e211f3600ce5c8ade98364fa57bc4263d Mon Sep 17 00:00:00 2001 From: Manasvi Goyal <55101825+ManasviGoyal@users.noreply.github.com> Date: Wed, 29 Sep 2021 14:26:41 +0530 Subject: [PATCH] added get minimum element of stack without extra space --- ...m_element_of_stack_without_extra_space.cpp | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 Data Structures/Stacks/get_minimum_element_of_stack_without_extra_space.cpp diff --git a/Data Structures/Stacks/get_minimum_element_of_stack_without_extra_space.cpp b/Data Structures/Stacks/get_minimum_element_of_stack_without_extra_space.cpp new file mode 100644 index 000000000..79dd99e08 --- /dev/null +++ b/Data Structures/Stacks/get_minimum_element_of_stack_without_extra_space.cpp @@ -0,0 +1,95 @@ +#include + +using namespace std; + +int stack[50], minimum, top=-1,x; + +void push(int x) +{ + if (top==-1) + { + top++; + stack[top]=x; + minimum = x; + } + else + { + if (x>n; + + cout<<"1) Push"<>choice; + switch(choice) { + case 1: { + cout<<"Enter the value to be entered in the stack: "<>x; + push(x); + break; + } + case 2: { + pop(); + break; + } + case 3: { + int minimum=getmin(); + break; + } + case 4: { + cout<<"Exit"<