Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Devise a recursive algorithm to find the term of the sequence defined bya0=1,a1=2,a2=3andan=an1+an2+an3forn=3,4,5,

Short Answer

Expert verified

The appropriate algorithm is given.

Step by step solution

Achieve better grades quicker with Premium

  • Unlimited AI interaction
  • Study offline
  • Say goodbye to ads
  • Export flashcards

Over 22 million students worldwide already upgrade their learning with Vaia!

01

 Step 1: Recursive algorithm

Recursive algorithms call themselves "smaller (or simpler)" input values and get the output for the current input by performing straightforward operations on the output from the smaller (or simpler) input.

More generally, one can use a recursive method to solve a problem if solutions to smaller versions of the same problem can be used and the smaller versions can be reduced to situations that are simple to tackle.

A recursive algorithm, for instance, can be used to determine the members of a set that has been constructed recursively or the value of a function that has been defined in this way.

02

Find the appropriate algorithm

Here we have given that,

a0=1,a1=2,a2=3andan=an1+an2+an3forn=3,4,5,

and for.

Now, suppose the name of the algorithm as “term”

Let is a positive integer.

Procedure term ( n : positive integer)

When the integer is zero thena0=1

If n = 0 then

Return 1

When the integer is 1 thena1=2

If n = 1 then

Return 2

When the integer is 2 thena2=3

If n = 2 then

Return 3

Using an=an1+an2+an3when is at least 3.

Else returnterm(n1)+term(n2)+term(n3) .

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Study anywhere. Anytime. Across all devices.

Sign-up for free