Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

1 . Answer the following: ( a ) Design and analyze a recursive version of the LOGICALAND ( A , B , C , p

1. Answer the following:
(a) Design and analyze a recursive version of the LOGICALAND(A,B,C,p,r) algorithm
that uses 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. Dont 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 line
of pseudocode takes unit time (i.e., c i =1), except, of course, those lines containing non-
primitive 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(n/4)+n, n>1, where T(1)=1
c) T(n)=5T(n/16)+n 1/2+n, n>0, where T(0)=2

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

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

0764532545, 978-0764532542

More Books

Students explore these related Databases questions