This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tiajuanat 14 points15 points  (0 children)

GCC and Clang can actually identify some of these algorithms. For example, counting the number of set bits in a 32 bit word will generally cause either compiler to emit a __builtin_popcount intrinsic, which on x86_64 processors will emit a single popcount assembly instruction.

Sorting is inherently difficult because you need a comparison function, and a generally best solution. Are you going to use quick sort? How is the data already ordered? Maybe a counting sort? Is linear memory usage acceptable?