Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q 1 ) This question is concerned with the design and analysis of recursive algorithms. You are given a problem statement as shown below. This

Q1) This question is concerned with the design and analysis of recursive algorithms. You are given a problem statement as shown below. This problem is concerned with performing calculations on a sequence A of real numbers. Whilst this could be done using a conventional loop-based approach, your answer must be developed using a recursive algorithm. No marks will be given if your answer uses loops. FindSumP os And Neg(a1...,an) Input: A sequence of real values A =(az,...,an), such that no values of A are 0. Output: A 2-tuple (sum 1, sum2) containing the sum (suml) of all the positive values and the sum (sum2) of the negative value of the elements in A. Your recursive algorithm should use a single recursive structure to find the sum values and should not use two separate instances of a recursive design. (a) Produce a pseudo code design for a recursive algorithm to solve this problem. Please write your answer in the answer sheet. [5 marks](b) Draw a call-stack diagram in your answer sheet to show the application of your recursive algorithm when called using the sequence =(8,3,-4,3,-8,6).[5 marks)(c) Write down the set of recurrence equations for your recursive algorithm. The recurrence equations in the answer sheet should take a form like this: T(n)=(expression)(expression) otherwise The "otherwise" case here refers to the recursive algorithm base case. [4 marks](d) Using the recurrence equations, you gave in your answer for part (c), determine the running time complexity of your recursive algorithm. Put your analysis in your answer sheet. [6 marks]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions