0% found this document useful (0 votes)
2 views1 page

Stack 1

The document outlines five programming aims related to stack operations in C++. Aim 1 involves implementing push, pop, and top operations in a stack. The subsequent aims focus on removing the middle element from a stack, finding the Next Greater Element in an array, converting a Postfix expression to Prefix, and reversing a string using a stack.

Uploaded by

akatsukigangboys
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Stack 1

The document outlines five programming aims related to stack operations in C++. Aim 1 involves implementing push, pop, and top operations in a stack. The subsequent aims focus on removing the middle element from a stack, finding the Next Greater Element in an array, converting a Postfix expression to Prefix, and reversing a string using a stack.

Uploaded by

akatsukigangboys
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Stack:

Aim 1: Write a C++ program to perform push operation and pop operation and top
element in a stack and display the
output.

Aim 2: Given a stack s, remove the middle element of it without using any additional
data structure.
Example :

Input: s = [10, 20, 30, 40, 50]​


Output: s = [10, 20, 40, 50]

Aim 3 : Given an array arr[] of integers, determine the Next Greater Element
(NGE) for every element in the array, maintaining the order of appearance.
●​ The Next Greater Element for an element x is defined as the first element
to the right of x in the array that is strictly greater than x.
●​ If no such element exists for an element, its Next Greater Element is -1.

Examples:

Input: arr[] = [1, 3, 2, 4]​


Output: [3, 4, 4, -1]

Aim 4: Given a Postfix expression, convert it into a Prefix expression using stack
Examples:
Input : Postfix : AB+CD-*​
Output : Prefix : *+AB-CD

Aim 5: Write a C ++ program to reverse a string using stack.

You might also like