×

# finding subsets in an array

 0 Pls suggest an algorithm to find the maximum no. of subset of length k in an array of length m where k<=m , having sum equal to a constant factor... e.g an array of length 11 2 5 1 2 4 1 6 5 2 2 1 k=6, constant factor = sum of largest k values in the array= 6 + 5 + 5 + 4 + 2 + 2 = 24 ?? asked 13 Mar '14, 11:47 2★zargus 176●6●21●36 accept rate: 0%

 0 copy the values into a new array name sbs length k. then find max either with what ever build in function or write it down your self. hint for max func() for i =0 isbs[i+1] max =sbs[i] else if sbs[i] = sbs[i+1] Continue } sbs: short of subset answered 13 Mar '14, 13:50 70●1●2●4 accept rate: 11% i need to find the max no. of subset of length k not max k !! (13 Mar '14, 15:28) zargus2★ @zarqus I edited above answer to make sense, look at it now. Advice: extract the code on sperate lines, it will be more clear. (16 Mar '14, 11:38)
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,658
×1,478

question asked: 13 Mar '14, 11:47

question was seen: 4,760 times

last updated: 16 Mar '14, 11:48