Question: Given an array of n integers, design a greedy algorithm to find the partitions that divide the array into k non-empty subarrays with the

Given an array of n integers, design a greedy algorithm to find 

Given an array of n integers, design a greedy algorithm to find the partitions that divide the array into k non-empty subarrays with the equal sum (return false if not found). State your algorithm in English or pseudo code, and running time in big O notation. An example is as Array: [1, 3, -2, 7, 5, 4, 9, -4, 13], k = 4 Results: [1, 3, -2, 7], [5, 4], [9], [-4, 13]. Another example is as Array: [5, -2, -1, 4, 8, -8, 12], k = 3 Results: false Hint: you can calculate the sum for each subarray first.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!