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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started