• :00Days
  • :00Hours
  • :00Mins
  • 00Seconds
A new era for learning is coming soonSign up for free
Log In Start studying!

Select your language

Suggested languages for you:
Answers without the blur. Sign up and see all textbooks for free! Illustration

Q31E

Expert-verified
Discrete Mathematics and its Applications
Found in: Page 203
Discrete Mathematics and its Applications

Discrete Mathematics and its Applications

Book edition 7th
Author(s) Kenneth H. Rosen
Pages 808 pages
ISBN 9780073383095

Answers without the blur.

Just sign up for free and you're in.

Illustration

Short Answer

Devise an algorithm that finds the first term of a sequence of integers that equals some previous term in the sequence.

An algorithm of determining the first term of a sequence of inters that equals some previous term in the sequence.

procedure repeated ( a1,a2,...,an: list of integers having n > 0 )

j=2 position : =0

while jn and position = 0

will show the position of the first term of a sequence of integers that equals some previous term in the sequence.

See the step by step solution

Step by Step Solution

Step 1: Write the steps required to follow to determine Algorithm.

First set j equals to 2 and position equals to 0 .

Then use while loop to examine given list and condition for while loop is jn and position = 0 .

In while loop set k equal to 1 and use another while loop with condition k < j and position + 0 . Compare aj and ak using the if loop with condition aj=ak and when if loop becomes true, return then position as and when if loop becomes false then increase k by 1 . After the completion of if loop increase j by 1 .

Here the position is our required answer.

Step 2: Determine the steps of the algorithm.

By using the above conditions, the algorithm finds the first term of a sequence of inters that equals some previous term in the sequence can be written as:

procedure repeated ( a1,a2,..,an : list of integers having n > 0 )

j = 2

position : = 0

while jn and position = 0

Recommended explanations on Math Textbooks

94% of StudySmarter users get better grades.

Sign up for free
94% of StudySmarter users get better grades.