Binary Tree Rebuilder

  • 767 words

Imagine you have a Binary Tree, with those characteristics: Nodes do not respect any order relation - In other words: it's not a Binary Search Tree of any kind Every node appears once and only once within the tree A nice Binary Tree Then, your little brother passes by your desk and, to upset you, deletes the tree from your ... read more

Serverless chat to reduce office distance

  • 471 words

This idea comes out for an old university-time idea: to write a serverless chat application. Of course, I’m aware of the complications and the problems that using Broadcasting could create, so this problems would be took in consideration by design. But why now? I was thinking of a way to reduce the “office distances”: making easy to connect with a ... read more

iPad Simulator in Video and Comments

  • 343 words

I would have just posted it on Twitter, but I have some comments about this video. </param></param></param></embed> One of the first video of the iPad Simulator Watch it in Full screen at 720p: it help "feeling" the proportions used by Apple in the UI It clarify how it does execute iPhone apps: they most probably implement the iPhone API as ... read more

Prime Numbers Generator

  • 675 words

I believe I don’t have to describe what primes are, what are their properties and what not. This post is more a tribute to geek-ness of 2 friends-and-colleagues (@lucabox) that have fun thinking of algorithms to solve stupid (or less stupid), and always useless problems ;-) . Optimus Prime :-P - yeah yeah, a stupid joke Briefing This code is ... read more

"Bidirectionally multiplied" array

  • 248 words

Another small problem before I go to sleep tonight: There is an array A[N] of N numbers. You have to compose an array Output[N] such that Output[i] will be equal to multiplication of all the elements of A[N] except A[i]. For example Output[0] will be multiplication of A[1] to A[N-1] and Output[1] will be multiplication of A[0] and from A[2] ... read more

Use Backtracking to print all Subsets

  • 743 words

I’m “studying” this algorithmic technique: Backtracking. This is an algorithmic approach to problem solution that I trust every good Computer Scientist already uses; but taking a good theo-practical look at it is something better. A Backtracking Tree I believe you can find enough informations about it online (the 2 links I provided are more than enough), so I’ll go straight ... read more

Money change problem: Greedy vs. Dyn.Pro.

  • 690 words

This is a classical problem of Computer Science: it’s used to study both Greedy and Dynamic Programming algorithmic techniques. I hate having my pocket full of copper!!! -_- Definition Given: A set of n Denominations D[0...n-1] in ascending order, representing a Monetary Coin System An money amount A, as input calculate a solution: S[0...n-1], with 0 <= S[i] <= (A/S[i]) ... read more

Calculate abs(int) without branching

  • 417 words

For this you need someone to teach it to you: if you made it yourself, then you are a very good Comp-Sci, and you should send your CV to Google ASAP. ;) Without branching O_o? Yes, without using any “if ( a < 0 )...”. To do that, you need to refresh how Two’s Complement works, then come back. What ... read more

Swap the value of two integers without temporary storage

  • 160 words

Someone says this is an old lame trick. I think it’s simple and clever use of XOR. How/Why does it work? It’s built around the properties of the XOR ^ operator, who has the following properties: A ^ B = B ^ A (commutative) A ^ 0 = A A ^ 1 = ~A A ^ A = 0 So, ... read more

Pascal's Triangle generator

  • 417 words

What’s Pascal’s Triangle? That’s what it is (Wikipedia has all the theory, if you need). Pascal's Triangle first 6 rows The thing I wrote here is a generator of the n-th row of the triangle, that doesn’t use more then the memory needed to store the solution. Instead of allocating a Triangular Matrix, and building every row based on the ... read more