Category Archives: programming

Puzzle – Roll a die for $

This is an interesting puzzle in that it shows a basic technique used in solving these kinds of probability puzzles, as well as in models for some derivatives pricing, without the need for conditional probability calculations. Hint: start with the … Continue reading

Posted in programming | Tagged , | Leave a comment

Binary Search Tree – Lowest Common Ancestor – Python

The last problem in the Trees chapter of Programming Interviews Exposed was about finding the lowest common ancestor between two nodes of a binary search tree. Starting from the head, if you find that the nodes that you’re looking for … Continue reading

Posted in programming | Tagged , , , | 2 Comments

Tree Traversal – Python

Another question posed in the Programming Interviews Exposed book. A pre-ordered traversal of a binary tree (counterclockwise starting at root, printing nodes as you encounter them) is pretty straight forward, and a very natural thing to implement with recursion: A … Continue reading

Posted in programming | Tagged , , , | 4 Comments

Linked List – Cyclic or Acyclic?

Another problem in the Programming Interviews Exposed book (see previous post) is to determine whether a Linked List is cyclic or not. The most obvious way to do this is to iterate over the list, checking whether the next element … Continue reading

Posted in programming | Tagged , , | 3 Comments

More on Linked Lists – flattening and unflattening

More from the Programming Interviews Exposed book (see last post). In this problem you take a double linked list (where each node knows its previous and next nodes) with child elements, and flatten it. Then unflatten it back to its … Continue reading

Posted in programming | Tagged , , , | Leave a comment

Linked List Interview questions

I hadn’t done much programming for a while and thought I’d best brush up on some basic data structures and algorithm. The following is from Programming Interviews Exposed. I implemented some of the Linked List stuff in the first section … Continue reading

Posted in programming | Tagged , , | 2 Comments