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

7
votes
1answer
56 views

Stack using an array

I designed a simple drop-out stack a while back. Basically, I just want to get a few opinions on whether or not this is a good implementation and whether I am understanding the concept of a drop-out ...
6
votes
3answers
584 views

C++ Stack using template

I'm learning C++, so I wrote a stack with the help of templates. I'm wondering if there is anything I can improve or if I did something vastly wrong. Stack.h ...
5
votes
4answers
292 views

A data structure with push(int x), pop(), min() and max() in O(1)

I have written this Java code for a data structure which includes 3 stacks to supports four operations in \$O(1)\$: push(int x), ...
4
votes
3answers
37 views

Balanced expression checker

This program detects whether an expression is balanced or not. I would like to know how I can make this more efficient. ...
-3
votes
1answer
74 views

Implemented Stack using array

I'm going to job interviews soon. How I can improve my coding style and write better code? ...
3
votes
1answer
53 views

Priority stack in Java

I have this (simple) data structure that maintains multiple LIFO stacks. Each such stack is assigned a priority. The less is the value of a priority key, the higher the priority. Pushing operation ...
10
votes
1answer
272 views

Stack implementation using Swift

I would like to request some code review and feedback on a stack implementation using Swift. Disclaimer: I might have not used protocols, optional unwrapping and error and ...
5
votes
1answer
54 views

Stack implementation using linked list in C++

I'd like some feedback for the code I wrote. I haven't programmed in C++ for two years. ...
2
votes
2answers
45 views

ADT Stack with a doubly circular linked list

I have managed to implement an ADTStack with a circular doubly linked list. I would like to know whether there are things I could have done better or, I should ...
6
votes
2answers
200 views

Stack implementation with a linked list

Could anyone provide any constructive criticism? I'm trying to get a jump on data structures before classes start. One thing is that I should add a copy constructor and assignment operator. Changes ...
4
votes
2answers
44 views

ADT Stack with LinkedList

I am currently preparing for my exam and I am trying to implement some abstract data types with linked lists as preparation for the exam. I found an older exam from my prof. and he wants us to ...
8
votes
3answers
254 views

Generic stack in C

I tried to implement a generic stack in C using void pointers and tried to keep it as simple as possible by delegating all responsibility to the caller of the ...
6
votes
1answer
116 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
84 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
1k 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
122 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
186 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
540 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
163 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
121 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
453 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
98 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 ...
5
votes
3answers
1k 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
162 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. ...
1
vote
1answer
71 views

Python script to convert hierarchical JSON to LaTeX itemize

I have the following JSON: ...
3
votes
1answer
111 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
53 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
71 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
172 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
353 views

Stack Implementation

I would like comments on my implementation of a stack: ...
2
votes
3answers
115 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
147 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
428 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
121 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
441 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
1k 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
248 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
289 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
3answers
125 views

Superior improved stack implementation using a linked list

This is a followup to Improved stack implementation using a linked list Simple stack implementation using linked list Please review my hopefully improved stack implementation As suggested by ...
11
votes
3answers
818 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
532 views

Improved stack implementation using a linked list

This is a followup to Simple stack implementation using 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. ...
5
votes
3answers
1k views

Simple stack implementation using linked list

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

Extremely simple stack implementation using a vector

Please review my simple Stack: ...
3
votes
2answers
220 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
324 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
711 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
201 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
899 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: ...