[algogeeks] A bi-direction hashtable

2008-03-27 Thread Sticker
I was interviewed a question about implementing a bi-direction hashtable, i.e. a hashtable that stores key-value pairs such that you can find value based on key as well as find key based on value. In another word, there is no obvious difference between a key and a value, your hashtable should

[algogeeks] An interesting graph problem

2008-02-24 Thread Sticker
I have a graph problem, which is different from the standard salesman problem. I say it is more difficult. In a graph, I have many vertexes with different colors. It is more easier to think of each vertex as a shop selling only one goods and vertexes with the same color selling the same goods.

[algogeeks] Re: How to solve this problem efficiently?

2007-10-07 Thread Sticker
am agree with Sticker, I comes to write exactly what Sticker wrote. ;) It's O(N^2 / 2) that is 1+2+3+4+5+...+N. On 9/25/07, Sticker [EMAIL PROTECTED] wrote: I saw your ideas. Some of them are correct some are not. Here is what I am thinking. From the question we know that 1 ≤ M

[algogeeks] Re: Google Interview Question: find shortest summary containing all key words

2007-09-30 Thread Sticker
En, it is the idea. You assume each keyword is a single character and you use a map to hash key words and their counts. Each time you extend the range to right hand side, you may increase the counts of some found key words and each time you shrink the range from the left hand side, you decrease

[algogeeks] Re: using an array for BFS and DFS

2007-09-30 Thread Sticker
I have a rough idea about what you are concerning. Yes, DFS is usually implemented as recursion and there must be stack overflow problem for any algorithms using stacks to store search paths. But I never think about crawling the Web as an application of DFS. But it is, I have to say. To me, if

[algogeeks] Re: using an array for BFS and DFS

2007-09-30 Thread Sticker
to some Information Retrieval or Database or data structure textbooks to get the right one suits you. To me, it is never easy to build a spider that can crawl the (nontrivial) Web. On Oct 1, 12:44 pm, Sticker [EMAIL PROTECTED] wrote: I have a rough idea about what you are concerning. Yes, DFS

[algogeeks] Re: Google Interview Question: find shortest summary containing all key words

2007-09-25 Thread Sticker
, but it will be more complex and not as effecient as the above one in practise Sticker 写道: Declare: this question is originally from Google. The original form is: given a document, how to find a shortest summary containing all

[algogeeks] Google Interview Question: find shortest summary containing all key words

2007-09-24 Thread Sticker
Declare: this question is originally from Google. The original form is: given a document, how to find a shortest summary containing all the key words. After translated, it will be: given a sequence, how to find a shortest substring that contains all the items required. Example: a sequence

[algogeeks] Re: undo/redo algo

2007-09-24 Thread Sticker
Can them be implemented using stacks? Two stacks, one is called ls and the other is rs. I agree. Two things are needed, 1st, for each trackable action, a reverse action should be recorded in order to perform the undo action. The action itself must be recoreded as well for redo action. 2nd, two

[algogeeks] Re: An interesting numerical sequence problem

2007-09-05 Thread Sticker
to illustrate well by using word typer as only available here. I will put the link to a pdf file later, showing how I accomplish the whole problem. On Sep 5, 6:13 pm, adak [EMAIL PROTECTED] wrote: Darn it, I meant to post Sticker shock, but my typo left out the 't'. . Thanks for the clarification

[algogeeks] Re: An interesting numerical sequence problem

2007-09-04 Thread Sticker
the number next to min (which is 2). Scan through 6. New segment is {2,3,4,5,6}. Extend it to 7 but failed. 3. Scan from 3 to 7. New segment {3,4,5,6,7}. Stopped extending it at 8. 4. Scan through 4 to 8 and so on. I wonder whether there are any better solution to this? regards Sticker On Sep 5