Tagged Questions

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

2
votes
2answers
77 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 ...
9
votes
3answers
411 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
378 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
247 views

Simple stack implementation using linked list

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

Extremely simple stack implementation using a vector

Please review my simple Stack: ...
3
votes
2answers
100 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
207 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
179 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
97 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
276 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
759 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
118 views

Delimiter-matching using Stack in Java

Is this code okay? ...
9
votes
6answers
2k views

Reversing a String using Stack

Is this code okay? ...
4
votes
4answers
409 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 ...
6
votes
3answers
1k 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
134 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
65 views
4
votes
1answer
82 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
59 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
355 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
189 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
396 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
173 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
191 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
89 views

Stack with “getMiddle” and “deleteMiddle” operation

Looking for code review, optimizations and best practices. ...
4
votes
1answer
77 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
102 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 ...
6
votes
2answers
401 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
225 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
167 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
2k 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
118 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
1k 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
220 views

How does this naive stack implementation look?

Consider this naive stack implementation in Elixir: ...
5
votes
1answer
157 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 ...
7
votes
3answers
6k views

Stack implementation using an array

I am trying a stack implementation using an array. I want to know if this approach is OK or if there is a logical problem. This program is working fine. ...
3
votes
1answer
92 views

Infix to postix conversion

I'm looking for code review, optimizations and best practices. Also verifying complexity to be O(n), where n is the string length. ...
9
votes
3answers
2k views

Implementation of stack using pointers

Please review my code and let me know how I can possibly improve it. ...
19
votes
1answer
411 views

Stack implemented using linked list in x86_64 assembly

I wrote a stack implementation using a singly linked list in x86_64 assembly. This stack supports the usual push/pop operations ...
11
votes
2answers
481 views

Balanced parentheses

Given an expression string exp, write a program to examine whether the pairs and the orders of "{","}","(",")","[","]" are correct in exp. For ...
12
votes
7answers
4k views

Check for balanced parentheses

Given an expression string exp, write a program to examine whether the pairs and the orders of "{","}","(",")","[","]" are correct in exp. For ...
6
votes
1answer
184 views

Functional, but not recursive, tree traversal

To learn tree traversal i implemented os.walk, tail-recursive and stack-based. Unfortunately Python doesn't support tail call optimization. How do i rewrite my ...
4
votes
2answers
180 views

Retrieve min from stack in O(1)

I wrote some Python code to solve the following problem. I'm curious to see if someone else can find a better solution, or critique my solution. How would you design a stack which, in addition to ...
7
votes
2answers
484 views

Int stack implementation

...
3
votes
2answers
139 views

Dynamic stack in C - new version

Not long ago, I posted this dynamic stack for review. Now I wrote a new version, which is hopefully a better one. Please take a look and let me know how I could improve performance and increase code ...
5
votes
3answers
690 views

Dynamic stack implementation

I wrote this code for a dynamic stack and would like to know what would be better if done differently. It can increase memory by a percentage and/or fixed value when needed. It can also be set to not ...
-2
votes
2answers
3k views
2
votes
2answers
4k views

Postfix evaluation using a stack

I just wrote the code to evaluate a postfix expression and would like it if someone reviews it for me, it works perfectly fine but I'm having trouble adding the character "=" at the end. ...