Question: The following recursive function S: LDR r2, [r0] CMP r2, #0 BNE L1 MOV R7,0 MOV PC, LR L1: LDR R3, [r2 #0] CMP R3,

The following recursive function S: LDR r2, [r0] CMP r2, #0 BNE L1 MOV R7,0 MOV PC, LR L1: LDR R3, [r2 #0] CMP R3, R1 BNE L2 MOV R7,1 L2: SUB SP, #4 STR LR, [SP] CMP R1, R3 BGE L3 LDR R0, [r2 #8] BL SEARCH B L4: L3: LDR R0, [r2, #4] BL SEARCH L4: LDR LR, [SP] ADD SP, #4 MOV PC, LR

where R0 points to a structure that looks like this [data, pointer to left child, pointer to right child] and R1 is an integer

a. What does this code do? Describe it b. Write in C or JAVA pseudo-code a version of this function c. Is this code tail-recursive? Explain it.

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!