Question

Consider the algorithm: Algorithm Input: A natural number n (1) let c := n (2) repeat -- (a) let c := c + 4 (3) until c ? 10 (5) return c What does the algorithm return when the input is n = 5 ? What does the algorithm return when the input is n = 4? What does the algorithm return when the input is n = 3?

          Consider the algorithm:
Algorithm
Input: A natural number n
(1) let c := n
(2) repeat
-- (a) let c := c + 4
(3) until c ? 10
(5) return c
What does the algorithm return when the input is n = 5 ?
What does the algorithm return when the input is n = 4?
What does the algorithm return when the input is n = 3?
        
Show more…
Consider the algorithm:
Algorithm
Input: A natural number n
(1) let c := n
(2) repeat
– (a) let c := c + 4
(3) until c ? 10
(5) return c
What does the algorithm return when the input is n = 5 ?
What does the algorithm return when the input is n = 4?
What does the algorithm return when the input is n = 3?

Added by Albert L.

Close

Computer Science and Information Technology
Computer Science and Information Technology
Trishna Knowledge Systems 2018 Edition
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
Consider the algorithm: Algorithm Input: A natural number n (1) let c:=n (2) repeat -- (a) let c:=c+4 (3) until c>=10 (5) return c What does the algorithm return when the input is n=5? What does the algorithm return when the input is n=4? What does the algorithm return when the input is n=3? Consider the algorithm: Algorithm Input: A natural number m (1) let c:=n (2) repeat -- (a) let c:=c+4 (3) until c>=10 (5) return c What does the algorithm return when the input is n=5? What does the algorithm return when the input is n=4? What does the algorithm return when the input is n=3?
Close icon
Play audio
Feedback
Powered by NumerAI
Danielle Fairburn Jennifer Stoner
Ivan Kochetkov verified

Sri K and 99 other subject AP CS educators are ready to help you.

Ask a new question

*

Labs

-

Want to see this concept in action?

NEW

Explore this concept interactively to see how it behaves as you change inputs.

View Labs

*

Key Concepts

-
Key Concept
Premium Feature
Explore the core concept behind this problem.
Play button
Key Concept
Premium Feature
Explore the core concept behind this problem.
Your browser does not support the video tag.

*

Recommended Videos

-
recall-the-linear-search-algorithm-procedure-linear-search-x-integer-a1-a2-an-distinct-integers-i-1-while-i-n-and-x-6-ai-i-i-1-if-i-n-then-location-i-else-location-0-return-location-apply-th-86426

Recall the linear search algorithm: procedure linear search (x: integer, a1, a2, ..., an: distinct integers) i := 1 while (i ≤ n and x 6= ai) i := i + 1 if i ≤ n then location:= i else location:= 0 return location Apply the linear search algorithm to search for the number 3 in the list 1, 5, 3, 9. (a) In this application of the algorithm, what is the integer n? (b) What is the initial value of i? (c) How many iterations of the while loop occur when applied to this list? (d) What is the value of i after the while loop finishes its iterations? (e) What does the algorithm return?

Sri K.

need-help-please-3-consider-the-following-recursive-algorithm-for-computing-the-sum-of-the-first-n-cubes-sn13-23-n3-algorithm-sn-input-a-positive-integer-n-output-the-sum-of-the-first-n-cube-81793

3. Consider the following recursive algorithm for computing the sum of the first n cubes: S(n) = 1Âł + 2Âł + ...... + nÂł Algorithm S(n) //Input: A positive integer n //Output: The sum of the first n cubes if n = 1 return 1 else return S(n - 1) + n * n * n a. What is its basic operation? b. Set up and solve a recurrence relation for the number of times the algorithm's basic operation (multiplication) is executed. c. How does this algorithm compare with the straightforward nonrecursive algorithm for computing this function?

Akash M.

1-consider-the-following-recursive-algorithm-algorithm-qn-input-a-positive-integer-n-if-n-1-return-1-else-return-qn-1-2-n-1-a-determine-what-this-algorithm-computes-bs-set-up-a-recurrence-re-46652

4) Consider the following recursive algorithm Algorithm Q(n) //Input: A positive integer n if n = 1 return 1 else return Q(n - 1) + 2 * n - 1 a. Determine what this algorithm computes. b. Set up a recurrence relation for the number of multiplications made by this algorithm and solve it. c. Set up a recurrence relation for the number of additions/subtractions made by this algorithm and solve it.

Akash M.


*

Recommended Textbooks

-
Computer Science and Information Technology

Computer Science and Information Technology

Trishna Knowledge Systems 2018 Edition
achievement 1,734 solutions
Introduction to Programming Using Python

Introduction to Programming Using Python

Y. Daniel Liang 1st Edition
achievement 1,657 solutions
Computer Science - An Overview

Computer Science - An Overview

Glenn Brookshear, Dennis Brylow 12th Edition
achievement 1,088 solutions

*

Transcript

-
00:01 For the solution of a in this application of algorithm what is the integer n.
00:07 So, here n is the number of items in the list.
00:20 So, n equals to 4 as per the list 1 5 3 9.
00:30 For the solution of b what is the initial value of i.
00:34 So, the initial value of i is 1...
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Join the community

18,000,000+

Students on Numerade


Trusted by students at 8,000+ universities

Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever