Oh sorry I didn't include this,
it is a software engineering role - a very general one. Especially the 1st few rounds will be very general (data structures and algorithms and such), so I was interested in a mock interview of that kind.

GrowFastDigital, thanks for the suggestion. But I'm going to be phone screened first, and I wanted to have some phone like mock interviews


I hope it is okay to post this here.

I'll be interviewed by a few companies in some time and I heard mock interviews are a great way to be prepare for it (the mental aspect :)).

So I was wondering if anyone else is the situation and would like to interview with me (mutually).

Hope I didn't violate any forum rules here

From my experience, it isn't really easy to contribute to a not-so active project. I don't know if you will easily get into the flow, by forking any github project. Perhaps, you want to try a slightly large organization? Linux, Ubuntu, Fedora, Mozilla... they have these "where do I start" pages which should pull you along.

Why not?

The amount of processing to be done is really large. All my implementaions ran far too long.

If you run it all the way through, yes. But you can also bail out as soon as you find a solution that is "good enough" in your judgment.

I don't have any heuristics that will tell me if a solution is "good enough". By good enough I meant one produced by an intuitively convincing greedy algorithm :)

Actually this sounds like a good way to limit your choices: Only consider actions that bring you closer (for some definition of "closer") to connecting the parts, ignoring moves that don't really help.

I've been finding it really hard to write what you say in code. A definition of "closer" is quite complex to me.

If I advance/find out anything more, I'll post here.


Nope I haven't been able to think of a particular strategy. The only thing I was able to do was separate it into components and join the components. This of course uses just turning a non-verex into a vertex (one of those 3 moves).

About the game tree approach, it is just brute force isn't it :)
I don't think it is feasible at all. It would produce the best solution though

Is there a greedy approach? One that would give a decent result?

If "one single connected component" means you're supposed to modify it to be a connected graph, then what does it actually mean to be adding, removing, and moving nodes? There will generally be multiple ways to connect disconnected subgraphs, so if the grid is meaningful, how do you decide which is the "right" connection to make?

Imagine there is a real grid of rooms in each of which may lie of computer. Each computer may communicate with a computer next to it(not diagonally though). In one arrangement it so happens that not all computers are able to communicate with eachother (for obvious reasons of lack of connectivity). Our task is to either:

  1. add new computers to empty rooms
  2. delete computers from some rooms
  3. move a computer from one room to another room next to it
    or any combination of the above 3.

Each of those 1,2 and 3 have costs.
We want the minimal cost or atleast a good cost. "The" right connection is the one with least cost.

However if that is hard we could settle with a "good" cost.

Are we missing any information?

Theguitarist, there needs to be some type of visual feedback for people to understand how the feature works. How would the system know when you're done selecting all your pieces of text?

I'm thinking the system finds out when the user hits the Quote button in the editor's menu.

It could be over the course of ten minutes with a five minute break between selections?

Yes, I'm not denying the usefulness of the pop-up. In the above case, it works alright. I'm just talking about the special case when you select some text even while the pop-up is being displayed. Perhaps you could cut short the pop-up there and forget about it? Just deal with the next pop-up like nothing happened before.
Am I missing something?

I don't get any popups.

I don't know, you should be getting them :)

Well it is important. Not just for display. On a normal graph you could connect 2 vertices with an edge no matter which the 2 vertices are. Here it is only vertices right next to each other can be connected. Each cell in the grid constrains the location of the vertex in it.

The problem wants a solution with the grid structure in mind.
Hope I didn't confuse you further :P

The pop-up appears once for each selected text.

Yeah, but is this okay? After you've finished selecting all your pieces of text shouldn't the pop-up get shown just once? What I see is: pop-op - blink - pop-up - blink - pop-up blink ...

Hummm -- where is there an "Insert with the Quote editor button"? I can't find it.

Just select some text from this post and wait for a pop-up to appear.


I had complained about this sometime ago and most of it got fixed and the site in general is a lot better.

But there is one thing annoying about that "Insert with the Quote editor button" popup :

  1. Select some text
  2. even while the popup is being shown select some other text
  3. Do 2 many times

When you're done with doing this, I'd expect the popup to be shown one last time for the last text I selected.
But what happens is that it gets shown a lot many times. The problem can be replicated even easily with double-clicking on text.

Though I'm not really knowledgeable here, I think this should be an easy fix.


I have a graph that is represented in the form of a grid. For example:


Each V is a node. If there is another V above/below/to the side of a V then there is an edge between them.

I'm to form one single connected component in this by doing either:

  1. adding a node where it doesn't exist
  2. Removing a node from where it exists
  3. Moving a node either above/below/to the side if no node exists there.

Each of the above have different costs.

I'm to find a decent way to this using some combination of 1, 2 and 3.

I don't know if the optimal solution is easy to find (complexity-wise). Perhaps there is a greedy approach to this that will do fairly well?

Thanks everyone.
I watched the 1st lecture in the design and analysis of algorithms course of MIT (Open CourseWare). He starts off from the very basics. He says the purpose of that course is to study efficiency of algorithms. Then he lists what is more important than the efficieny: all the stuff you mentioned (maintainability, readability, simplicity, user experience, etc.) Why study efficiency then? He says it is to buy those more important commodities :)

If one can write an algorithm that is significantly faster than a brute-force one, that is better.
Satisfying the customer is the goal, yes. But there are so many roles that would contribute to that. A UX designer would, a software tester would. But all my peers and companies that recruit interns look for people who can write algorithms that are fast.

I just fail to see the wonderful patterns that arise out of the better(faster) algorithms.
I wonder if solving tons of problems on topcoder, codeforces, etc. would actually help.


I select something on a post and this shows up:
Select additonal text or insert with the Quote editor toolbar button

I understand that it is trying to teach us something but what about people who have learnt that?

