Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

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.

Filter by
Sorted by
Tagged with
3 votes
1 answer
102 views

My previous post: Simple Stack and Deque implementation I have implemented 2 classes for my project similar to stack and deque. This is my second attempt to get advice and evaluation of my code. Maybe ...
vansergh's user avatar
  • 313
1 vote
1 answer
154 views

I implemented a single-linked and double-linked lists (like stack and deque). I would like to receive your feedback on improving the code or maybe some comments. I'm learning C++ for the third month. ...
vansergh's user avatar
  • 313
5 votes
2 answers
519 views

I just learned Adapter Pattern, and I have used STL for some time. I know that the std::stack is a adapter for sequence container (say, ...
John's user avatar
  • 469
4 votes
4 answers
2k views

I implemented a stack data structure without using any libraries or Java API code. ...
Mardson Diego's user avatar
2 votes
2 answers
156 views

The below post is a follow-up of Generic stack implementation. Below follows a header-only implementation of a generic stack (inspired by stb-libraries, following these guidelines: stb-howto.txt). ...
Madagascar's user avatar
  • 10.1k
3 votes
1 answer
262 views

The provided code (a header-only library inspired by stb libraries] defines functions for creating a stack, pushing elements onto the stack, popping elements from the stack, peeking at the top element ...
Madagascar's user avatar
  • 10.1k
10 votes
5 answers
2k views

Objective: Given a string s containing '(', ')', '{', '}', '[', ']' (and other characters), determine if the input string is valid. An input string is valid if: ...
Madagascar's user avatar
  • 10.1k
3 votes
2 answers
149 views

I'm new to Assembly, and this is my very first "project" in Assembly. I wanted to store data (numbers) on the stack, then access and display them. Eventually, this "experiment" of ...
ghost's user avatar
  • 31
3 votes
1 answer
198 views

I am posting a message here because I am new to assembly programming. My goal today was to re-code strdup in assembly, so to save my first parameter which is a ...
knocknock's user avatar
1 vote
4 answers
866 views

I have implemented my stack based on a doubly linked list. The code is tested and works; however, I am interested in any improvement ideas. ...
V_head's user avatar
  • 575
1 vote
3 answers
219 views

I've a simple push/pop implementation in my program: ...
3rdgrade-dropout's user avatar
0 votes
1 answer
90 views

I have slightly refactored the Delayed, concurrent event stack in Java. Now it looks like this: DelayedEventStack.java ...
coderodde's user avatar
  • 32.2k
0 votes
3 answers
232 views

(See the next iteration: Delayed, concurrent event stack in Java - follow-up ) Motivation I was confronted with a task of having "message events" for a GUI program. The use case is as ...
coderodde's user avatar
  • 32.2k
4 votes
1 answer
192 views

I need your expert opinion! In fact, for a Leetcode Problem, I had to code a queue using 2 stacks. It's shown just below and functions well. It is a pretty simple code with peek, pop, push, etc. ...
Thomas H.'s user avatar
2 votes
0 answers
78 views

I followed this algorithm to find strongly connected graph components in C and this code works (I think ... maybe there are bugs I am not aware of). I am wondering can I please get some feedback? ...
Node.JS's user avatar
  • 429
2 votes
3 answers
1k views

Problem: Stacks can be used to check whether the given expression has balanced symbols. This algorithm is very useful in compilers. Each time the parser reads one character at a time. If the character ...
Sol's user avatar
  • 29
2 votes
2 answers
181 views

This is my second implementation of the Stack in C++. I already implemented it as an array-based here. I need a review for it to improve it and improve my coding skill. I also will put this ...
Omar_Hafez's user avatar
2 votes
2 answers
340 views

I wrote my implementation to Stack array based. And I need a review for it to improve it and improve my coding skill. I also will but this implementation on my GitHub account. One more thing: I am not ...
Omar_Hafez's user avatar
2 votes
1 answer
102 views

I spent some time implementing a generic stack in C using macros. Apart from general bugs and bad practices in my code, I was wondering about the viability of an implementation like this that uses ...
vim_overlord's user avatar
5 votes
3 answers
2k views

I have written a program to convert an infix expression to postfix with the help of infix2postfix() function. Please review my code and suggest ways to make it ...
Ultimate's user avatar
  • 173
2 votes
2 answers
96 views

I have made a few functions for some basic stack operations using linked lists. Please review my code and suggest some ways to increase its readability. I would also love to hear ideas on how to make ...
Ultimate's user avatar
  • 173
2 votes
0 answers
52 views

I wrote a simple Linter that checks for matching opening and closing braces for one line of JavaScript. It utilizes a stack to store opening braces found in the line, then compares the first closing ...
dbrokamp's user avatar
5 votes
2 answers
316 views

I have tried to implement a Stack and associated functions in C, in order to understand the data structure better. Just wanted to know what do you think about my code overall. Furthermore, I am using <...
KmerPadreDiPdor's user avatar
7 votes
1 answer
406 views

I have implemented an array based pseudo-generic stack in C using macros. The code works fine for all data types. Is it a good idea to implement such a data structure using macros? array_stack.h ...
DIVIJ_404's user avatar
3 votes
1 answer
580 views

As part of an online programming challenge, I wrote a program that implements a stack of integers, supporting adding and removing elements, finding the last inserted element, and the minimum element. ...
gparyani's user avatar
  • 131
1 vote
1 answer
79 views

I'm new to common lisp. I basically translated a procedural implementation of balanced parenthesis using a stack to common lisp. How can I make my implementation more lispy? ...
Caesar's user avatar
  • 11
-1 votes
2 answers
151 views

stack.hpp ...
Jaysmito Mukherjee's user avatar
2 votes
1 answer
647 views

This is my solution for evaluating postfix expression using a stack. It does work on multidigit numbers, the problem I was struggling with last time. Now it works completely fine. This is the stack ...
KermitTheFrog's user avatar
3 votes
4 answers
428 views

I'm learning C++ by implementing a previous project I did in Python. This is a simple stack machine which evaluates mathematical expressions, e.g. pow(9, 12). The code to run this on the stack ...
redexe's user avatar
  • 31
3 votes
2 answers
137 views

I'm trying to create a stack library from scratch. It stores generic elements which are passed in void* pointers. This is the defined structure: ...
Christian Diekmann's user avatar
3 votes
2 answers
215 views

Got this problem in a coding interview - Get the max value of a stack in O(1). The stack contains numbers only. Please review my solution. ...
G.R's user avatar
  • 39
4 votes
2 answers
1k views

I am learning data structures and below is my implementation of a stack in JavaScript. I didn't want to use built in functions for an array because in JavaScript that would be too easy, so I made my ...
Jordan Baron's user avatar
2 votes
3 answers
412 views

Write a program that uses an ADT Stack to evaluate arithmetic expressions in RPN format. The contents of the stack should be displayed on the screen during evaluation. The allowed arithmetic operators ...
Willow's user avatar
  • 21
7 votes
1 answer
2k views

This is a simple arithmetic calculator, which parses mathematical expressions specified in infix notation using the shunting-yard algorithm. This is one of my personal projects and I would love to ...
Andy Sukowski-Bang's user avatar
1 vote
1 answer
283 views

I'm learning C, and currently I follows C99 standard. Here is my implementation of integer-stack, which is just a stack you can do: push, pop, and print the content ...
RainningTW's user avatar
3 votes
1 answer
367 views

I have a system for going back to a previously-visited page in a Python console application; it works well enough, but I feel that there could be a prettier way of doing it. Does anyone have any ...
Jake Jackson's user avatar
4 votes
2 answers
485 views

I've written a toy example of the concurrent stack which has only three functions push(), peek(), and ...
user37014's user avatar
1 vote
1 answer
280 views

I haven't separated the stack code into its own header and source yet, this is just a proof of concept for now. Haven't chosen better function names yet because I ultimately want to integrate this ...
liewl's user avatar
  • 235
2 votes
0 answers
130 views

I tried following the official solution of LC975 (https://leetcode.com/problems/odd-even-jump/), using a monotonic stack - i.e., I reimplemented their solution (Approach 1) from python in C++. TLDR ...
Mircea's user avatar
  • 322
2 votes
1 answer
185 views

I implemented a Stack in C++ using a dynamic C-style array. I tried sticking to the most important functions a Stack has to have to be usable. This is meant to only be for integers. I appreciate any ...
Tom Gebel's user avatar
  • 360
6 votes
2 answers
696 views

I've been programming in Go and I enjoy how easy it is to create descriptive errors and propagate them up the call stack. I wanted that sort of ease and consistency in C so I created a small error ...
Ollie's user avatar
  • 163
4 votes
1 answer
212 views

The recurring problem to assemble a network packet out of payload, sequence number, header, and other misc. information is mostly solved either on the heap (e.g. appending to a ...
ernestum's user avatar
2 votes
2 answers
3k views

I wrote a dynamic stack in C that uses an array as a structure. I tried to maintain O(1) for push and pop and believe I have done so. I want to know what can be written in a cleaner way and if there ...
guitarcat's user avatar
  • 123
3 votes
2 answers
1k views

This is a small part of a larger program for implementing a limited syntax regular expression constructor using Ken Thompson's construction algorithm. Converting to postfix before the regular ...
user avatar
7 votes
1 answer
6k views

I'm solving a problem on HackerRank where I'm required to implement a simple stack. It's passing all the tests except for the last 4 where it fails due to surpassing the time constraint of 10s. ...
Jonathan Spiller's user avatar
3 votes
1 answer
542 views

Is this a performant strategy to implement a stack in Kotlin to compare and delete values? Expect Create a stack in order to compare an array of asteroids (ASTs) and handle collisions (deletions), ...
adamhurwitz.eth's user avatar
10 votes
2 answers
685 views

I usually use c++ so it may not be best practice for c. This is a stack based toy vm and as a result it is very primitive, and it has no bitwise instructions 64k might be a bit overkill for a toy vm. ...
SomeDude's user avatar
  • 109
1 vote
1 answer
149 views

I have tried Implementing Stacks Using Linked Lists, and would like some tips and tricks regarding optimizations or ways to simplify/compact processes. It has 3 functions, Push, Pop, and Peek (For ...
Anonymous's user avatar
  • 1,244
-3 votes
1 answer
75 views

My CS teacher sent me the following code for implementing the stack. I've been programming for a few years in higher-level languages, but have rather weak experience with C++. I mean, this code just ...
throwaway142's user avatar
9 votes
4 answers
4k views

I've recently started teaching myself basic C++ and decided to implement a simple stack with pointers. ...
Bartek Pacia's user avatar

1
2 3 4 5
9