Wednesday, May 28, 2008

windows 7

Would Windows 7 meet the needs ?

The way of handling senses (vision, touch, speech) would be the sales pitch!

Time for collaboration

The way we work is becoming more and more networked. Day by day different cloud based solutions are popping out as a platform for viable collaboration. Some are more granular and some are not. I incidentally came through some of the idea management/collobaration sites and seemed to be a very interesting area. WebStorm from BrightIdea caught my eye and I spent more time reading what they do.

Thursday, May 22, 2008

Hit century

A small accomplishment on my end, with my last blog the total number of blogs @ Global Handler blogspot touched 100.
Thank you all for your suggestions/critics/appreciations.

Hope I can further improve my writing, depth of the topic, and diversify topics.

Miles to go...

Wednesday, May 21, 2008

Interview questions coding design and analysis - part II (Web programming)

1. Jeff Bezos has decided that he doesn’t like his website anymore, and he has tasked you with identifying a suitable platform for his online bookstore application. He wants you to build the new website from scratch. Let’s assume that he wants you to design a system that keeps track of 100 million books, allows 10 million users to browse through the selection or quickly search for the book they want via the Internet, keep track of users’ preferences, and permit secure online purchases. What technology or set of technologies would you use to accomplish this task? Please defend your choice against other possible alternatives.

2. Considering the lifecycle of software development, and keeping in mind that Jeff doesn’t want to change the chosen web technology/technologies for at least 3 years, but that he does want to have the flexibility to make significant changes to the application if need be, are you still confident that your choice is the best? Why?

3. What are some of the things you would do to increase the availability of your database, as in “make it mission-critical”? Assume you have infinite resources.

4. Bob Millionaire just purchased some apartment buildings and would like you to design a database system that will enable him to properly oversee and manage his new investment. He will be hiring several building managers to help him handle the day-to-day problems and issues that will arise for his tenants. While some of these managers will be placed in charge of only one building, others could manage several. Bob would like to be able to use the system to see what buildings his managers are in charge of, and would also like to keep track of each manager’s name, phone number, address, and weekly wage.

Bob would also like to keep track of his tenants. He would like to be able to look up any given tenant’s name, phone number, apartment number, rent rate, and lease expiration date. It is also very important that Bob is able see in which building each tenant is currently residing.

From time to time, tenants will register complaints that Bob’s building managers will need to address. For each complaint, Bob would like to store the description of the complaint, the resolution of the complaint, the manager who resolved the issue, the date the complaint was registered, the date the complaint was resolved, and the tenant or tenants who registered the complaint. If two or more tenants register the same complaint, Bob would like the complaint to be entered into the system only once, but would still like to keep track of all of the tenants that registered the complaint.

a) Using the scenario above, describe how you would design the database. List all of the tables you would create along with the fields you would create in each table. Clearly mark your primary and foreign keys. If you make any assumptions, please state them.

b) Using the database you have just designed, write a SQL query that lists the name of each tenant and the total number of complaints they have ever registered.

5. Use the rules below to construct a class diagram. You may use UML or some other technique capable of communicating what classes would be created, what attributes would be created in each class, and the relationships that would exist between the classes. For each class, do not worry about methods, just the attributes and relationships that might exist. Indicate attributes only when necessary (you will not need to fill in attributes for all of the classes). If you make any assumptions, please state them.

a) There exists a company in which there are several software development teams.
b) Each software development team has a number of developers.
c) Within each team there are two types of developers--Senior Developers and Junior Developers.
d) All developers have names, phone numbers, and addresses, but only Senior Developers are issued a company car and only Junior Developers are issued a laptop computer.
e) Company cars have a make, model, year, and color.
f) Laptop computers have a make and model.
g) All developers are involved in one or more projects.
h) Projects have a name and an estimated date of completion.

6. Many banks have a telephony service that allows their customers to call in and verify their personal account balance via the telephone. Most of the banks are happy with the default number utterance; however, Bank One believes that it could gain an edge over the competition by personalizing the number utterance. They hired a speech professional to record the following utterances:

