• Interactive Poisson Blending on GPU
    Interactive Poisson Blending on GPU
  • 404 Not Found In Two Triangles
    404 Not Found In Two Triangles
  • Simplest and Fastest GLSL Edge Detection using Fwidth
    Simplest and Fastest GLSL Edge Detection using Fwidth

Tag: C++

N Queens Problem Revisit using Bit Operations

Finally, I have some time to revisit the N queens problem using bit operations. The following functions could solve 11 queens in 1 second:

So far to me, this is the most efficient algorithm for N queens. The code is mostly self-explenary. Please comment if anything cannot be understood.

 


Timer: How to Measure Execution Time in C++ 11

Timer is important for measuring speed-ups or elapsed time for custom algorithms. We used to import <ctime> and measure time with:

However, clock() measures CPU time, not actual time elapsed (which may be much greater) according to this StackOverFlow. Hence, here provides my code snippets to measure execution time in C++ as a DebugTimer Class….


Quicksort, Mergesort, and Bucket sort in C

Quick Sort This is used in research code when built-in qsort does not satisfy the demands.

K-th element Qsort can be used to find the Kth smallest element a[k]:

Use partition to sort 0, 0, 0, 1, 1, 2, 2, 2…

  Merge Sort Linked List Version Here is the merge sort…