Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

pseudocode:

void recursive('k'){ // 'k' and 'i' vertices
  sumA = 0;
  sumB = 0;
  for each non visited 'i' neighbor do{
     recursive('i');
     sumA = sumA + b['i'];
     sumB = sumB + max(a['i'], b['i']);
     }
  a['k'] = 1 + sumA;
  b['k'] = sumB;
  }


void main(){
 a = b = 0; //initialize tables with 0 (zeros)
 recursive('X');  //let 'X' be an arbitrary root
 cout<<max(a['X'], b['X']);
 }

need proof that max(a['X'], b['X']) is the cardinal of the maximum independent set in the tree. What am I missing ?

Thank you in advance.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

The element $a[i]$ is the size of the maximal independent set in the subtree rooted in $i$ which contains $i$.

The element $b[i]$ is the size of the maximal independent set in the subtree rooted in $i$ which doesn't contain $i$.

The algorithm computes these recursively, and then choose the maximal of the two at the root.

share|improve this answer
    
are you suggesting that this would be enough to say in order to prove that it's the maximal ? –  sdadffdfd Oct 31 '10 at 10:38
    
You have to prove that the algorithm calculates both arrays correctly, but that's not difficult. –  Yuval Filmus Oct 31 '10 at 18:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.