Number Spoken Output File Name
0 Zero 0.wav
1 One 1.wav
2 Two 2.wav
3 Three 3.wav
4 Four 4.wav
5 Five 5.wav
6 Six 6.wav
7 Seven 7.wav
8 Eight 8.wav
9 Nine 9.wav
10 Ten 10.wav
11 Eleven 11.wav
12 Twelve 12.wav
13 Thirteen 13.wav
14 Fourteen 14.wav
15 Fifteen 15.wav
16 Sixteen 16.wav
17 Seventeen 17.wav
18 Eighteen 18.wav
19 Nineteen 19.wav
20 Twenty 20.wav
30 Thirty 30.wav
40 Forty 40.wav
50 Fifty 50.wav
60 Sixty 60.wav
70 Seventy 70.wav
80 Eighty 80.wav
90 Ninety 90.wav
- Hundred Hundered.wav
- Thousand Thousand.wav
.01 Cent Cent.wav
- And And.wav
- Cents Cents.wav
- Dollars Dollars.wav

Using C#, please create the algorithm that will output to the screen the names of the .wav files in the proper sequence for any number between 0.00 and 999,999.99. Assume and.wav will be used to join only dollars and cents. For example:
1,234.59 = 1.wav + Thousand.wav + 2.wav + Hundred.wav + 30.wav + 4.wav + Dollars.wav + And.wav + 50.wav + 9.wav + Cents.wav
103.01 = 1.wav + Hundred.wav + 3.wav + Dollars.wav + And.wav + 1.wav + Cent.wav

7. What is one application you created (either individually or as part of a team) that you are proud of? Please describe it in broad terms, focusing especially on your choice of technology, and any algorithms you might have used. How long did it take you to develop it?

8. Is there any database-driven website on the Internet that you created, either individually, or as part of a team?

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.

Thursday, May 15, 2008

13 problems to crack interviews

These 13 problems would suffice as a good preparation material to crack the interviews of Microsoft, Amazon and Myspace.

All the below questions requires you to give the most efficient algorithm interms of time and space complexity.

1. Given a circular linked list remove all the duplicate nodes.
2. Given a linked list sort them and explain what is the best sorting method, pros and cons. Remember this is not array sorting this is a linked list sorting.
3. Given a string find the first unique character in the most efficient way.
4. Given a array say for example 20 numbers, you need to generate an output array that will have the product of all the numbers for every index, except the value in the index. for ex: 2, 3, 5 output would be 15, 10, 6 -
Write the test cases to test your app.
5. Find the permutation and combination of a given string.
6. You are given a method void fun(int num) => the output will be a string for example: abc for 1, def for 2.
Now you need to find all the combinations for the given set. say I give you 1, 2, 3. you will get output from the fun() as abc, def, ghijk
final output should be along these lines: 1. adg 2. aeg 3. afg
At any time only one character from a set should appear, which means a and b are mutually exclusive as they are both part of set 1.
7. Given an array and a value called sum, find the minimum set of numbers that could result in the sum value. Find the first any set you obtain. example: sum is 10 and array is 1, 0, 3, 15, 6, 47, 3, 4, 23, 7, 5
the answer should be 3, 7 and not 1, 3, 3, 4
8. Write the same prog. in which the largest set of numbers will be taken in to account for finding such a sum. This is just the opposite of the required in question 7.
9. Given a BTree each node has an extra data information like sibling. The class for node is like class node{int data; node left, node right, node sibling). You are given a tree that is populated with data, left & right. Now you have to obtain the sibling and add it to each node.
If the tree contains ex: three nodes,. root->left and root->right. for the left node you should add it's sibling as right. ie. left->sibling = right. and right->sibling will be null.
10. Implement a queue using stacks. I give you stack with pop, push and isempty methods, using this you should implement the enquee() and dequee().
11. Implement a queue using an array, tell me when is the queue empty and when is the queue full.
12. Explain the efficient way to store a hash table in memory, if the hash table is so huge that it cannot be fit in to memory what are the possible solutions you would come up with?
13. Remove duplicates from an array in O(n) time.

