Describe An Algorithm That Takes As Input A List O...

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

  Textbook Solutions Expert Q&A Practice Study Pack 

Find solutions for your homework Search

home / study / math / advanced math / advanced math questions and answers / describe an algorithm that takes as input a list of n integers and finds…

Question: Describe an algorithm that takes as input a list of n integers and… Post a question
Answers from our experts for your tough
homework questions

Describe an algorithm that takes as input a list of n integers and finds the number of negative integers in the list. Enter question

Answers
Continue to post
CautiousDinosaur5511 answered this
Was this answer helpful? 0 0 0 questions remaining
231 answers

A nested loop, or a nested control loop.

I won't write your code for you, but the logic is like
this...

Snap a photo from your


phone to post a question
***

We'll send you a one-time download


counter = 0

link

for each N in (n0, n1, n2, n3...) {

if N < 0 {

counter++
888-888-8888 Text me
} else {

next
By providing your phone number, you agree to receive a one-time
automated text message with a link to get the app. Standard
} // end of if loop
messaging rates may apply.
} // end of for each loop

print "The number of negative integers is ", counter

***

It's nested because the for each loop isn't enough to satisfy the
condition in question (is the array element negative or My Textbook Solutions
not?). You
need to nest the if-else loop to check for that condition.
Comment


Accounting Mechanics of Accounting


Information... Materials Information...
8th Edition 8th Edition 9th Edition
amrita answered this
Was this answer helpful? 0 0
7,591 answers View all solutions

here is the logic

counter = 0

for each N in (n0, n1, n2, n3...) {

if N < 0 {

counter++
} else {

next

} // end of if loop

} // end of for each loop

print "The number of negative integers is ", counter

}
Comment


Anonymous answered this


Was this answer helpful? 1 0
45 answers

Describe an algorithm that takes


as input a list of n integers an

d finds the number of negative

integers in the list.


FOLLOW:
math.berkeley.edu/~isammis/55.S08/
55PS3.pdf
books.google.co.in/books?
isbn=0070648247
ANSWER:
counter = 0

for each N in (n0, n1, n2, n3...)


{
if N < 0
{
counter++
} else
{
next
}
print "The number of negative
integers is ", counter
Comment

  Textbook Solutions Expert Q&A Practice Study Pack 

Practice with similar questions

Q: describe an algorithm that takes as input a list of n integers


andfinds the number of negative integers in the list

A: See answer 100% (1 rating)

Q: Describe an algorithm that takes as input a list of


nintegers and finds the number of negative integers in the
list.

A: See answer

Show more 

Questions viewed by other students

Q: 1. Write an algorithm that takes as input a list of n integers and finds the number of negative integers in the list. Describe
the worst-case of this algorithm in English Then, characterize the asymptotic growth of the worst-case time complexity
of the algorithm. Justify your answer 2. Complete the recursive algorithm to compute the sum of the first n positive
integers Input Output...

A: See answer 100% (1 rating)

Q: Describe an algorithm that takes as input a list of n distinct


integers and finds the location of the largest even integer in
the
list or returns 0 if there are no even integers in the list.

A: See answer 100% (4 ratings)

Show more 

COMPANY LEGAL & POLICIES CHEGG PRODUCTS AND SERVICES CHEGG NETWORK CUSTOMER SERVICE
About Chegg Advertising Choices Cheap Textbooks Mobile Apps EasyBib Customer Service
Chegg For Good Cookie Notice Chegg Coupon Sell Textbooks Internships.com Give Us Feedback
College Marketing General Policies Chegg Play Solutions Manual Thinkful Help with eTextbooks
Corporate Development Intellectual Property Rights Chegg Study Help Study 101 Help to use EasyBib Plus
Investor Relations Terms of Use College Textbooks Textbook Rental Manage Chegg Study
Jobs Global Privacy Policy eTextbooks Used Textbooks Subscription

Join Our Affiliate Program DO NOT SELL MY INFO Flashcards Digital Access Codes Return Your Books

Media Center Honor Code Learn Chegg Money Textbook Return Policy

Site Map Honor Shield Chegg Math Solver

© 2003-2021 Chegg Inc. All rights reserved.

You might also like