FindMaxSumSubArray(arr[],low,high){
//The array is empty
if (low > high)
return 0;
//only one element is present in the
array
if (low == high)
return max(0,
arr[low]);
//finding the middle element of the
array
mid = (low + high) / 2;
// find maximum sum crossing to left
leftMax = sum = 0;
for (i = mid; i ≥ low; i--) {
sum += arr[i];
if (sum >
leftMax)
leftMax = sum;
}
//find maximum sum crossing to right
rightMax = sum = 0;
for (i = mid+1; i ≤ high; i++) {
sum += arr[i];
if (sum >
rightMax)
rightMax = sum;
}
// Return the maximum of leftMax, rightMax
and their sum
return Math.max(leftMax + rightMax,
Math.max(FindMaxSumSubArray(low, mid),
FindMaxSumSubArray(mid+1, high)));
}
The worst case time complexity of the algorithm is O(n log n).
Sum of A1l Integers in a List (SUM) Input A list of integers Ala.. b] Output...
For [Select], there are three choices: worse than, the same as, better than Answer the following questions about the computational properties of divide-and-conquer sorting algorithms, based on tight big-Oh characterizations of the asymptotic growth rate of the functions for the running time or space size, depending on the question. Assume that the input sequence is given as a list, and the output sequence is also a list. Also assume a general implementation of the sorting algorithms, as opposed to an...
Consider the following problem: Input: a list of n-1 integers and these integers are in the range of 1 to n. There are no duplicates in list. One of the integers from 1 to n is missing in the list. Output: find the missing integer Let the input array be [2, 4, 1, 6, 3, 7, 8]. Elements in this list are in the range of 1 to 8. There are no duplicates, and 5 is missing. Your algorithm needs...
Q1. Write an algorithm (pseudocode or flowchart) for the following problem. Input: Eight integers Output: the sum of even numbers only. Example: Let the eight integers are 2, 9, 3, 20,5,17, 10, 6 then S = 2+20+10+6 = 38
Algorithm MyAlgorithm (A,B) Input: Arrays A and B each storing n >= 1 integers. Output: What is the output? (Refer to part b below) Start: count = 0 C = 10 for i = 0 to C do { sum = 0 for j = 0 to n-1 do { sum = sum + A[0] for k = 1 to j do sum = sum + A[k] } if B[i] == sum then count = count + 1 } return...
a. Use pseudocode to specify a brute-force algorithm that takes as input a list of n positive integers and determines whether there are two distinct elements of the list that have as their sum a third element of the list. That is, whether there exists i, j.k such that iヂj, i关k,j关k and ai + aj = ak. The algorithm should loop through all triples of elements of the list checking whether the sum of the first two is the third...
urgent L. Consider the following pseudocode for finding binomial coefficients: Binom(n, r) Input: integers n and r Output: n choose r if r-0 or r-n thern return 1 end else return Binom(n-1, r-1) Binom(n-1, r); end running time of this algorithm. Prove your bound for the upper bound. (5 points) Rewrite the above algorithm so that it is efficient. (You have 2 choices!) Analyze the worst case time of your new algorithm. (5 points) Find the edit distance between "SPOKE...
Adder Design FAO FA1 B A Cin B Coub die los - S doo Problem 4.1 (17 points) Design a fast 4 bit ripple-carry adder using the two full adder cells shown in Figure 4 and CMOS inverters. Label the inputs A[3:0), B(3:0), Cin and the outputs S(3:0) and Cout. Assume the delay through an inverter tiny = 4ps, the delay from any input to the full adder carry output is tc. = 7ps and to the sum output is...
For the remainder of this problem, the signals (t) and y(t) denote the input and output, respectively, of a stable LTI system whose (double-sided) frequency response is known to be w-4m 27T 4m H(w) = rect ( 2π with rect(t) denoting the unit-pulse function i.e., rect(t) 1 for lt| < 1/2 and is zero otherwise. Hint: Use sketches as a guide for answering each question most efficiently. (c) (15 points) Determine y(t) for all t given the applied input is...
Lab #4 – Recursive Methods for Generic ArrayList ----- JAVA The problem Use recursion to implement some list functionalities on an ArrrayList of generic type using type parameters in method definition Our goal for this lab is to continue using the divide and conquer approach of splitting a list into its head and tail and keep recursing on the tail (which happens to be smaller). However, instead of trying the approach on a string (a list of characters) we would...
Create a NOTEPAD or PDF file that restates the problem in your own words, specifies what input is needed, what output is expected, the step by step process (algorithm) to get the output from the input, and test data (input for which you know the expected output) for each of the 3 problems given below. You should not write any actual C++ code. Make sure the problem statement is in your own words and is descriptive enough so someone not...