Zig-zag scan an N x N array
Very cool question. Here’s an analysis and an algorithm. A key advantage to using this algorithm is that it’s all done using simple integer calculations; it has no “if” statements and therefore no branches, which means if it were compiled, it would execute very quickly even for very large values of n. This also means … Read more