fitting n variable height images into 3 (similar length) column layout

How many images? If you limit the maximum page size, and have a value for the minimum picture height, you can calculate the maximum number of images per page. You would need this when evaluating any solution. I think there were 27 pictures on the link you gave. The following uses the first_fit algorithm mentioned … Read more

What algorithm can be used for packing rectangles of different sizes into the smallest rectangle possible in a fairly optimal way?

See this page on the ARC project for a survey of solutions, there is a trade-off between implementation complexity/time and optimality, but there is a wide range of algorithms to choose from. Here’s an extract of the algorithms: First-Fit Decreasing Height (FFDH) algorithm FFDH packs the next item R (in non-increasing height) on the first … Read more

Structure padding and packing

Padding aligns structure members to “natural” address boundaries – say, int members would have offsets, which are mod(4) == 0 on 32-bit platform. Padding is on by default. It inserts the following “gaps” into your first structure: struct mystruct_A { char a; char gap_0[3]; /* inserted by compiler: for alignment of b */ int b; … Read more