title: Interview : function pointers vs switch case
body: <p>During my Interview, I was asked to implement a state machine for a system having 100 states where each state in turn has 100 events, I answered 3 following approaches:</p>
  
  <ul>
  <li>if-else </li>
  <li>switch-case </li>
  <li>function pointers</li>
  </ul>
  
  <p>If-else is obviously not suited for such a state machine, hence main comparison was between switch-case vs function pointers, here is the comparison as per my understanding:</p>
  
  <ul>
  <li>Speed wise both are almost same.</li>
  <li>Switch-case is less modular than function-pointers</li>
  <li>Function-pointers has more memory overhead.</li>
  </ul>
  
  <p>Could someone confirm if above understanding is correct ?</p>