its depend on compiler how it optimize it . he can make binary search tree for this comparison or perform cascading comparison as in if else case .. so worst case complexity will be as of if- else .
but for this case switch(i) { case 4: //some operation case 5:// some operation case 6 : // some operation } optimization can be done by compiler which need no comparison just need to calculate index which need to comparison... so in above case switch is better than if else. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.