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.
3
votes
1answer
38 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
234 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
69 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
142 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
75 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
25 views
0
votes
1answer
45 views
3
votes
1answer
77 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
31 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
57 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
121 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
317 views
2
votes
3answers
99 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
113 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
233 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
44 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
111 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
377 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
154 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
147 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
171 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
104 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
586 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
449 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
512 views
5
votes
2answers
613 views
3
votes
2answers
170 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
249 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
371 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
134 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
533 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
852 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
232 views
8
votes
6answers
3k views
5
votes
4answers
2k 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
114 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
7k 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
145 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
95 views
Which is a better implementation of a stack data structure (based on an array)?
This is a version I made:
...
4
votes
1answer
149 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
550 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
282 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
266 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
245 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
158 views
Stack with “getMiddle” and “deleteMiddle” operation
Looking for code review, optimizations and best practices.
...
4
votes
1answer
125 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
194 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
412 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 ...