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.
2
votes
0answers
20 views
Balanced parenthesis in Ruby
I'm solving the "Balanced Parenthesis" problem in Ruby, and I came up with this solution.
...
-2
votes
0answers
17 views
Linked List in the form a a stack [on hold]
I created a stack using a linked list, and while most of the code works correctly, I am having issues with the pop method.
The program pushes in numbers correctly, and while it can pop values if they ...
3
votes
2answers
67 views
Stack and Queue implemented with a LinkedList
I am looking for feedback on my implementations of Queue, Stack, and LinkedList using Java ...
-2
votes
0answers
12 views
Postfix Evaluation [closed]
I'm having a hard time understanding whats wrong with my code. When ever I go to run the application program, I get an Empty Stack Exception
...
4
votes
1answer
51 views
Fuzzy Octo Guacamole interpreter
This is my code that interprets my own golfing and esoteric language, Fuzzy-Octo-Guacamole.
It has 2 stacks to store information in, and various operations can be performed on each stack, or both at ...
3
votes
2answers
58 views
Comparing a string using a stack
Let L be the language defined as follows:
The words are made up of strings of a’s followed by b’s.
The number of a’s is always equal to the number of b’s.
Examples of words that belong ...
1
vote
2answers
84 views
Fixed-length Stack in Java
I implemented a fixed-length stack in Java for use in my fractal generator program, an RPN calculator and my esolang interpreter. This is a generic stack, and goes over and above the call of duty in ...
1
vote
1answer
71 views
Java Stack Implementation with Generics
I've written an implementation of a Stack data structure using a linked list.
Stack.java
...
-2
votes
2answers
97 views
Checking for matching delimiters using multiple stacks or counters
I know my algorithm is very naive and slow for this problem. I would like to learn how to improve upon it?
...
0
votes
1answer
39 views
Custom concurrent stack implementation in Java
I don't want to use synchronized for sizeof method, any suggestion to implement the method thread safe?
...
2
votes
2answers
47 views
2
votes
2answers
51 views
Program looks for correct balance of ( [ and { in expression
I'm still new to programming. (First exposure was school about a year ago), and for some reason this problem really gave me a lot of problems trying to solve it. Can you help me understand what I ...
3
votes
1answer
114 views
Tail-recursive call vs looping for a Poker app
I'm developing a Poker app. It is almost done, and I'm looking for improvement. One of the things I wonder is whether I should change how I perform iterations. I currently iterate by using ...
3
votes
3answers
80 views
Sort stack in ascending order
I am using two more helper stacks to sort. Kindly suggest improvements in terms of space and time.
...
1
vote
1answer
39 views
Implement MyQueue using two stacks
I am taking a helper stack, which is used during dequeue. Kindly suggest improvement or some solution with less complexity.
...
10
votes
2answers
855 views
Stack having push, pop and return min in O(1)
I am using a class which is taking care of minimum value so far. Please let me know of any improvements or suggestions.
...
4
votes
1answer
90 views
Reverse Polish Notation Calculator in Java
I created a highly effective Reverse Polish Notation calculator using Java 8, but am uncertain if there are any better ways to handle the problem. Feedback on any evident taboos and bugs is greatly ...
4
votes
1answer
48 views
8
votes
1answer
67 views
Implementing Multi-File Programs in Vitsy
I'm the proud owner of the Vitsy programming language, which I've been working on for some time (except recently, because high school). It's only been used in PPCG so far, but I hope to expand it to ...
3
votes
2answers
84 views
Implementation of stack
Task:
Create a class RPNStack which represents a stack of objects of type
Node. Class RPNStack contains only one private field top of type Node.
Objects of type Node represent data that ...
3
votes
1answer
39 views
Simple stack structure in C
I just started to learn C, and for practicing, I tried to implement a simple stack data structure, and I want to know if I'm making any mistakes, or how could I improve it:
My stack.h:
...
3
votes
2answers
72 views
C Stack data structure
I have implemented a Stack data structure in C and I would like to know if there is something that could be improved.
Stack using linked list:
...
4
votes
2answers
106 views
Sort a stack of numbers in ascending order only using push
I have a stack of numbers ranging from 1 to 1 million representing a pile of numbered DVDs. Given the stack in random order I am to sort the stack by only taking an element from the stack and push it ...
4
votes
2answers
105 views
Given a path to a directory, print the path to the biggest file in it
Here is my code. I simulated a stack rather than used some regular recursive algorithm because I needed to keep track of two variables: the path to the biggest file and its size. Besides I wrote a few ...
2
votes
1answer
68 views
Mutable stack in Racket
I'm learning Racket and have implemented a mutable stack, which is just a bunch of wrappers around an underlying struct containing a size and buffer list (so it's ...
0
votes
2answers
100 views
Infix to postfix implementation using a stack
I have implemented a "infix-to-postfix" function that takes as input a list representing the parsed expression, resulted from applying a certain regular expression to an expression, and I would like ...
3
votes
2answers
85 views
Sorting a Stack in ascending order
Here's my implementation of sorting a stack in ascending order. The problem statement is as follows :
Write a program to sort a stack in ascending order (with biggest items on top).
You may use ...
1
vote
2answers
100 views
Traversing a stack in my DFS algorithm for finding a path in a maze
I am trying to get this code running as fast as possible when traversing through my stack of my DFS currently the input files are like so:
...
0
votes
1answer
30 views
LinkedListy-Stack
I came across this interesting question while reading 'Cracking the coding Interview' and came up with a simple implementation. Any suggestions are welcomed.
Imagine a (literal) stack of plates. ...
3
votes
2answers
85 views
C++ Stack implementation using std::list
I have the following 'interface' to the C++ std::list and I was wondering how I could make it go faster. In particular, it needs to be able to evaluate up to two ...
10
votes
2answers
141 views
SortedStack implementation in Java
This is a data structure that supports the push(), pop() and isEmpty() operations and ...
6
votes
3answers
280 views
Simple Stack Implementation in C
This is my implementation of the stack data type in C language. It is static meaning it does not grow in size. Any suggestions or feedback would be much appreciated.
...
7
votes
2answers
206 views
3
votes
2answers
99 views
Memory leak in Java's stack implementation
Recently I was asked to implement a stack specifically for storing 'int' type data and find memory leaks. Isn't the garbage collector responsible for releasing all the memory? What are the possible ...
6
votes
2answers
375 views
Array-based stack data structure in Java
I've recently been writing simple data structures, even though they exist in the library it helps me understand them a lot better.
...
2
votes
1answer
60 views
Postfix evaluation using a stack in c
I have written a program to evaluate a postfix expression using a stack. I had my stack implementation using a linked list reviewed here, so I am only including the header file here.
I have taken ...
8
votes
4answers
609 views
Array implementation of Java Stack
As an exercise, I wanted to make an array implementation of Stack, including most of the methods from the native Java Stack.
...
10
votes
3answers
420 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 ...
5
votes
2answers
253 views
Stack implemented using a single linked list
I am studying data structures and I have implemented a stack using a linked list.
stack.h
...
4
votes
2answers
754 views
Simple FIFO and LIFO ferry simulator
I am trying to make a ferry simulator with one ferry that works like a stack and another like a queue. I have a working class for stacks and queues with pop/push; I am trying to figure out how to ...
-1
votes
2answers
124 views
Stack using two queues
I have implemented the Stack using two Queues q1 and q2 respectively as shown below in the code. I would like to get you reviews on whether it's an efficient way of implementing it or now.
For Pop ...
3
votes
2answers
567 views
5
votes
1answer
45 views
ADT stack with a dynamic array (revision 1)
Here's the second draft of my ADT stack code which I posted here before after carrying out most of the improvements suggested there.
I decided to expose a function called ...
4
votes
1answer
95 views
Stack implementation using arrays in Java
Could someone please review my code and let me know if there is any scope for optimization for better performance.
...
5
votes
4answers
268 views
ADT stack with a dynamic array
I'm starting to learn about data structures and coding in C. The stack is the simplest of all data structures so I'm trying to implement an ADT stack with dynamically allocated array in C. This ...
4
votes
2answers
191 views
Java Max-Stack implementation to return maximum value in the stack
I have written the below program to write a Java stack implementation. I have added a method which returns the maximum value in the stack, e.g, a pop. The implementation for this is based on the Max ...
8
votes
3answers
416 views
Simple implementation of a generic stack
I'm fairly new to C++ programming. To help I've been writing my own data structures for practice. I'd liked this to be judged as if it was written by a professional, and receive honest feedback. I ...
3
votes
1answer
75 views
Stack implemented with a linked list
I have made a basic stack class utilizing a linked list for data storage and \$O(1)\$ push and pop and just want some basic feedback on the class to see if there is anything basic I missed. It seems ...
5
votes
1answer
679 views
Palindrome using stack
I recently started learning Java, algorithms, and data structures. I am trying to check if a string is palindrome. I would like a review to see where and how I could improve.
...
5
votes
3answers
548 views
Stack Implementation in C++
This is my first template implementation. I'm trying to learn C++ and Algorithms. Any constructive criticism on code quality, readability is welcome. Everyone has their own style, but there are ...