Need help on questions 6 and 7 thanks!!!

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Need help on questions 6 and 7 thanks!!!

Post by answerhappygod »

Need help on questions 6 and 7 thanks!!!
Need Help On Questions 6 And 7 Thanks 1
Need Help On Questions 6 And 7 Thanks 1 (172.18 KiB) Viewed 112 times
0 X protected-COMP2119_20_2021 (1).pdf (SECURED) - Adobe Acrobat Reader DC (54-bit) File Edit View Sign Window Help Home Tools protected COMP21... Sign In A 5/5 c? DO = 150% - 為·愛 > OQ u. (1970) LU 211..1! De ray UIT POSTLIVC TUTDCIO. Limy 110 PICO VIC Taung price of a stock X on the i-th day (and hence the numbers are ordered chronologically). Write an algorithm max-profit that returns a pair (a, b) such that if one buys stock X on the a-th day and sells it on the b-th day, the maximum profit is made. Give the time complexity of your algorithm in Big-0. Show the derivation of the complexity result. 6. (15%) Give the complexity in (g(n)) for the following five expressions (a) to (e)). Use the simplest g(n) possible. Prove your answer for expression (a) based on the mathemat- ical definition of Big-e. (No need to give proofs for the other expressions.) (a) V8n2 + 2n – 16, (b) log (n) + log3 (na), (C) 20.2" +3" (d) in log n +3n1.5 (e) (n + 1)!+ 2" D 2 7. (a) (8%) Draw a decision tree that describes binary-search when it is applied to search for a number X in a sorted array A[1..4) of four distinct numbers. (Note: there are three possible outcomes of a comparison between two values X and Y, namely, "X<Y", "X =Y", and "X >Y".) (b) (6%) Determine the average number of comparisons binary-search takes on an array of four distinct elements. (Note: this question is meant to be vague. State any assumptions you made.) 850 x 11.00 in
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply