Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

0 votes
2 answers
77 views

Algorithm for enumerating unique ways to remove leaves from a tree?

I am looking at this challenge: Consider a tree graph, where each vertex can be removed only if it is a leaf node. A parent node may have multiple children nodes. A root node is given, which, as ...
0x13's user avatar
  • 103
3 votes
1 answer
119 views

Given a radius R, find the minimal number of circles to maximize the area where the circles' center belong to a set of points P

Given a list of points, P, and a radius R, find the minimum set of points P that maximizes the area. Where each point represents a circle centered at that point. For example, given the points (3,2), (...
Spectacles4's user avatar
1 vote
1 answer
64 views

How many permutations of an array when created into a number are divisible by 4 or 8?

We have an array of numbers ex. {0, 5, 4, 8, 9}. We have to find the number of permutations that when the array is turned into a number (ex. {6, 8, 3, 2} -> 6832) the number will be divisible by 4. ...
K123's user avatar
  • 23
1 vote
1 answer
185 views

How many distinct digit permutations exist for a specific N-digit number? [closed]

The problem is simple. We have an N-digit digit number (N <= 18) and we need to know all the possible distinct combinations of this number. For example the answer for the number 214 (N = 3) is 6 (...
K123's user avatar
  • 23
1 vote
0 answers
45 views

What diff algorithm relies on finding the longest common prefix and suffix and cursing on the middle substring?

I can't remember where I read this years ago, but there's this variant of a diff algorithm for 2 lines, that finds the longest common prefix and suffix for the 2 lines, and then recurses on the ...
24n8's user avatar
  • 2,126
1 vote
2 answers
81 views

How to determine if there are n consecutive pieces of the same color after every move?

Suppose I have some board game with 2 players. Each player takes turns placing pieces of the board at random locations. A player wins if they have n consecutive pieces in a row (vertically or ...
roulette01's user avatar
  • 2,354
-1 votes
2 answers
106 views

Can I search two arrays for entries `a[i] + b[i] > N` faster than linear time?

I have two sets of arrays, as and bs, all of length n. If I choose an a and a b, I know that a[i] <= N and b[i] <= N for all 0 <= i < n. What's the most efficient way to calculate whether ...
user200783's user avatar
  • 14.1k
-1 votes
1 answer
41 views

What is wrong with my remove-method for a BST?

I am working with Binary Search Trees and I am writing pseudocode for a function removeLessThan that takes node and value as input. The function is supposed to remove all the nodes that have a value ...
H B's user avatar
  • 1
0 votes
1 answer
60 views

Algorithm for allocating whole gold bars amongst thieves by % share of the booty

I have N big gold bars and 1 small gold bar equivalent in weight to some fraction x of a large bar. E.g N = 10 and x = 0.5 then I have 10.5 large bars worth of gold, in 10 large bars and 1 small bar I ...
Greedo's user avatar
  • 5,365
0 votes
0 answers
59 views

Algorithm for most efficient memory write

I have the following problem and need help coming up with an algorithm for it You have value which you must write at a specific address in memory and a counter which starts from 0. The objective is ...
bluehelp8's user avatar
0 votes
1 answer
37 views

Packing a specific number of equally sized rectangles on a grid with obstacles most effectively

I'm trying to find an algorithm that can place a specific number of equally sized rectangles in a grid with obstacles. The rectangles should not overlap and the total distance to a given starting ...
Crater Hater's user avatar
3 votes
2 answers
942 views

Algorithm for combining two trees

I'm looking for an algorithm to merge or combine two trees (if possible). While I've tried to search the web in general, as well as Stack Overflow in particular, I haven't been able to find anything ...
Mark Seemann's user avatar
1 vote
1 answer
66 views

Remembering Lists in backtracking

I am working on a question that requires me to generate an array that includes all of the difference values. Backtracking naturally seemed to be the method to use here but im having some issues with ...
MrKhonsu's user avatar
0 votes
2 answers
269 views

Algorithm to calculate if bottleneck distance between Nodes s and t in a weighted undirected graph is at most W in O(V+E) time

I am currently working through exercise 9.b) on Page 270 of Jeff Erickson's Algorithms book Consider a path between two vertices s and t in a undirected weighted graph G. The width of this path is ...
user1171376's user avatar
0 votes
1 answer
104 views

Is tail call (including tail recursion) compiler/implementation dependent?

Searching tail recursion on the internet I stumbled on How does compiler know whether the recursion is a tail recursion or not and how does it optimize tail recursion. If I understand correctly then ...
duong_dajgja's user avatar
  • 4,256

15 30 50 per page
1
2 3 4 5
130