patternMinor
When should we construct trees, graphs to analyse an algorithm?
Viewed 0 times
graphstreesalgorithmanalyseshouldconstructwhen
Problem
In many algorithms, it's easy to understand how the algorithm is executed, but as for why it works well and how it can work, it's not very easy to see, sometimes, authors construct trees or graphs to put things analysed in them and use those structures to describe the property of the research object and prove some property of the structures to finally give an explanation why it works well...
When should we use trees, graphs to analyse an algorithm? Or equivalently, what property do trees or graphs do well in describing in theory?
Like, in sort algorithms, many algorithms are analysed with a binary tree, in 2SAT algorithms, the core of the problem is decribed as a graph.
Well, for the problems with fixed mode, the structures can be implied easily, like the problems in OI or leetcode, however, in research such situation is not so likely to happen.
If the best probably answer is: well, when you feel some structures are proper, you can try them, it is hard to say which must be used and which shouldn't. I accept it. I look forward to a more inspiring answer.
When should we use trees, graphs to analyse an algorithm? Or equivalently, what property do trees or graphs do well in describing in theory?
Like, in sort algorithms, many algorithms are analysed with a binary tree, in 2SAT algorithms, the core of the problem is decribed as a graph.
Well, for the problems with fixed mode, the structures can be implied easily, like the problems in OI or leetcode, however, in research such situation is not so likely to happen.
If the best probably answer is: well, when you feel some structures are proper, you can try them, it is hard to say which must be used and which shouldn't. I accept it. I look forward to a more inspiring answer.
Solution
There's no hard-and-fast rule. Use them if they are useful; don't if they are not. As a broad guideline:
Graphs are often useful when you have relationships between a pair of items.
Trees are often useful when you have a hierarchical relationship.
Graphs are often useful when you have relationships between a pair of items.
Trees are often useful when you have a hierarchical relationship.
Context
StackExchange Computer Science Q#124432, answer score: 3
Revisions (0)
No revisions yet.