some more questions:
1. Find the value in the deepest node of an un-sorted BTree.
2. Given two string, with millions of digits, you need to multiply them. (Half adder/full adder)
3. Count the number of bits set in a dword (See programming pearls book)
4. Print all the nodes in the tree by level (Breadth first traversal)
5. Given N number of people sitting in a round table, each one will start counting the number until M, when M is counted the person who said ‘M’, should quit and the same follows until the end. What data structure will you use to implement this game?
6. You have a set of points which will have a 1:1 connection. Say from a to z are the names of node. What data structure will you choose to implement this? (Obviously vector, but the time to access is more, since it is like a->b-c>….->z so better implement in an array, so that to go from one node to other it is just o(1). Worst case is a->z which will be o(n).
7. How will you calculate the distance for say m->…->U in the above? (the distance to be stored as a cumulative distance, so that we avoid more calc. So while adding ‘o’ to the link n, it will have the cumulative distance from m, this will make the operation faster.

STAY TUNED will post the answers

If you are done with the above, this tip might help.
Donot forget to ask the interviewer what they are looking for and make sure you understand the problems stated.

In some cases it is as simple that the given array is sorted and the solution we are looking for is o(n), but the interviewer never explicitly tells you that the array is sorted. You as the interviewee should ask the interviewer whether the array is sorted etc etc.
Coding is not all the interviewer wants to see in you, the way you think and analyze the problem is all the more important.

Wednesday, May 14, 2008

Microsoft Live reviving the search with options

Then there is the image search with handy options like size, color, style, face to name a few.

And the product search with categorized options and easy look ups.

Live search is introducing cool features, most of the times they do not get noticed due to Google effect.

Anyways I liked this one, see the snapshot and try it for yourself. Enjoy life and enjoy 'live'.

Worst case analysis - finding the second largest #

Describe an optimal algorithm to find the second minimum number in an array of numbers. What is the exact number of comparisons required in the worst case?
Note that Big-Oh notation is not what is being asked. Exact number of comparisons is what is required.

Example array (here after called as arr) for the worst case:
20 | 15 | 16| 18| 19| 20

Say there are 6 #'s in an array.
for the array that has min of two #'s only you can start, unless they are equal #
so always for 2 #'s there will be minimum and a max of '1' comparison.
After comparing arr[0] and arr[1] you will assign a temp variable first = arr[0] and second = arr[2], you have to iterate the array forward and make comparison to the second and first.

Say you have an "if condition" for the new # like this.
if( new < second || new == second || new == first)
//case ignore
if( new > first) { second = first; first = new;}
if(new > second)
second = new;

or you can write the above as

if( new < second)
//case ignore
if( new > first) { second = first; first = new;}
if(new > second && new < first) -> to make sure new is not first, if not we will have first & second the same values...
second = new;

so second one was better comparison as it ignores one case, if you compare both the methods.

any given new # will be equal to first or second in which case we do not care
or will be > first
or will be < second
or in between. -> worst case or new == first is the worst case.

so given 3 #'s worst case in a best algorithm will be:
5 comparisons.(for every new # 4 comparison + 1 comparison for the first two #'s)

2 # -> 1
3 # -> 5
4 # -> 9
5 # -> 13

This above is a series, where n+1 is greater than n by 4.
The above is a classic question and you have the answer. If the series is in the pattern above find the nth #. That would be the answer for the exact number of comparisons that needs to be made for the WORST case.

Ok it is (n-1) * 4 + 1

Friday, May 09, 2008

Bliss to be a hacker

Hacking heals your zeal for quest!

In the world of everything being digital you try to monetize as much as possible, if not otherwise you spoil others from doing it. If you think hacking is evil yes it is, but what it takes to be a hacker? Being smart, not just tech savvy but technically sound, hard worker... Oooo a lot of good qualities you often need to do something great.

It is a tit for tat game, the security experts who often mostly are hackers try and close the walls but the hackers breach them, and this after all continues for ever and ever. isn't that fun, hmmm yup it is too much of fun.
The current common attacks pose mobile virus, malware, spying software, sql injections.

There are classification of hackers the main one being the one who do hacking ethically called as ethical hackers and the rest of them. Ethical hacker makes money legally and the others do it the opposite or just for fun.

OK let me stop here before you conclude that I am hacker too.