Need help with Python Programming Questions about output

User Generated

nnebaw9999

Computer Science

Description

Q8-9.pdf

I don't understand these two questions (see pdf). Could someone please give me a detailed explanation on how you find the answer?

Unformatted Attachment Preview

CS177 Spring 2015 Final exam - Page 6 of 29 Fri 05/08 7:00p - 9:00p 8. What is the output of the following program def lucasNumbers ( n ) : i f ( n==0) : return 2 i f ( n==1) : return 1 return lucasNumbers ( n 1) + lucasNumbers ( n 2) print ( lucasNumbers ( 5 ) ) A. 5 B. 7 C. 8 D. 11 E. 18 9. What is the space complexity of this algorithm that reverses a List (input is a list of length n) def r e v e r s e ( l i s t 1 ) : newlist =[] for i in range( 1, len ( l i s t 1 ) 1, 1) : n e w l i s t . append ( l i s t 1 [ i ] ) return n e w l i s t A. O(1) B. O(log(n)) C. O(n) D. O(n*log(n)) E. O(n2 )
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer


Anonymous
Just what I needed. Studypool is a lifesaver!

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags