Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Personal project Q5.

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.

FindAverageAndProduct(a1, ...., an) such that n > 1

Input: A sequence of real values A = (a1, ...., an
Output:, A 2-tuple (average, product) containing the average (average) of all the values and the product (product) of all the values of the elements in A.

Your recursive algorithm should use a single recursive structure to find the average and product values, and should not use two separate instances of a recursive design. You should not employ any global variables.

(a) Produce a pseudo code design for a recursive algorithm to solve this problem.

(b) Draw a call-stack diagram to show the application of your recursive algorithm when called using the sequence = (24, 8, −4, 6, −6, 3).
(c) Write down the set of recurrence equations for your recursive algorithm. Remember that one of the equations should correspond to the recursive algorithm base case.

(d) Using the recurrence equations you gave in your answer for part (c), determine the running time complexity of your recursive algorithm.

 

Personal project Q8.

 

A piece of code implementing a recursive algorithm has been produced, and a student has analysed the recurrences. They have produced the recurrence equations as shown below:

T(n) = T(n-3) + 2(n-3) + c1

T(3) = c2

So the recursive algorithm features a base case when the size of the problem is n = 3. The values of c1 and c2 are constants. You should assume the initial value of n (the size of the problem) is divisible by 3.

Determine the running time complexity of this recursive algorithm. To get the full marks, your analysis should be as complete as possible. You can verify your analysis by modelling the recurrence equations in a program like Excel or MATLAB. Your answer must include:

(a) Evidence of at least two cycles of substitutions to establish the running time function T(n).

(b) A clear statement of the generalisation of that pattern to k iterations of the recursive step.

(c) A statement of the number of iterations required to solve a problem of size n.

(d) A statement of the final overall running time complexity that follows from your previous algebra.

You may find it useful to know that the formula for a sum of an arithmetic sequence of numbers of the form (1,2,3, ... . k) is given by the formula: - attached the photo

 

m=1 m=k m = ?(k+1) /2

 
m=k
Ση
m=1
m =
k(k + 1)
2
expand button
Transcribed Image Text:m=k Ση m=1 m = k(k + 1) 2
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education