Skip to main content

Questions tagged [backtracking]

3 votes
2 answers
127 views

I just solved the following Leetcode problem: All Paths From Source to Target Here is my solution: ...
1 vote
1 answer
330 views

With the following recursive code to count leaf nodes of a binary tree, is there any way to make it faster or parallel-computing optimized in time? Python code - (mag(P) = number of leaf nodes of tree ...
-2 votes
1 answer
71 views

I'm trying to solve the following Leetcode problem: https://leetcode.com/problems/path-sum-ii/description/ This solution I came up with is working: https://pastebin.com/ma3DtU5b However, I was not ...
1 vote
1 answer
154 views

In the classic 0-1 knapsack problem, I am using the following (dynamic programming) algorithm to construct a "dp table": ...
0 votes
1 answer
96 views

The following is a Leetcode problem: 473. Matchsticks to Square (https://leetcode.com/problems/matchsticks-to-square/description/) Problem Statement You have an array, matchsticks, of size n, with ...
1 vote
1 answer
305 views

I am working on a problem where I need to find values for nodes in a graph of k-nodes. Here an example: The properties are: Each big node (A..H) is connected to at least one blue node Each blue node ...
2 votes
2 answers
1k views

When dealing with a Recursive Backtracking Algorithm what are the ways to speed it up and what computational hardware is involved? I'm assuming from ignorance that everything is done by the CPU so the ...
8 votes
1 answer
337 views

I am trying to solve this branch and bound problem but I could not come up with any approximate cost function which is better than the cost. Let's say $G$ is a graph of $n$ nodes $\{1, 2, 3, \ldots , ...
0 votes
1 answer
304 views

Problem is to decide if it is possible to partition a given array nums into k partitions. I've written a brute force backtracking algorithm. How do we analyse this algorithm to calculate average ...
4 votes
0 answers
57 views

Let $I$ be a set of items; $C \subseteq \mathcal{P}(I)$ be a set of subsets of $I$, where $\mathcal{P}(I)$ stands for the power set of $I$; And $C(i) = \{ c \in C \mid i \in c \}$ be the set of sets, ...
1 vote
1 answer
353 views

I don't really need hands on coding help, I need to clear my concepts of some of the more complex topics of DS and Algo like NP-Completeness, Computational Geometry, String Matching, Multithreaded ...
0 votes
0 answers
99 views

You have board size and one Knight but what is different is that when you move it you have to duplicate the knight and the 2 duplicates have to be in valid position from the knight This gets repeated ...
3 votes
1 answer
83 views

Say that I have a plasma gun: It's easy to compute the trajectory of the plasma ray starting from the gun. However, another ray may come from afar: As everybody knows, plasma rays are deviated when ...
0 votes
1 answer
98 views

In the slides' based animation given for backtracking, here (with code here, in the web-page ); have few doubts, in the code restated below, and the execution as shown in the call #5. ...
1 vote
0 answers
53 views

I'm working on implementing a puzzle board game called Double-Choco published by Nikoli magazine Where the board is a 2-dimensional matrix with cells that are either white or gray. The goal is to ...

15 30 50 per page
1
2 3 4 5
7