Question: 3. C# switch statement plc question Consider the following C switch statement: switch (ch) {case'n': new_cmd(); case 'o': open_cmd(); case 'c': close_cmd(); case 's': save_cmd();

3. C# switch statement plc question  3. C# switch statement plc question Consider the following C switch

Consider the following C switch statement: switch (ch) {case'n': new_cmd(); case 'o': open_cmd(); case 'c': close_cmd(); case 's': save_cmd(); case 'a': save_as_cmd(); case 'g': save_as_web_page_cmd(); case 'h': search_and(); case 'r': versions_cmd(); case 'b': web_page_preview_cmd(); case 'u': page_setup_cmd(); case 'v': print_preview_cmd(); case 'p': print_cmd(); case 'd': send_to cmd(); case 'i': properties_cmd(); (a) How many comparisons would be performed, on average, if linear search were used to implement this switch statement? (Assume that ch always matches one of the case values listed and that each value is equally likely.) A "comparison" involves testing whether the value of ch matches one of the case values. (b) Repeat part (a) using binary search instead of linear search. Assume that a single comparison can test whether ch is less than, equal to, or greater than a particular case value. (c) Would it make sense to use a jump table to implement this switch statement? Why or why not

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!