@dipankar.... Can u tell us , sumthng more in support of ur ans...??
On Mon, Nov 22, 2010 at 10:40 AM, DIPANKAR DUTTA <dutta.dipanka...@gmail.com> wrote: > both are same .. because any good optimizing compiler generate same assembly > code of them... > > On Mon, Nov 22, 2010 at 9:38 AM, Gene <gene.ress...@gmail.com> wrote: >> >> A good compiler will never generate a switch that is slower than an >> if...else chain. They will analyze the switch cases and pick one of >> several options for code generation. These may include cascaded >> conditional jumps (like if...else code), simple jump tables, segmented >> jump tables (cascaded jumps pick one of several jump tables because a >> single table would be too big), binary searches in a sorted table of >> case values, and perfect hash functions. These are the ones I've >> seen. There may be others. >> >> >> On Nov 21, 8:15 am, shiva <shivanand.kadwad...@gmail.com> wrote: >> > As per my understanding it is compiler depending thing.. >> > >> > what i feel is switch need to evaluate the expression only once but if >> > else if need to evaluate the expression more than once(what if >> > expression stored in variable and then compare...) >> > >> > Does any one please comment difference in speed of switch and if >> > depending on how it is implemented... >> > >> > I heard switch uses jump table for its operation. >> >> -- >> 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. >> > > > > -- > DIPANKAR DUTTA > M-TECH,Computer Science & Engg. > E&C Dept,IIT ROORKEE > Uttarakhand , India – 247667 > ------------------------------------------- > website:http://people.iitr.ernet.in/shp/09535009/Website/index.html > ph no-09045809987 > email:dipan...@iitr.ernet.in > > -- > 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. > -- Lalit Kishore Sharma IIIT Allahabad (Amethi Capmus) 5th Sem -- 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.