A stack is a last in, first out (LIFO) abstract data type and data structure. Perhaps the most common use of stacks is to store subroutine arguments and return addresses.

learn more… | top users | synonyms

6
votes
3answers
167 views

Stack with getMin method

This should implement a stack that has a \$O(1)\$ getMin method. I used an auxiliary stack. Please provide comments on my solution. ...
5
votes
1answer
40 views

Sort a stack in ascending order

Sort a stack in ascending order. You may only use one additional stack to hold items. Any comments on my solution? Worst case complexities: Memory complexity: O(n) Runtime complexity: O(n^2) Also, ...
2
votes
1answer
60 views

C++ program that recognizes a context-free language

This program (C++) was for a class project. A program that recognizes a given context-free language by implementing a pushdown-automaton (PDA). The PDA recognizes the following language: S → $T$ ...
3
votes
1answer
54 views

Fully Generic C++ Stack Implementation Without Lists, Arrays, or Vectors

I'm trying to write a fully generic Stack in C++. I'm not sure if this is the best way to do this. Right now I know that the Pop method needs improvement since ...
7
votes
2answers
251 views

Implementing a stack and using it to print alternate elements in reverse

Challenge: Implement a stack interface. Specifications: The interface should have ‘push’ and ‘pop’ functions. Your task is to ‘push’ a series of integers and then ‘pop’ and print every ...
3
votes
1answer
75 views

3-stack implementation with a single array

I'm teaching myself data structures and would really appreciate some feedback on my stack implementation. A couple of things I'm not sure if I should be doing: creation of the array and pointer ...
4
votes
3answers
158 views

Stack Implementation in Python

I have written a simple stack implementation and would like some feedback as to what I could improve in my code and coding practices. ...
2
votes
4answers
91 views

Palindromes with stacks

I'm creating a simple function to verify whether or not a string is a palindrome, and must use stacks in solving it. ...
0
votes
1answer
49 views

Python script to convert hierarchical JSON to LaTeX itemize

I have the following JSON: ...
3
votes
1answer
82 views

Stack with Array

Just coded up a simple Stack using an Array in Java for practice. Other than the lack of JavaDoc (still need to learn that part), did I cover all the bases? ...
1
vote
1answer
32 views

Make a new design of Stack with a new function

I am doing some coding exercise, and I am not sure if I have met the requirement. Can someone help me to figure it out? How would you design a stack which, in addition to push and pop, also has a ...
5
votes
1answer
62 views

Popping from a list in state while a condition is true

I'm dealing with data that stores its state as a String, treating the string like a stack. I also have to combine that with error handling. To that end, I'm using ...
6
votes
1answer
129 views

RoundStack Implementation

I just recently made an attempt at implementing what I have been led to understand is called a RoundStack, simply meaning contrary to .NET Stack's default behavior ...
3
votes
2answers
325 views

Stack Implementation

I would like comments on my implementation of a stack: ...
2
votes
3answers
102 views

Stack implementation using vectors and templates with no overflow version 1.3

Below is the code for stack along with one or two extra options. Kindly let me know if there are any concerns/critical issues. Below are the links for previous versions. Version 1.0 Version 1.1 ...
4
votes
3answers
120 views

Stack implementation using vectors and templates with no overflow version 1.2

Below is the code for stack along with one or two extra options. Kindly let me know if there are any concerns/critical issues. Below are the two link for previous versions. Original Version 1.1 ...
5
votes
2answers
255 views

Stack implementation using vectors and templates with no overflow version 1.1

I have modified my code as per the suggestion given by some of the developers. Let me know if there are any further concerns or scope for improvements. Original Version ...
1
vote
1answer
45 views

Stack without use of STL - Version 1.1

I had already posted this question at here and have tried to incorporate some of the suggestions given. Kindly let me know if there are still some concerns/suggestions/improvements in the code ...
4
votes
2answers
113 views

Stack implementation using vectors with no overflow version 1.0

This is an implementation of a stack where I have used vectors. Can anyone please review it and let me know how I can improve this code and overall coding practice? ...
3
votes
3answers
385 views

Stack without use of STL - version 1.0

This is a basic implementation of a stack. Can anyone please review it and let me know how I can improve this code and overall coding practice? ...
0
votes
1answer
216 views

Implementing a stack using a simple array, dynamic array and linked list

I have implemented a stack using simple array, dynamic array and linked list. I am requesting a review of this code. Interface for stack: ...
5
votes
2answers
156 views

Balance braces method

This is a continuation of this question, at least the first part of that question. I want to check if everything in the new code is right or if there are other way to make it better. Exercise The ...
5
votes
4answers
182 views

Stack with a minimum

