Profile cover photo
Profile photo
This Thread
54 followers -
Programming in C/C++, and some chatting about other languages like Java, Perl, SQL; design, testing and more.
Programming in C/C++, and some chatting about other languages like Java, Perl, SQL; design, testing and more.

54 followers
About
This Thread's posts

Post has attachment

Post has attachment
This problem is about implementing a data structure that allows the user to enter names and then get the numbers of them starting with a given prefix.
As a interview question, its point is to see if we know about tries.
Here I implemented the solution in python. The minimal implementation does not get fully accepted because, being written in python, it is not fast enough to pass one of the tests.
I had two chances. The easy one was porting my to C.
I decided instead to improve slightly the algorithm, to reduce the number of nodes created.

Post has attachment
The problem I bumped in asked for writing a piece of code implementing level-order traversal on a Binary Search Tree.
I thought to do a bit of practice more, so I have implemented also in-order, pre-order, post-order traversals, both in recursive and iterative way. All of them using Python as implementation language.

Post has attachment
If you are in a hurry, there is a quick and dirty solution that uses the insort() function from the python standard bisect library, that works not so fast, still is good enough to have the job done.
Having some time for hacking, two heaps, managed by functions from the heapq library give better performances.

Post has attachment
A Java Spring bean is by default a singleton. However we can say to the framework to create a new one each time it receives a request, marking it as a prototype.
Here I set a JUnit test to see how Spring behaves in both circumstances.

Post has attachment
Checking if a tree is a Binary Search Tree.
I show a python solution to this hackerrank problem, and I spend a few extra words on it.

Post has attachment
Given a hierarchy of classes rooted in an interface, writing an app with the Java Spring Framework, there could be a few problems if Spring can't understand which actual component we want to autowire.
Here I show a couple of exceptions that we could get, I explain what they mean and how to solve these problems.

Post has attachment
I have written a toy calculator using polish notation in python as solution to the codeeval problem #7.
Python lack of switch statement pushed me to be more creative and using a dictionary with lambda function to have to job done.
Another interesting feature is the use of zip to put together operators with the their associated right side operands.
Cute little problem.

Post has attachment
This problem is about implementing a queue using two stacks.
I have coded a Python solution and written a few extra words on the matter. 

Post has attachment
Functional interfaces have been introduced in Java 8 as a sort of clever hack so to let lambdas in.
Here I explore a few of them with examples.
Wait while more posts are being loaded