COMPILER DESIGN

ADVANCED TOPICS IN COMPILER DESIGN

CODE GENERATION FOR OBJECT ORIENTED LANGUAGES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Consider the following pseudocode procedure, where the index of the integer array x starts at 0.// precondition:0 ≤ y < z < the length of the integer array xint sumItems ( int[] x, int y, int z ) int s ← 0 int i ←y while ( i < z ) s ←s + x[i] i ← i + 1 end while return send sumItemsConsider the following code segment.int[] a ← {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}int r ← sumItems ( a, 2, 5 ) + sumItems ( a, 4, 6 )What is the value of r after the code segment is executed?
A
17
B
23
C
29
D
24
Explanation: 

Detailed explanation-1: -Expert-Verified Answer p = 4, q = 7, r = 13.

Detailed explanation-2: -Expression is a-b and we get the answer as 456–45=411. Hence the output printed is 411.

Detailed explanation-3: -The purpose of using pseudocode is an efficient key principle of an algorithm. It is used in planning an algorithm with sketching out the structure of the program before the actual coding takes place.

Detailed explanation-4: -Let min = 0 and max=n−1. If max<min, then stop; target is not present in array. Compute guess as the average of max and min, rounded down so that it is an integer. If array[guess] equals target, then stop. More items

There is 1 question to complete.