Also it has been very buggy in my experience: doesn't stop blinking, blinks thrice, blinks twice(normal?)...
Not to mention, it is opaque and covers such a large area.

I thought I'd give my feedback about this.

Look at this: http://www.codinghorror.com/blog/2007/01/how-to-become-a-better-programmer-by-not-programming.html

Did someone who simply couldn't write efficient code (complexity-wise) before, felt intimidated by people who did, decide to work really hard, try to solve an insane number of problems, actually get better?

I've been in touch with programming since some 4-5 years. Some of my friends who recently picked up C and speak total rubbish about it, solve those hard programming problems. I end up writing a long well polished program that employs brute force, while they get the best algorithm implemented with some really messy code.

I understand programming structures quite well, can read documentation, write understandable code.
Could reading a CLRS and working day and night at topcoder help me?


You're supposed to put some effort when you want help. People here are asked not to help when there is no effort shown in the question.
Read this also.

What are some common uses of HTML forms that contain just one text input and a submit button?

The only one use I find is to submit search queries.

Is there some other reason why this is commonly used?

Which brings me to my next point, how are you going to determine that someone is "searching" on a website? You search on anything, it is just a form that passes that user input.

True. It isn't possible to be sure if it is a search form or some other form.
That is one of the reasons why the staright forward algorithm would fail. So I was asking here for ideas that might meaningfully understand that it is a search. I really don't know the answer to this, and I thought I could find answers here. I asked for help in these issues.

The submission form u use the most is in fact a user name and a password, so - this is, what you thing it is - exactly!

Not sure what you're trying to say. If I wanted usernames and passwords I could have taken that information directly. It is not hard to identify login forms. Why find out if a form is a search form?
Besides why would anyone run such a script? If the script was pulled into the browser's source repo, it would get run, and why would developers pull malicious scripts into their code?

It sounds like spyware to me...

I'm sorry, it's not. May I ask why it sounds like that? Detecting any website as a search engine so the data can be kept inside the user's computer? Anyway it's not.

I is posible to directly read the historydatabase for firefox using php.

Since I am trying to extend a browser's functionality, I do have direct access to that data. My question was different.

I hope I asked the question clearly.
A user searches a lot in a website. That site could be detected as a search engine.
The straight forward way: check how many times he searched. If too many, maybe it is a search engine.
I just asked for ideas that could improve this, and perhaps where this would fail.


you tell me how do you observe form submitions and what website the user is submiting it on,
and I'll tell you absolutely everything else you need to know, I'll even write the original code you are asking for...

If I am working with a browser's source code, I can use their API to observe form submissions, know what website and even maintain a record of previous searches. I am not aware of how to do this from scratch, but I can use those APIs.

I didn't ask for any code. That was why I didn't mention any of this.
I'm asking for ideas. Please tell me.


I'm working on a project where I must observe form submissions in websites and detect a search engine if a form is used consistently.
I don't really want any help with coding this. I just want some ideas for an algorithm.

Like, for example if I were to come to Daniweb and search for something everyday, after sometime I must be suggested to use Daniweb as a search engine.

A typical algorithm would count the number of times I searched in Daniweb and if it exceeds a number, it should detect the Daniweb search form as a search engine. This seems too trivial.
I have not the experience to tell if this would practically work and produce neat results.

Assume I have the technical ability and resources (like form history, databases) to implement any algo.

Please suggest any ideas you have.
Thank you

Your code worked when compiled with g++ compiler.

Why is showAges() a member function? It doesn't really need a current instance (this) to work. It works on an array of objects passed as a arguments, like you said. You might as well make it a non-member function. (Oh, my bad, you were just trying it this way. Sorry)

You should write a constructor function.
You might want to make showAges take an extra parameter, the number of elements in the array being passed and iterate over all the elements of the array as opposed working on just the 1st 3.

The problem with the manager occurs in a public member function of class Client. Do I need to create an instance of the class Client inside the member function? I've never seen that.

No, no. You have IRManager* manager; in your Client class. It should be fine to invoke manager's member functions.
But, in general a static member function cannot directly call a non-static member function. Like here.

And when you say "main" function, you mean Client::_tWinMain. Right?

And the error message right at that line (manager->HangUp();) ?

That error is shown when you don't create an instance of a class and right away invoke a non-static member function of it.

Are you doing that somewhere?

Read here

So, you intialize 2-dimensional arrays (3 X 3), each representing a number on the dice.
'1' would be represented like I showed above. Right?

Your display function would need to iterate across each element of the array corresponding to the desired number and print an 'o' if it is 1, '-' otherwise.

That would be more systematic.

As for a better way of doing it, you could store how the numbers are represented in 2D arrays perhaps?
Like :

0 0 0
0 1 0
0 0 0 (for 1)

And you could use a single display function that prints a '-' if there is a 0 in the matrix and an 'o' if there is a 1.

Thanks everyone.
I was able to set it up.

I read on the web that using tables for layouts is not a good idea or a good convention. So I thought I'd avoid it.
I mean, what I'm creating isn't a data table after all. It is a small grid like you said.

Please see here.

The intention was to have 3 <div>'s in decreasing order of height(1,2,3) and to put those 2 buttons under the <div> marked 2.
Something like

1    2    3
-    -    -
-    -    
-   btn1
-   btn2

I floated 1 to the left because I wanted whatever that follows to wrap around it.
I combined both 2 and 3 into a single <div> because I wanted the 2 buttons to fall back down under 2.

So now that the single <div> that holds both 2 and 3, is NOT floated, whatever follows should simply appear in the next line, BUT still wrapping around 1.

The results aren't like that. Can you please tell me what is wrong?

And, do the index elements of a B+ tree necessarily have to be a subset of the values stored in the leaf pages?