Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+3 In what ways can an MNE improve or change its approach to IHRM?

Answered: 1 week ago