Questions: 1 978

Answers by our Experts: 1 850

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Maximum Subarray Sum (Divide and Conquer)

Description

You are given an array containing 'n' elements. The array can contain both positive and negative integers. Determine the sum of the contiguous subarray with the maximum sum.

 

Consider the array {8, -9, 3, 6, 8, -5, 7, -6, 1, -3}.

The maximum subarray will be 3, 6, 8, -5, 7.

The maximum subarray sum will be 3+6+8+(-5)+7 = 19

 

Input Format:

The input contains the number of elements in the array, followed by the elements in the array.

 

Output Format:

The output contains the maximum subarray sum.

 

Sample Test Cases:

Input:

10 8 -9 3 6 8 -5 7 -6 1 -3


Output:

19 

 

Input:

5 8 9 4 5 7

 

Output:

33


convert to prefix:

( AX * ( BX * ( ( ( CY + AY ) + BY ) * CX ) ) )


This is my code C++ for my assignment. Please help me to convert it to C code. Thank you!


#include <iostream>

using namespace std;



float f1(float a){

float s;

if (a<250)

s=a*0.11;

else

s=250*0.11+(a-250)*0.17;

return s;

& }



float f2(float a){

& return f1(a)*1.1;

& }


int main(void)

{

float a;

cout<<"enter the number of kilowatt hours consumed : ";

cin>>a;

cout<<"total amount: "<<f2(a)<<endl;

system ("PAUSE");


}

See more: C


Parking lot charges rs.30.00as a minimum fee to park a vehicle for upto 3hours.an additional charge of re 5.00 per hour will be added if exceed three hours.for 24hours the parking fee are 80.00 write a program to define an array and read the vehicle registration bumber,and hiurs parked for each customer and calculate the parking for n customer and display the output



Accept 10 numbers from the user and calculate their sum.


. A right triangle can have sides whose lengths are all integers. The set of three integer 

values for the lengths of the sides of a right triangle is called a Pythagorean triple. 

The lengths of the three sides must satisfy the relationship that the sum of the squares 

of two of the sides is equal to the square of the hypotenuse. Write an application that 

displays a table of the Pythagorean triples for side1, side2 and the hypotenuse, all no 

larger than 500. Use a triple-nested for loop that tries all possibilities. This method is 

an example of “brute-force” computing. You’ll learn in more advanced computer 

science courses that for many interesting problems there’s no known algorithmic 

approach other than using sheer brute force.


Write a program that prints the result of rolling one fair 

dice.

Hint: use the rand() function with range given in 

arguments to generate a random integer in the desired 

range. 

Add a loop to print the sum of rolling 10 fair dice.

Add a second loop to repeat this N times, printing the 

sum after each trial. 

Maintain an array count[] so that count[k] stores the 

number of times the sum is exactly k.

Review your code and eliminate glitches and unnecessary 

repetitions if any


Compare the methods of determining prime numbers with code and concept.

i.Naive method

ii.square root method

iii.Seive of Eratosthenes


Write a program with analysis to sort in descending manner using 'p' number of values and analyze the complexity.(bubble sort)




Write a C program for the Fibonacci series of n numbers using array.

    Fi = F(i-1) + F(i-2)

 Example: if n =5

F1 = 1 

F2 = 1       

F3 = F2+ F1 = 1 + 1 = 2

F4 = F3 + F2 = 2 + 1 = 3

F5 = F4 + F3 = 3 + 2 = 5


LATEST TUTORIALS
APPROVED BY CLIENTS