MO.AT

What I've been up to

Ramblings and teachings on topics of interest to me.

Get Random Node from Binary Search Tree

Algorithms, Binary Search Tree

Problem Statement

The goal of this challenge is to build your own BinarySearchTree class which in addition to supporting insert, find and delete also supports a special operation getRandomNode() which returns a random node from the binary search tree with special consideration that each node in the binary search tree is equally likely to be selected.

Read More

Check if a Tree is a sub tree of another

Algorithms, Tree, Graph, DFS

Problem Statement

There exists two very large binary trees, with one tree, T1 relatively much bigger than the other T2. How can we efficiently determine if T2 is a sub tree of T1?

Read More

Weaving two arrays

Algorithms, Backtracking, Recursion

This is an interesting recursion problem where the aim is to find all the possible weaves of 2 arrays keeping the relative order of the elements the same.

Read More

Taming Open Source Swift (SR-7292)

Open Source, Swift

In December 2015, Apple made Swift an open source language and made it available on Github. This piqued my interest, I dug around the code base for a little, cloned it and felt like I had achieved something great. Fast forward to Spring 2017, I made my first contribution to the swift-corelibs-foundation, two contributions to be precise. The way I made these contributions was by digging around the code base for the NSString class and implementing methods marked as NSUnimplemented(). With two accepted PRs to swift-corelibs-foundation, the next thing I did was opened up my resume and under the Key Projects section, added a new bullet point right on top – Currently contribute to Apple’s open source Swift project on Github.

Read More

Leetcode - 270. Closest Binary Search Tree Value

Algorithms, Binary Search Tree, Leetcode

If the type of the target and the type of the value in the tree nodes were the same, and the problem was to find the node in the tree that is just smaller than the target, the problem becomes fairly simple. For example, given target = 17 and the graph:

Read More