Questions tagged [stack]
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.
413 questions
44
votes
2
answers
40k
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 example,...
31
votes
7
answers
67k
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 example,...
27
votes
1
answer
2k
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 ...
27
votes
1
answer
1k
views
How can I make my stack monad faster?
I made a stack monad that lets one manipulate and control values on a stack.
I want to know if it's correct (it seems correct), how to make it faster, and how I could detect stack overflows without ...
25
votes
3
answers
9k
views
Leetcode: Valid parentheses
Leetcode: Valid parentheses
Given a string containing just the characters (, ), {, ...
17
votes
7
answers
4k
views
Stack data structure in Python 3
I have implemented a stack in Python 3, and it works well. If anything needs to be improved, I would appreciate the criticism.
...
16
votes
6
answers
35k
views
Implementing a Stack in Java for a 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 ...
16
votes
4
answers
28k
views
Implementation of stack using pointers
Please review my code and let me know how I can possibly improve it.
...
15
votes
3
answers
2k
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 ...
15
votes
2
answers
117k
views
Stack implementation using linked list
This is a working stack implementation using a linked list. I'm just curious to know if this is a good way of doing it. Any suggestions are welcome. Can we keep track of the number of elements in ...
14
votes
3
answers
2k
views
Stack Implementation in C++ with Exceptions
Appreciate your thoughts and feedback...
Stack.h
...
13
votes
5
answers
3k
views
Stack class in Java 8
I have a exercise where I have to write a Stack class with the push and pop methods. The code compiles and works as it should. Are there better practices to use in my code? Is there something I should ...
13
votes
1
answer
2k
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 ...
12
votes
3
answers
3k
views
Stack implementation with move semantics
I have implemented a basic stack just for fun. I've just started learning about move constructors and assignment and move semantics as a whole, so I would really appreciate some feedback as to whether ...
12
votes
2
answers
7k
views
Managing a programmatically accessible stack trace
VBA has a call stack... but there's no programmatic way to tap into it, which means in order to get a stack trace for a runtime error, one has to manage it manually.
Here's some example code that ...