A practice interview question: How would you design a stack which, in addition to push and pop, also has a function getMin which returns the minimum element? Push, pop and min should all operate ...
2
votes
2answers
106 views

Superior improved stack implementation using a linked list

Please review my hopefully improved stack implementation As suggested by some answers to my previous code, some of the functions can be overloaded to provide versions of return by value, return by ...
11
votes
3answers
618 views

Implementation of an Stack without Linked Lists in C

I'm a beginning C programmer. As an exercise, I have attempted to implement a stack of strings in C. This is my first real exercise working with pointers. I looked at some other similar posts on here, ...
2
votes
3answers
464 views

Improved stack implementation using a linked list

Since my original Stack implementation has lots of bugs that I did not notice, I thought I would recreate and try to improve it. Please review this version. Note ...
5
votes
3answers
583 views

Simple stack implementation using linked list

Please review my Stack using linked list: ...
5
votes
2answers
704 views

Extremely simple stack implementation using a vector

Please review my simple Stack: ...
3
votes
2answers
175 views

Parenthesis checker

I am working on a parenthesis checker program in Java that reads in a text stream from standard input and uses a stack to determine whether or not its parentheses are properly balanced. For example, ...
8
votes
2answers
256 views

Implement a stack using a linked list

I am to implement a stack in C using a linked list. My code is below. My design: I use stack_ prefix to each function, and each function has a ...
7
votes
2answers
432 views

Linked list implementation of a stack

I am working on a basic linked list implementation of a stack of ItemType (currently set to double but can be changed) values. The stack code will then be used in a ...
3
votes
1answer
143 views

XML Writer in C++ - Updated

I recently posted about a basic XML writer in C++ and got a lot of great feedback. Well, I'm back with an updated version of the XML writer that is a bit less basic, but hope it's better than the ...
2
votes
1answer
581 views

Generic Stack implementation in C-style C++

I implemented generic stack in C. Seems to work fine. It doesn't work for strings, though. It was compiled using Visual C++. Implementation: ...
2
votes
2answers
885 views

Unsafe Stack in C#

I was interested to see if it was possible to implement an unsafe stack in C#, so I wrote this: ...
2
votes
3answers
257 views

Delimiter-matching using Stack in Java

Is this code okay? ...
8
votes
6answers
3k views

Reversing a String using Stack

Is this code okay? ...
5
votes
4answers
3k views

Array Implementation of Stack

I've implemented the basic logic of a stack data structure. How can I make this code more generic? Is there any better way to display the stack contents? StackMethods.java ...
5
votes
4answers
117 views

Dynamically-sized stack - follow-up 3

Follow up of - Dynamically-sized stack - follow-up 2 I've took the tips given to me, and what I did now is: Use same case type for type stack and it's functions Returning 1 if push failed due to an ...
7
votes
3answers
9k views

Stack implementation using a linked list

To understand the concept, I implemented the stack operations using a linked list. Please review the code and tell me your suggestions. Node.java ...
6
votes
1answer
61 views

Dynamically-sized stack - follow-up 2

Follow up of - Dynamically-sized stack - follow up I've took the tips given to me, and what I did now is: changing the function names to have a prefix making the ...
4
votes
2answers
148 views

Dynamically-sized stack - follow up

Follow up of - Which is a better implementation of a stack data structure (based on an array)? Please review my stack implementation from before. I've made it dynamically sized if needed and made a ...
2
votes
1answer
98 views
4
votes
1answer
159 views

Stack-based mini-stack

I've created a MiniStack to assist in removing recursion from routines using a manual stack. Obviously if the stack is an object it lives on the heap and its ...
4
votes
4answers
648 views

LinkedList to be used in a stack or queue

This all works. Just wanted to make sure I didn't miss anything. Coming from C++ and working my way through Algorithms, 4th ed. Here is my LinkedList class: ...
6
votes
2answers
287 views

Layer Stack class to practice std::shared_ptr

The following three source files is to define and test a class StackLayer. While it was written in a need for scalable layer-based architecture design, it was also ...
5
votes
4answers
2k views

Stack implementation using only one queue in C

We start with an empty queue. For the push operation we simply insert the value to be pushed into the queue. The pop operation needs some manipulation. When we need to pop from the stack (simulated ...
4
votes
2answers
345 views

Stock span problem

The stock span problem is a financial problem where we have a series of n daily price quotes for a stock and we need to calculate span of stock’s price for all n days. The span Si of the stock’s ...
6
votes
4answers
263 views

Stack with 'getMinimum' operation

Design a Data Structure SpecialStack that supports all the stack operations like push(), pop(), isEmpty(), isFull() and an additional operation getMin() which should return minimum element from the ...
4
votes
1answer
180 views

Stack with “getMiddle” and “deleteMiddle” operation

Looking for code review, optimizations and best practices. ...