Posts

Daily Coding Problem: Problem #1780 [Medium]

Daily Coding Problem: Problem #1780 [Medium]

Bruce Ediger

Problem statement

This problem was asked by Cisco.

Given an unsigned 8-bit integer, swap its even and odd bits. The 1st and 2nd bit should be swapped, the 3rd and 4th bit should be swapped, and so on.

For example, 10101010 should be 01010101. 11100010 should be 11010001.

Bonus: Can you do this in one line?

I Saw It on I-25

Bruce Ediger

I’ve been commuting somewhat less than 3 days a week, from Fort Collins to Denver and back. I’ve seen some mighty strange stuff.

Mergesort Investigation 8 - bottom up

Mergesort Investigation 8 - bottom up

Bruce Ediger

I thought that since the purely recursive implementation of mergesort didn’t show weird, abrupt performance drops, traversing linked lists (no matter what order the nodes appeared in memory) also did not show abrupt performance drops, and that node size in memory caused different performance oddities, that the iterative implementation’s memory access patterns might be the cause.

Pop Quiz Paradox

Bruce Ediger

When my kids were small, I would tell them about famous philosophical or mathematical paradoxes.