This is my implementation of the Barnes-Hut algorithm in 2D for an N-body gravity simulator. The 2D Barnes-Hut algorithm uses a quad-tree to provide a fast approximation for particle interactions.
I've implemented this in Processing, with the controlP5 UI library.
There is a brief video demo on YouTube here.