I am studying some old past test questions. Is this search tree correctly pruned?
Asked By : gbhall
Answered By : gbhall
I was close. Here's an answer from my tutor which makes sense:
There should be some pruning on the last branch.
When descending into the third branch from the main node, the top criteria is >=12. The first sub-tree of that node sets its value to 13 (>12), so the next sub-tree is expanded. When the value of the node changes to 12 after the second sub-tree is completed, the condition triggers.
It doesn't matter what the value of the last sub-tree is. If the value is > 12 then min will choose it and max will choose the previous top-level sub-tree (value 12). if the value is <= 12 then min will choose 12 and the overall value doesn't change. For this reason the last two nodes (both value 10) are pruned before being examined.
I think he may have slightly messed up his wording in the last paragraph, but basically we are not going to improve on the 12, as min will select 12 and less, so there's no point in checking anymore.
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/11308
0 comments:
Post a Comment
Let us know your responses and feedback