the challenge
Earlier last week, I was asked to implement an inmemory database similar to Redis (namevalue pairs). This post is about code style, algorithmic performance, and thought process. For simplicity's sake, my program to the challenge will receive commands via stdin, and should write appropriate responses to stdout.
6 Comments
Java Collection Framework (java.util.* package) is a unified architecture for representing and manipulating collections. This post is a quick note of my knowledge about Java Collection Framework that covers frequently used java data structure to store a group of elements and/or keyvalue pairs. In the java.util framework, there are two major camps  Collections & Map.
To illustrate, I will use solid lines to denote 'extends' in Java, and dash lines to denote 'implements' in Java. The way to use my note is to first go to the diagram for the specific class or interface, then read the brief blurb that'll remind you what the class or interface is about for you to choose the right data structure.
Queue and Stack are basic data structure. This post is about implementing Breadth First Search (BFS) & Depth First Search (DFS) using concept of Queue and Stack.
Assuming we have a set of values (see left). If you write these values down on a a piece of paper, from the top element you can branch downward into either left or right element each has its value. You can get a set of values with triangular look as shown. The question is, going from the value at the top to the bottom by choosing to go down the path of either left or right, what is the maximum sum among all possible paths? A clear thought process helps coders to get to the solutions. This post simply walks you through my thought process of how to implement some very basic data structure  a stack and a queue.
In this post, I note the approach and my thought process about determining whether a given smaller tree (t2) is a subtree of another larger tree (t1). First, the approach: Since I know t2 is smaller and it is to be matched/found in a larger tree t1, I'll take the approach of scanning through the larger tree t1, and t1's children, by trying to find a match of t2 in t1's left child tree and find a match of t2 in t1's right child tree, recursively. 
Categories
All
Archives
December 2017
