Skip to main content

Questions tagged [stacks]

A stack is a Last In First Out (LIFO) data structure. A common use of stacks is to store subroutine arguments and return addresses.

0 votes
0 answers
30 views

Given an array of integers A, the previous smaller element problem is to find, for each position i in the array, the closest element before position i that is smaller than A[i]. This problem can be ...
user1583861's user avatar
0 votes
0 answers
29 views

Suppose you have elements (a,b,c,d), and you want to use bubble sort to sort them(either ascending or descending,doesnt really matter), but you can only use a single memory stack (with infinite ...
Root Groves's user avatar
0 votes
0 answers
25 views

I am trying to understand how the Reduce Operation that PyTorch does in its backward pass for broadcasted tensors actually work under the hood. I am trying to make a cpp library for neural networks ...
Rishabh Agarwal's user avatar
0 votes
1 answer
71 views

I assume we have a simple definition of "expressions" comprised of symbols, some of which map (perhaps polymorphically) to functions and others which hold values, either as variables or ...
Osr Workshops's user avatar
1 vote
1 answer
117 views

Here's the problem: you get an array of numbers. lets say you get an array of 5 numbers: {5,3,4,1,1}. Each of the numbers in the array represent a 'tower'. Your goal is to make the array in the shape ...
monish kumar's user avatar
2 votes
1 answer
73 views

I would like some help with proving the correctness of the following algorithm that solves LeetCode problem 84 of finding the largest rectangle enclosed by the bars of a histogram. For simplicity, we ...
user1446642's user avatar
0 votes
1 answer
223 views

A monotonic stack is a stack whose elements are monotonically increasing or decreasing. To insert an element into the stack you need to remove elements that are greater/less than the provided element ...
Irdis's user avatar
  • 53
1 vote
1 answer
60 views

I am stumped on Engineering a Compiler, 3rd ed. Section 6.3, Review Question 1. The book uses the term 'activation record' to refer to a generalized procedure frame. The question asks: In C, '...
Dean DeRosa's user avatar
1 vote
1 answer
85 views

Had this random thought while running. If I think of a conventional computer program function execution, I think of piece of paper. The program can only run down the page, it can never go backwards. ...
dwjohnston's user avatar
-2 votes
1 answer
194 views

In this problem we consider two stacks $A$ and $B$ manipulated using the following operations ($n$ denotes the size of $A$ and $m$ the size of $B$):   PushA($x$): Push element $x$ on stack $A$.   ...
Avin's user avatar
  • 1
0 votes
2 answers
127 views

This is from the Narasimha's data structure book For nth element (n - 1 index), if we want to push an element, create a new array of size n and copy old array to the new, and at the end assign the ...
tbhaxor's user avatar
  • 208
1 vote
1 answer
151 views

I was playing a puzzle game and started wondering how they implemented their undo feature. The game only has five possible moves, and only when the player does a move does the game state change, but ...
SmileyCraft's user avatar
1 vote
1 answer
105 views

I'm writing a graph traversal function to be used in a garbage collector. To avoid stack overflow, I used a finite state machine. Roughly, it descends into child nodes recursively to mark objects, and ...
DannyNiu's user avatar
  • 448
-1 votes
1 answer
1k views

Were w is any string composed over the alphabet $\Sigma = \{0,1\}$. For the first part of the exercise I've tried decomposing the problem into three different ones, mainly the first one is for the ...
Lorenzo's user avatar
0 votes
2 answers
553 views

...
BeanieBaby's user avatar

15 30 50 per page
1
2 3 4 5
9