algorithm - Dividing to groups based on preferences using dynamic programming -


i need design algoritm divide n students 2 groups based on preferences (preference of 1 group, both or none) match preferences as can , divided equally both of groups. should o(n^3) using dynamic programming.

so thought algorithm should iterate through n/2 students , choose preference, rest done. depends on order of choosing n/2 students, don't know if way. if give me hint, thanks.

i should o(n^3) using dynamic programming.

overkill. pick student strongest preference , put him group wants in. repeat until @ least 1 group has reached n/2 students. sorting students strength of preference @ outset o(n log n), rest o(n).

if students don't have preference strengths (we try satisfy greatest number of them), can done in o(n) total time.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -