recategorized by
692 views
0 votes
0 votes

A sequential search operation is performed on an array $A$ for the key value of $'x'$ (ignore quotes). Consider the following piece of assembly language code that uses back patching to perform the sequential search.
i=0;
P: if (i<A.length) goto ____;
Q: goto ____;
R: if (x==A[i]) goto ____
S: goto _____;
T: return i;
U: return -1;

What should be the correct values in the blanks provided ordered from top to bottom?

  1. R T U P
  2. R U T P
  3. P U T R
  4. P T U R
recategorized by

1 Answer

Best answer
2 votes
2 votes

it's like below-

i=0; 
P: if (i<A.length) goto __R__; // if length of the array is not 0 then next we'll check the condition on R.
Q: goto __U__; // if array length is 0 then return -1.
R: if (x==A[i]) goto __T__ // if element is found then return the index.
S: goto ___P__; // else not found go to P.
T: return i; 
U: return -1; 

Option B.

 

selected by
Answer:

Related questions

334
views
1 answers
0 votes
Rahhul A asked Nov 13, 2023
334 views
$\text{ Anyone please explain : }$
1.4k
views
1 answers
0 votes
Tridhara Chakrabarti asked Jan 23, 2017
1,399 views
Please can anyone list the topics to study in this part. The syllabus only states basics of code generation and optimization. Anyone who had prepared gate earlier. What did you study?
1.2k
views
0 answers
3 votes
Ruturaj Mohanty asked Dec 27, 2018
1,232 views
The task of adjusting programs so that they may be placed in arbitrary core locations is called relocation. This task is often performed by the relocating loaders. Given below are the tasks performed ... 3 \: 1 \: 4 \: 2$2 \: 1 \: 4 \: 3$
1.7k
views
1 answers
4 votes
Ruturaj Mohanty asked Dec 27, 2018
1,665 views
Which of the following statements on Viable Prefixes is incorrect?A viable prefix does not extend past the right end of the handleFor any context-free grammar, ... a parser has viable prefixes on the stack no parsing error has been detected