Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Let X[1 : n] be an array of real numbers. A positive run is any maximal sequence of consecutive positive numbers in the array, and

Let X[1 : n] be an array of real numbers. A positive run is any maximal sequence of consecutive positive numbers in the array, and the length of a positive run is the number of entries in it. Each positive run is represented as a pair (i,j), where i is the index of the starting element of the run, and j is the index of the ending element of the run.

For example, in the array 10, 5, 7, 0, 3, 4, 1, 2, -1, -2, 8, 12, -5 the runs are: [10, 5, 7] (represented as (1,3)), [3,4,1,2] (represented as (5,8)), and [8,12] (represented as (11,12)).

a. Write a divide-and-conquer algorithm that takes as input a real array X[1 : n], and returns a list of the (i,j) pairs for the positive runs in the input array. Analyze the time complexity of your algorithm.

b. Write a divide-and-conquer algorithm that returns the longest positive run in an input real array. Analyze the time complexity of your algorithm.

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

Step: 3

blur-text-image

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

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago