Design & Analysis of Algorithms
Implement the algorithm in C++ of the following problem
Code:
#include<iostream>
using namespace std;
#define MAX_INTERVAL 3
// An interval has start and end value
struct Interval
{
int start, end;
};
// find the subset and print.To get print of non duplicate subset we can use set
void findSubset(Interval arr[MAX_INTERVAL], int a) {
Interval temp[MAX_INTERVAL];
int p = 0;
for (int i = 0; i < MAX_INTERVAL; i++) {
if (a >= arr[i].start && a <= arr[i].end) {
temp[p] = arr[i];
cout<<"interval is ("<<temp[p].start<<","<<temp[p].end<<")"<<endl; // will print the subset which contains point.
break;
}
}
}
int main() {
//interval array list
Interval arr[MAX_INTERVAL];
arr[0].start = 1;
arr[0].end = 5;
arr[1].start = 2;
arr[1].end = 3;
arr[2].start = 7;
arr[2].end = 12;
//hold the number to find inside interval
int numArr[5] = {1,3,4,8,10};
for (int i = 0; i < 5; i++) {
findSubset(arr, numArr[i]);
}
// time complexity will be O(MAX_INTERVAL) for every indivisual number
return 0;
}
output :
Design & Analysis of Algorithms Implement the algorithm in C++ of the following problem
Design & Analysis of Algorithms Implement the algorithm in Java of the following problem
Design & Analysis of Algorithms Describe a Dynamic Programming Algorithm of the following problem
Design and analysis of algorithms Problem Verify two of the four equations in the Strassen's algorithm: t=P3+P4 and
Introduction to the Design and Analysis of Algorithms Note: Present Algorithms in Pseudocode Give an algorithm to print all the common elements in two sorted arrays of integers, A and B of sizes m and n, respectively. Assume that the numbers in each of the arrays are distinct. Input: Sorted arrays A[m] and B [n]. Output: Common elements. ExA:3.5 6 9 12 17 23; B:2581011 12 15 16 17 19 22 25; Output: 5 12 17
Design And analysis algorithm course . Remarks: In all the algorithms, always explain their correctness and analyze their com- plexity. The complexity should be as small as possible. A correct algorithm with large complexity, may not get full credit Question 2: Give an algorithm that finds the maximum size subarray (the entries may not be contiguous) that forms an increasing sequence.
Design and analysis of algorithms Type in answer Problem 5. Given a sorted array of distinct integers A[1- -n], you want to find out whether there is an index I for which Ai-i. Give a divide-and-conquer algorithm that runs in time O(log n)
Design & Analysis of Algorithms Problem 3. 34.5-1 to prove the subgraph-isomorphism problem is NP-complete.
Design And analysis algorithm course Remarks: In all the algorithms, always explain their correctness and analyze their com- plexity. The complexity should be as small as possible. A correct algorithm with large complexity, may not get full credit Question 3: Given a gas station with two pumps, and a collection of cars 1, 2, n with filling time si for item i (on both pumps). Find a schedule that assigns cars to the two pumps, so that if the first...
Implement the following sorting algorithms using Java: a. Heap Sort. b. Quick Sort. c. Radix Sort. Verify the correctness of each implemented algorithm by sorting the following array: 10, 5, 60, 53, 45, 3, 25,37,39,48
Your task is to design algorithms to solve the following problems. For full credit, your algorithm must run in logarithmic time. Given a number n greaterthanorequalto 1 and a (user-specified) error tolerance e, you want to approximate the squareroot of n to within error tolerance e. Specifically, you want to return an x = Squareroot n that satisfies |x^2 - n| greaterthanorequalto e. For example, to compute the squareroot of n = 2 with e = 0.01, an acceptable answer...