Questions tagged [backtracking]
93 questions
9
votes
1 answer
Conflict Driven Clause Learning backtracking clarification
On the wikipedia page here it describes pretty well the CDCL algorithm (and it seems the pictures were taken from slides created by Sharad Malik at Princeton). However when describing how to backtrack all it says is "to the appropriate point".…
Jake
- 3,810
- 21
- 35
8
votes
1 answer
Branch and bound for minimum linear arrangement
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 , n\}$. For a permutation $f$ of the nodes of $G$,…
Bibek Bhattarai
- 83
- 5
7
votes
1 answer
Aren’t most constraining variable and least constraining value the exact opposite?
So aren’t MCV and LCV the exact opposite?MCV tries to choose the variable with the most constraints on
remaining variables but LCV is opposite: it tries to rule out as least values for other variables as possible
user94485
7
votes
2 answers
Find if a sequence of nodes is yielded by a preorder traversal of a binary tree
Assume we have a sequence of $0$s and $1$s: $n_1, n_2, ..., n_N$, in which $0$ stands for a leaf node, and $1$ stands for an uncertain node that may or may not be a leaf node. How can we check if this sequence is a valid result of a binary-tree…
Harold H.
- 71
- 3
6
votes
1 answer
Neural Network: Why can't we calculate derivatives during forward prop itself?
I have been studying Andrew Ng's Coursera course about Deep Learning. In that he mentions that we calculate the activation functions during the forward pass, and the derivatives $\dfrac{dL}{dz} \ $, $\dfrac{dL}{dw} \ $, and $\dfrac{dL}{db} \ $…
Hemant Singh
- 63
- 4
6
votes
2 answers
How does one formulate a backtracking algorithm
I am new to learning algorithms.
I was reading backtracking algorithm for generating all strings for n bits.
If I dry run the program I know the program is giving right result.
But I didn't understood the logic can anybody please explain? What I…
ManMohan Vyas
- 171
- 1
- 4
6
votes
2 answers
Greedy and backtracking solutions to an arrangement problem with constraints
I'm revising for my finals. I have found a pattern in past papers in terms of a recurring question, reworded coming up every year. But I've no idea what the marker actually wants... I've asked class mates but they all seemed to be confused. One gave…
user26288
- 79
- 1
- 3
5
votes
2 answers
Using backtracking to find all possible permutations in a string
I came across this algorithm in a book, and have been struggling to understand the basic idea. The books says it uses backtracking to print all possible permutations of the characters in a string. In Python, the algorithm is given as:
def bitStr(n,…
ankush981
- 153
- 1
- 1
- 5
4
votes
0 answers
(Historical perspective) CSP and SAT inter-fertilization
[Disclaimer: this is a rather specialized question]
It is known that techniques like Conflict-Driven Clause Learning (CDCL) and back-jumping -- which improved the Satisfiability (SAT) strategies exponentially -- were actually inspired [2] by…
ZakC
- 141
- 1
4
votes
1 answer
Is there a more efficient algorithm than backtracking/dynamic programming?
Consider the following game:
One day a castle is attacked at sunrise (by surprise) by n soldiers.
Each soldier carries a canon and a rifle.
The castle has strength s.
On the first day each soldier shoots his canon at the castle costing the castle n…
user35202
- 231
- 1
- 7
4
votes
0 answers
Cardinalities in set coverings
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, in $C$, containing item $i \in I$.
We state the…
Matheus Diógenes Andrade
- 217
- 1
- 8
3
votes
1 answer
SAT Solving + Turing Machines
I have a couple of questions based on how SAT solvers work. I understand that SAT solvers may employ any/all of the following techniques:
Randomness
Heuristics
Backtracking
SAT is just one example of an NP-complete problem. Is it common to use…
Schmetterling
- 113
- 3
3
votes
1 answer
Why doesn't the Needleman-Wunsch algorithm find solutions that begin with a gap?
I have implemented in C++ the Needleman-Wunsch algorithm for pairwise sequence alignment using the following scores:
+1 for match (regardless of base)
-1 gap penalty
-1 for a mismatch.
Given two sequences of length $m$ and $n$ the algorithm then…
andreas.vitikan
- 215
- 2
- 6
3
votes
1 answer
Time complexity of this solution to N-queens problem
I'm trying to figure out the time complexity of this implementation of classic N-queens problem on geeksforgeeks. The goal is to find just one such non-attacking solution(as opposed to finding all of them). The relevant code is briefed below.
bool…
Eric Z
- 131
- 1
- 1
- 4
3
votes
1 answer
Trajectories with collisions
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 they collide. In fact, they are always deviated…
cdupont
- 131
- 3