C. What is the running time for the following approaches to solving the max sum of a consecutive subset of the array?
Approach 1. initialize the max sum to be the first element in
the array for a subset of size 1
for each consecutive subset of that size, calc the sum of the
subset
if the subset is larger than the current max, update the current
max
repeat for subset sizes 2 through n
Approach 2. Divide the array in half
Return the max of the three values
result of the recursive call on the left half
result of the recursive call on the right half
the sum of the max subarray that spans the two halves (take
O(n))
1) First algorithm is considering all size subarray hence time complexity of this algorithm can be defined as T[n]=summation(I*(n-i+1)) from I=1 to n where I is subarray size solving this we get T[n] =o(n*n)
2)Second algorithm uses divide and conquer approach and using the information calculated in more depth to compute at lower depth from top of recursion tree and at each level of recursion we are computing at cost of n operations thereby time complexity can be represented as T[n]=o(nlogn)
Please upvote.
C. What is the running time for the following approaches to solving the max sum of...
Consider recursive divide-and-conquer algorithms with the following descriptions. For each, determine the running time in Big-Theta notation. If necessary, you may assume that the regularity condition holds. You do not need to prove your result. You may use the Master Theorem (n3) work per Performs 8 recursive calls on problems half the size of the input and performs recursive call. Consider recursive divide-and-conquer algorithms with the following descriptions. For each, determine the running time in Big-Theta notation. If necessary, you...
C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) Last Name (char[]) Age (int) Height in Inches (double) Weight in Pounds (double) You will use pass-by-reference to modify the values of the arguments passed in from the main(). Remember that arrays require no special notation, as they are passed by reference automatically, but the other...
Data Structures and Algorithms C++: I'm having a hard time getting my main.cpp part of the source code (shown below) to output the following: Inserting elements to array list: The list contains 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Deleting elements: The list contains: 2 4 6 8 10 12 14 16 18 20 22 24 this is a programming problem in...
Using Merge Sort: (In Java) (Please screenshot or copy your output file in the answer) In this project, we combine the concepts of Recursion and Merge Sorting. Please note that the focus of this project is on Merging and don't forget the following constraint: Programming Steps: 1) Create a class called Art that implements Comparable interface. 2) Read part of the file and use Merge Sort to sort the array of Art and then write them to a file. 3)...
can i get some help with this program CMPS 12B Introduction to Data Structures Programming Assignment 2 In this project, you will write a Java program that uses recursion to find all solutions to the n-Queens problem, for 1 Sns 15. (Students who took CMPS 12A from me worked on an iterative, non-recursive approach to this same problem. You can see it at https://classes.soe.ucsc.edu/cmps012a/Spring l8/pa5.pdf.) Begin by reading the Wikipcdia article on the Eight Queens puzzle at: http://en.wikipedia.org/wiki/Eight queens_puzzle In...
This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...
Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that will process monthly sales data for a small company. The data will be used to calculate total sales for each month in a year. The monthly sales totals will be needed for later processing, so it will be stored in an array. Basic Logic for main() Note: all of the functions mentioned in this logic are described below. Declare an array of 12 float/doubles...