Pages

Wednesday, May 21, 2008

interview questions coding design and analysis - part I

1. Write a function in C\C++ that converts a null terminated string of a binary number into a null terminated string of the equivalent decimal number. For example, given an input of “001100”, the input string should be converted to “12”.

void BinaryStringToDecimalString(char* s)
{}

2. Given a binary tree with nodes as defined below, write a function in C\C++ which creates an array of pointers to each of the leaf nodes of the tree in left-to-right order. Your function will need to allocate the array. Assume that the calling function will properly zero the array and arraysize parameters before calling your function. When your function has returned, arraysize should be set to the number of leaves in the tree, and array should be a properly allocated array where array[0] points to the left-most leaf of the tree, etc.

struct NODE
{
NODE* left;
NODE* right;
};

void BinaryTreeGetLeaves(NODE* tree, NODE**& array, int& arraysize)
{
3. Assume you have a web service (in the language of your choice) for an online game that displays statistics and other information for the players in this game. This information is stored in a database, and since the database is in production running the game, you must assume it is a bottleneck in the performance of your web-based player-info page. The player information is retrieved from the database and presented to you as an Object (one per player) called Player. Design a persistent in-memory cache of the player information which utilizes a LRU replacement policy. If a player is not in the cache, a database request should be made and the Player Object should then be added. Do not write the code for the database request. You may use pseudo code if needed.

This cache will include the following methods:

Player GetPlayer(String name)

StorePlayer(Player playerObject)

4. Using C#, write an object that when given a file path, will asynchronously convert that ASCII file to a Unicode file. You may use pseudo-code for any boiler plate functionality you deem appropriate, but should implement the main conversion method in code.

5. You are asked to test a simple server application that receives request messages from a client, and generates response messages. The set of requests and responses is known (at a given time; changes can occur during the development cycle as messages are added or removed). You are to test the system’s functionality and stability. What kind of tests would you have to ensure that quality requirements are met?

6. You have been given the opportunity to create a service responsible for searching and displaying information collected from both database archives and other live backend services. Briefly describe how you would decide on an approach and how you would design and implement the new service, including how users will connect and interact with the service.

No comments: