March 2015 Entries
This is the way I would go about the “Is tree a Binary Search Tree” problem if I were asked to perform it at an evaluation. However, keep in mind there are multiple ways to solve this, so don't worry if your solution has variations. The Wrong Path The temptation here is to naively think of a BST as simply having the restriction that the left child of x must be < x and the right child of x must be > x. The problem is that this is not the accurate definition. The definition of a BST is that the ......
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. Visual Studio 2015 is on the horizon! In fact, some of you may already have played with the preview and seen some of the many neat new things to come – both in the IDE and in the C# language. For those who haven’t been keeping up with the announcements, allow me ......
I like to keep my brain sharp by working on programming puzzlers. On off weeks I'm going to start posting programming puzzlers I've collected over the years. Hopefully you'll find them as entertaining as I do. The Problem: Given a standard definition of a binary tree node, i.e.: 1: public class Node<T> 2: { 3: T Data { get; set; } 4: Node<T> Left { get; set; } 5: Node<T> Right { get; set; } 6: } And a reference to the root of the tree: 1: Node<T> root = ....; Write a method ......
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. Visual Studio 2015 is on the horizon! In fact, some of you may already have played with the preview and seen some of the many neat new things to come – both in the IDE and in the C# language. For those who haven’t been keeping up with the announcements, allow me ......
This is the way I would go about this problem if I were asked to perform it at an evaluation. However, keep in mind there are multiple ways to solve this, so don't worry if your solution has variations. When solving these sorts of problems, the first thing you should do before writing any code is test your assumptions and clarify requirements. Often times tech companies use these sort of questions to see if you just dive into coding with no set design, or if you really think out the edge cases. First ......
I like to keep my brain sharp by working on programming puzzlers. On off weeks I'm going to start posting programming puzzlers I've collected over the years. Hopefully you'll find them as entertaining as I do. The Problem Given an unbounded sequence of characters, find the value and position of the first non-repeated character. e.g., in the stream: A,B,C,D,C,B,A,F,A,F the first non-repeated character is D. For the purposes of this exercise, consider the following interface as the source of the stream: ......