Algebra of programming
Make it practical: a generic linear-time algorithm for solving maximum-weightsum problems
ICFP '00 Proceedings of the fifth ACM SIGPLAN international conference on Functional programming
Introduction to Functional Programming
Introduction to Functional Programming
Iterative-free program analysis
ICFP '03 Proceedings of the eighth ACM SIGPLAN international conference on Functional programming
A Short Cut to Optimal Sequences
APLAS '09 Proceedings of the 7th Asian Symposium on Programming Languages and Systems
Generation of efficient programs for solving maximum multi-marking problems
SAIG'01 Proceedings of the 2nd international conference on Semantics, applications, and implementation of program generation
Maximum marking problems with accumulative weight functions
ICTAC'05 Proceedings of the Second international conference on Theoretical Aspects of Computing
FLOPS'12 Proceedings of the 11th international conference on Functional and Logic Programming
Hi-index | 0.00 |
Here are two puzzles for you to solve. First, consider the binary tree in figure 1. Take a pencil (I am assuming that this is your personal copy of JFP!) and mark some of the nodes in such a way that the sum of the values of marked nodes is as large as possible. The catch is that you cannot mark all the nodes: if you mark a node, then you are not allowed to mark its parent. Equivalently, no two marked nodes can be contiguous in the tree.The second puzzle is similar though both the datatype and constraint are different. Consider the rose tree of figure 2 (a rose tree is a tree with arbitrary branching structure). Mark some of the nodes so that all marked nodes are now contiguous in the tree. For example, if you mark the root value 4 and the leaf value 1, then you must also mark the values 5 and −3 along the path from 4 to 1. Again the idea is to maximise the sum of the marked nodes. Of course, if all values were nonnegative, the best solution would be to mark all nodes. But they aren't and the maximum sum is obtained only by a judicious choice of marking. Answers to both puzzles are given at the end of the paper.The Maximum Marking Problem (MMP) is the problem of marking the entries of some given data structure in such a way that a given constraint is satisfied and the sum of the values associated with marked entries is as large as possible. By the end of this pearl, you will be convinced that there is a linear-time solution for both the puzzles described above.