Question: 2. You are required to address a problem that again depends on your matriculation number. First, add the digits in your matriculation number. If

2. You are required to address a problem that again depends on


2. You are required to address a problem that again depends on your matriculation number. First, add the digits in your matriculation number. If this sum value ends between 0 and 3, solve (a); if between 4 and 6, solve (b) with m = 8; else if between 7 and 9, solve (b) with m = 9. Please declare the sum value first before working out the solution. (a) A queue is an abstract data type (ADT) with 5 basic functions, including queue_init(), empty(), enqueue(val), dequeue(), and front(), where val is a data item. The detailed construction of these functions is not specified for the ADT. Using the basic functions of the queue, write a function maxval (q) to find the maximum value contained in a non-empty queue q. Before and after the execution of maxval (q), the content of q should remain unchanged. You may use additional queues to accomplish the task. (b) Consider the following recursive algorithm. Determine the output of the printing process. Justify the printed output in detail. Algorithm test(m) { } if (m == 0) or (m return 1 else { } print(m + " ") == 1) result = 2*test(m // output m + space - print(result + " ") return m*result 2) // output result + space print(m*result + " ") // output result + space // The symbol "+" in print will not be printed. // "+" means and in this case

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 Programming Questions!