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.
6
votes
1answer
83 views
Lock-free bounded stack in C++11
Here is a classical attempt to implement a lock-free stack (based on this article). I rewrote it in C++11 and also tried to add memory orders which I would like to confirm to be correct.
...
4
votes
1answer
80 views
Lock-free bounded stack atomics
I was thinking about using very basic bounded (preallocated) stack to keep track of my threads IDs in correct LIFO order. I was wondering if my implementation is thread safe:
...
12
votes
3answers
985 views
Java and C++ stack implementations with dramatically different performance
I'm developing a small programming language for use in any project I have where I feel a small scripting language could be used well. I've written two emulators for the language, one in C++ and one in ...
2
votes
1answer
94 views
C-style generic stack implementation in C#
I saw a nice generic stack implemented in C, in Stanford's CS107 Programming Paradigms course, so I tried to rewrite it in C#:
...
6
votes
3answers
185 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
232 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
132 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
85 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
364 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
90 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
521 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
144 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
43 views
1
vote
1answer
67 views
3
votes
1answer
104 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
44 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
69 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
153 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
347 views
2
votes
3answers
111 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
133 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
380 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
50 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
119 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
419 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
691 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
200 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
248 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
110 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
759 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
506 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
879 views
5
votes
2answers
1k views
3
votes
2answers
204 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
285 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
618 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
179 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
800 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:
...
3
votes
2answers
1k 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
338 views
9
votes
6answers
5k views
5
votes
4answers
6k 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
138 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
15k 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
76 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
169 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
129 views
Which is a better implementation of a stack data structure (based on an array)?
This is a version I made:
...
4
votes
1answer
216 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
885 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
337 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 ...