F#

Advent of Code F# — Day 15

ps. look out for all my oth­er solu­tions for Advent of Code chal­lenges here.   Day 15 See details of the chal­lenge here. Today’s chal­lenge is pret­ty straight for­ward, and a brute force approach would have suf­fice — try every t from 0 to inifin­i­ty and return the first t that sat­is­fies this equa­tion for all …

Advent of Code F# — Day 15Read More »

Advent of Code F# — Day 14

ps. look out for all my oth­er solu­tions for Advent of Code chal­lenges here.   Day 14 See details of the chal­lenge here. Today’s chal­lenge is very sim­i­lar to that of Day 5, but the require­ments for a valid hash val­ue is dif­fer­ent this time. As before, we’ll start by defin­ing a hash func­tion that will accept a string and return …

Advent of Code F# — Day 14Read More »

Advent of Code F# — Day 13

ps. look out for all my oth­er solu­tions for Advent of Code chal­lenges here.   Day 13 See details of the chal­lenge here. Today’s chal­lenge involves solv­ing two sep­a­rate prob­lems: count­ing set bits in an inte­ger lev­el order tree tra­ver­sal For the first prob­lem, I rec­om­mend read­ing through this blog post which cov­ers sev­er­al approach­es and opti­miza­tions for this …

Advent of Code F# — Day 13Read More »

Implementing a BST in F#

Bina­ry Search Trees (BST) seem to be a hot top­ic in tech­ni­cal inter­views. So, in order to help me pre­pare for all these grilling tech­ni­cal tests, I thought I’d give it a crack at imple­ment­ing inser­tion, dele­tion and ver­i­fi­ca­tion log­ic since I’ve already done both breath-first and depth-first tra­ver­sals.   Ver­i­fi­ca­tion Start­ing with some­thing nice and …

Imple­ment­ing a BST in F#Read More »

Depth-First Tree Traversal in F#

We looked at breath-first tree tra­ver­sal ear­li­er today, now let’s take a look at depth-first tree tra­ver­sal as well. Here, we loop through the tree start­ing with the root, yield the val­ue for each of the nodes before recur­sive­ly tra­vers­ing down all the left branch first and then the right branch.   Try it Your­self   Links Breath-First …

Depth-First Tree Tra­ver­sal in F#Read More »

Level Order Tree Traversal in F#

Anoth­er com­mon prob­lem I see dur­ing my prepa­ra­tion for tech­ni­cal inter­views is the Lev­el Order Tree Tra­ver­sal (or Breadth-First) prob­lem. I always like to think with my F# hat on when I solve algo­rithm prob­lem, so here’s an imple­men­ta­tion in F# . Here we have a nest­ed recur­sive loop func­tion that: yields the val­ue from the nodes …

Lev­el Order Tree Tra­ver­sal in F#Read More »

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close