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.
4
votes
3answers
108 views
A simple array-based Stack class in Java, what are my mistakes?
I have created a simple array-based Stack class with some methods like the actual Stack in Java.
I am testing this for mistakes, but since I am learning Java and my tests may not be as comprehensive ...
0
votes
2answers
56 views
symmetric string checking [closed]
I wrote this routine in C to check the symmetry of a string using only a stack.
(This is absolutely for educational purpose in our Theory Of Computation Class)
Anyways, does this look right?
For some ...
5
votes
3answers
151 views
implementation of a stack in C
Below is my implementation of a stack in C. Is it correct? And/or is there anything that I should fix to make it better in any way?
stack.h
#ifndef STACK_H
#define STACK_H
#define EMPTY_STACK -1
...
2
votes
3answers
110 views
How to improve my stack implementation (uses array)?
Below is an implementation of a stack data structure using arrays. Please comment on the same. How can it be improved?
Specific improvements I am looking for:
Memory leaks
C++ style
Making code run ...
4
votes
2answers
123 views
Java and stacks: correct implementation?
I created this very simple stack concept's implementation.
Could you tell me if it is correct and clean? Do you see any bad coding habits?
public class MyStack
{
private static final int ...
1
vote
4answers
575 views
Is this good code? Linked List Stack Implementation
I have used the following code for a stack implementation. The top keeps track of the topmost node of the stack. Now since top is a data member of the node function, each node created will have a top ...
3
votes
1answer
232 views
Tree-traversal without recursion
I wrote the following code for printing all the paths to the leaf nodes in a tree (NOT a binary tree ) without using recursion. I have used a stack and performed dfs on the tree. Whenever I reach a ...
4
votes
3answers
377 views
Simple stack implementation, how can I improve the code?
I am not experienced in C++, and wrote the below code for implementing a stack data structure using a linked list.
Can you please point out any flaws, errors, stupid mistakes, general improvements ...
7
votes
0answers
165 views
How can I make my stack monad, (in Haskell) faster?
I made a stack monad, (in Haskell), 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 ...
3
votes
1answer
116 views
Concurrent stack implementations in Ruby (relative performance of mutexes/CAS?)
This code is very simple, but it is intended as an experiment in the relative performance of mutexes/CAS on different platforms. The latest version can always be found at:
...