#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 4A::7.1.3 Bitwise Tricks and Techniques (part 2)
#columns:Front	Back	Tags
TAOCP §7.1.3 Bitwise Tricks and Techniques (part 2): what does it cover?	Part 2 covers the second 30 pages of 7.1.3 (book pages 153 to 183): broadword computing (Algorithm B, a branch-free binary logarithm) and lower bounds on what broadword chains can do, then a run of applications: reachability in digraphs with bit vectors, ternary and other encodings, data structures built on bits (sideways heaps, nearest common ancestors in constant time, navigation piles), negaFibonacci codes for the hyperbolic plane, bitmap graphics (cellular automata, thinning, connected components, filling, drawing conics), branchless computation, and MMIX's MOR and MXOR instructions for shuffles, transposes and CRCs.	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::about
TAOCP §7.1.3 (part 2): why does it matter?	Broadword (SWAR) techniques are the basis of fast string search, SIMD-style parsing and succinct data structures.	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::why
TAOCP §7.1.3 (part 2): what is Algorithm B about?	Broadword computing, a branch-free binary logarithm.	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::algorithm
TAOCP §7.1.3 (part 2), a common trap: “Reading the lower-bound results as practical advice.” What's the catch?	They show limits of a model; the applications later in the section are where the usable code is.	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::trap
TAOCP §7.1.3 (part 2): what traps should you watch for?	<ul><li>Endianness assumptions when packing bytes into words.</li></ul>	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::traps
TAOCP §7.1.3 (part 2), exercise 107 (rated 22, recommended): what is it asking?	Implement the broadword binary logarithm in MMIX for 64-bit words and compare it to the simple method. Translate to C if MMIX is not set up yet.	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::exercise
TAOCP §7.1.3 (part 2), exercise 133 (rated 20, recommended): what is it asking?	Reuse the maximal clique algorithm to list maximal independent sets and minimal vertex covers. Complements are cheap with bit vectors.	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::exercise
TAOCP §7.1.3 (part 2), exercise 150 (rated 25, recommended): what is it asking?	Show the nearest common ancestor method also solves range minimum queries after linear preprocessing. Standard algorithms material.	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::exercise
TAOCP §7.1.3 (part 2), exercise 185 (rated 22, recommended): what is it asking?	Simplify the conic drawing algorithm into a correct line drawer for rational endpoints.	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::exercise
TAOCP §7.1.3 (part 2), exercise 198 (rated 21, recommended): what is it asking?	Encode and decode UTF-8 with bitwise operations. Directly useful.	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::exercise
TAOCP §7.1.3 (part 2), exercise 199 (rated 23, recommended): what is it asking?	Reject overlong UTF-8 forms, and see why accepting them was a real security hole.	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::exercise
TAOCP §7.1.3 (part 2), exercise 215 (rated 21, recommended): what is it asking?	Test whether a 64-bit number is a multiple of 3 in a few instructions, with no division.	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::exercise
TAOCP §7.1.3 (part 2), exercise 132 (rated M27, recommended): what is it asking?	Analyze a bitwise algorithm for listing all maximal cliques of a graph. The stretch.	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::exercise
TAOCP §7.1.3 (part 2): how many exercises, and how are they rated?	218 exercises, rated 10 to 47.	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::exercises
TAOCP §7.1.3 (part 2): what should you be comfortable with first?	<ul><li>7.1.3 part 1</li></ul>	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::prereqs
TAOCP §7.1.3 (part 2): how should you work through it?	Broadword computing builds on last week's tricks. Pick one or two larger applications from the section and code them in C with 64-bit integers, testing against a slow, obvious version.	cracked.guide cracked.guide::phase::taocp-4a cracked.guide::section::7.1.3 cracked.guide::kind::approach
