Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
461 views
in Iteration and Recursion by (49.1k points)
closed by

Design a recursive algorithm to compute a . We constructed an iterative algorithm to compute an in Example 8.5. an can be defined recursively as

1 Answer

+1 vote
by (54.8k points)
selected by
 
Best answer

The recursive definition can be expressed as a recursive solver for computing power(a, n).

The recursive process resulting from power(2, 5)

power (2, 5)

= 2 x power (2, 4)

= 2 x 2 x power (2, 3)

= 2 x 2 x 2 x power (2, 2)

= 2 x 2 x 2 x 2 x power (2, 1)

= 2 x 2 x 2 x 2 x 2 x power (2, 0)

= 2 x 2 x 2 x 2 x 2 x 1

= 2 x 2 x 2 x 2 x 2 = 2 x 2 x 2 x 4

= 2 x 2 x 8 = 2 x 16 = 32

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

...