Click any tag below to further narrow down your results
Links
This article discusses two methods for representing hierarchical structures like trees. It contrasts using an array of child pointers with a more memory-efficient approach that employs first-child and next-sibling pointers. Each method has its trade-offs in terms of memory management and access speed.
The article argues that programming languages are rigid tools for implementation, limiting our ability to think creatively about problem-solving. It suggests that mathematics provides a more flexible framework for reasoning and abstraction, allowing programmers to focus on designing solutions before committing to a specific coding approach. This shift in mindset can lead to clearer, more efficient code.
This guide explains how to create and manipulate hexagonal grids using various coordinate systems like offset, axial, and cube. It covers algorithms for distance calculations, neighbors, and more, providing code samples in multiple programming languages. The content is interactive and designed for ease of understanding.
The code presented checks whether a year between 0 and 102499 is a leap year using only three CPU instructions, leveraging advanced bit manipulation techniques and mathematical optimizations to achieve this efficiency. The article explains the complexity behind these optimizations and provides insights into how traditional leap year checks can be significantly sped up by applying clever algorithms and magic numbers.
Branchless programming eliminates control flow branches in code to enhance performance by avoiding costly pipeline flushes in modern CPUs. By using arithmetic and bit manipulation instead of conditional jumps, programmers can create more efficient algorithms, especially in performance-critical applications. The article provides examples in C, demonstrating the advantages of branchless code for operations like calculating absolute values, clamping values, and partitioning arrays.