Question: a ) Design and analyze a recursive version of the LOGICALAND ( A , B , C , p , r ) algorithm that uscs

a) Design and analyze a recursive version of the LOGICALAND(A,B,C,p,r) algorithm that uscs a divide-and-conquer approach in which the algorithm divides the array elements p.r in half and calls itself recursively on each half. Specifically, give pseudocode for your recursive LOGICALAND(A,B,C,p,r) algorithm. The initial call to your algorithm would pass 1 in for p and n for r . Don't use global variables.
(b) Design and analyze an iterative version of the LOGICALAND(A,B,C,p,r) algorithm.
(c) Perform a line-by-line analysis of your algorithms in (a) and (b) and derive a recurrence T(n) for the running time, where n=r-p+1. You may assume that each linc of pseudocode takes unit time (i.e., ci =1), except, of course, those lines containing nonprimitive operations
(d) Compare the order of growth of the two versions and determine which one is better in terms of order of growth and practical use.
2. Solve the following recurrences:
a)T(n)=3T(n-1)+4T(n-2)+2,n>0, where T(0)=T(1)=1
b)T(n)=2T(n4)+n,n>1, where T(1)=1
c)T(n)=5T(n16)+n12+n,n>0, where T(0)=2
LOGICALAND Algorithm
Understanding the Problem:
Before we dive into the solutions, let's clarify the problem. We're assuming that:
Iogicaland (A,B,C,p,P) is a function that takes three arrays A,B, and C of equal length and two indices p and r .
It computes C[i]=A[i] AND B[i] for all i in the range p to r.
Solution:
(a) Recursive LOGICALAND
LOGICAIAND (A,B,C,p,q
 a) Design and analyze a recursive version of the LOGICALAND(A,B,C,p,r) algorithm

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!