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.
1
vote
1answer
30 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
56 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
112 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
291 views
2
votes
3answers
96 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
106 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
209 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
43 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
108 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
364 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
74 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
130 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
155 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
100 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
519 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
419 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
354 views
5
votes
2answers
337 views
3
votes
2answers
126 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
240 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
254 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
120 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
437 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
805 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
164 views
8
votes
6answers
3k views
5
votes
4answers
997 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
111 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
4k 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
141 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
80 views
Which is a better implementation of a stack data structure (based on an array)?
This is a version I made:
...
4
votes
1answer
122 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 ...
6
votes
1answer
61 views
Traversal of descendants using stack [closed]
I have a type Unit which has a property ChildUnits that returns the children of the unit instance, as a ...
4
votes
4answers
450 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
255 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
1k 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
230 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
227 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
118 views
Stack with “getMiddle” and “deleteMiddle” operation
Looking for code review, optimizations and best practices.
...
4
votes
1answer
106 views
Implement stack using a linked list
I am trying to implement Stack using a linked list. Looking for code-review, best practices and optimizations.
...
7
votes
1answer
145 views
Find the Next Greatest Element
Given an array, print the Next Greater Element (NGE) for every element. The Next Greater Element for an element x is the first greater element on the right side of x in array. Elements for which no ...
7
votes
2answers
409 views
Stack challenge - improving memory consumption
I am working on this problem:
Stacks
Imagine, that you are employed by a software development company. You
work now on the famous "D++ project", which is devoted to the creation
of a new ...
3
votes
2answers
400 views
Class that implements a queue using two stacks
I am looking for a review of my code that implements a MyQueue class which implements a queue using two stacks.
...
3
votes
2answers
183 views
How is my Java code for stack implementation?
The following example shows how to implement stack by creating user defined push() method for entering elements and pop() method ...
12
votes
6answers
3k views
Implementing a Stack in Java for Technical Interview
This code is based off the Stack implementation in Chapter 3 of Cracking The Coding Interview. I modified the code to make it compile and give me the correct output. I'd appreciate any feedback on ...
0
votes
2answers
129 views
Stack implementation using a queue
I've implemented a stack using a queue.
Time complexity:
\$O(n)\$ - push(), where n is the number of elements in the queue
\$O(1)\$ - ...
6
votes
2answers
2k views
STL Stack Implementation
I implemented std::stack from the STL for deeper understanding of the language and memory since I still am only a beginner. I implemented the stack using a singly ...
4
votes
3answers
241 views
How does this naive stack implementation look?
Consider this naive stack implementation in Elixir:
...
5
votes
1answer
177 views
Managing People in a SimCity Clone
So I am working through a few different game ideas as I learn programming, and I could definitely use some feedback on my latest project. This is a simple SimCity clone. So far I have created a City ...