Adobe Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
3
of 3 vote

It is a graph and do a BFS on the graph starting from any node and see if the count of nodes is N or not ... If the count is N, then it means that all the computers are interconnected ...

- Rushabh March 17, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Helloo .. .
There is no graph given. To form a graph from [Ca, Cb] API, every node has to be checked for every other node. The complexity to form graph is O(N^2).

This is obvious soln. Can someone suggest a better soln?

- xyz April 14, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Helloo .. .
There is no graph given. To form a graph from [Ca, Cb] API, every node has to be checked for every other node. The complexity to form graph is O(N^2).

This is obvious soln. Can someone suggest a better soln?

- xyz April 14, 2010 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 vote

:D its a high time for Ms Gayle to add 'like' button for people comments :D

- Anubhav February 09, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The question is unclear. What does "all computers are interconnected" mean? Each computer has a direct connection to every other computer? OR, there is a path of communication (possibly involving intermediate computers) between any two?

Comment by Rushabh addresses the second interpretation.

- T March 19, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think Warshall's algorithm for transitive closure would be a good solution...

- J March 29, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think Warshall's algorithm for transitive closure would be a good solution...

- J March 29, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Rushabh is right. Its a graph, just do a bfs or dfs to see if you can visit all the N nodes. This takes O(N+E) (where N is the number of vertices and E is the number of edges)
Warshall's algo would work. But it takes more time. Warshall's takes O(N^3).

- csl March 29, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The key idea here is to exploit the symmetricity and transitivity of connectivity between two computers.

So c(a,b) => c(b,a) (symmetric)
Also , c(x,y) and c(y,z) => c(x,z)

Now let's say we have n computers. Check if c(i,n) is true for all i = n-1,n-2,......1. If there's at least one i for which c(i,n) is false, the computers are not interconnected. Otherwise they are.

Pseudocode

isConnected(){
for( i= n-1 ... 1){
if(c(i,n)==TRUE){
continue;
}else
return FALSE
}
return TRUE;
}
Time complexity -> O(n)

Correctness of the algorithm:

The algo starts with checking c(n-1,n). If this is true,we go to the next step in which we check if c(n-2,n). If that is also true,we CLAIM that c(n-2,n-1) is also true.(Why?) Because c(n-1,n) = T

=> c(n,n-1) =T (symmetric property).
Also c(n-2,n)= T.

So by the transitivity property,c(n-2,n-1)=T

Let's now evaluate c(n-3,n). If that's also true,again we can claim that c(n-3,n-2) and c(n-3,n-1) are also true. How? Well,using the same logic,we have the following

if c(n-3,n) = T we already know that c(n-1,n),c(n-2,n-1),c(n-2,n) are all true,otherwise the algo would have exited by now)

We claim that c(n-3,n-2),c(n-3,n-1) are also true.Reason out why.

Similarly we can establish the connectivity of any two computers in the given set.

- S April 08, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The above pseudocode is wrong . Consider this case : n is connected to n-2 , n-1 is connected to n-2. By transitivity , n is connected to n-1.
But, acc to the pseudocode, n is not connected directly to n-1 so the program will exit and false will be returned - Which is wrong

- Manish April 13, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think this is write as relation is transitive if n is connected to n-2 and n-2 is connected to n-1 then n is for sure connected to n-1.

- n February 03, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think this is correct as relation is transitive if n is connected to n-2 and n-2 is connected to n-1 then n is for sure connected to n-1.

- n February 03, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

The above pseudocode is wrong . Consider this case : n is connected to n-2 , n-1 is connected to n-2. By transitivity , n is connected to n-1.
But, acc to the pseudocode, n is not connected directly to n-1 so the program will exit and false will be returned - Which is wrong

- Manish April 13, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Oh yeah..Thanks for pointing that out. I was just trying to avoid the formal graph based approach.

So,then the given information of direct connectivity between two computers could be translated into an undirected graph using the adjacency list/matrix representation.

The problem then reduces to finding whether the graph so formed is connected. A standard DFS could be used to do that.I don't think a complete transitive closure determination using warshall's algo is required here.

- S April 15, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

And yes, Rushabh's solution is similar,except that he uses BFS instead of DFS.

- S April 15, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

And yes, Rushabh's solution is similar,except that he uses BFS instead of DFS.

- S April 15, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

This can be easily checked for N computers whether they are connected by above rules,they must have N*(N-1)/2 distinct connection pairs(i.e. C[i,j] & C[j,i] are counted one time only)Now simply check whether given connection pair count is equal to N*(N-1)/2. if it is less than than certainly some disconnected computers are there. complexity: O(1)

- Shailu March 31, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

what about multiple links between two nodes ?

- Anonymous November 24, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Take a node_counter to count the node's, and initially mark its value 0;

void checkConnectivity(node * current_node)
{
   if(ptr == 0)
      return;
   
   loop for each conneced children_node from the current_node.
   {
      if(the children_node is not visited yet)
      {
         1. mark the node as visited.
         2. increment the node_counter by one.
         3. recursive call the checkConnectivity(children_node) 
      }
   }
}

If the node_counter == num of nodes in graph
  then nodes are interconnected
else
  nodes are not interconnected

- Ashutosh May 15, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Take a node_counter to count the node's, and initially mark its value 0;

void checkConnectivity(node * current_node)
{
   if(ptr == 0)
      return;
   
   loop for each conneced children_node from the current_node.
   {
      if(the children_node is not visited yet)
      {
         1. mark the node as visited.
         2. increment the node_counter by one.
         3. recursive call the checkConnectivity(children_node) 
      }
   }
}

If the node_counter == num of nodes in graph
  then nodes are interconnected
else
  nodes are not interconnected

- Ashutosh May 15, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Minimum Spanning Tree.

- Anonymous June 04, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

LOL.

- LOLer August 11, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

All you need to check if the graph is connected OR not,

- Lord Darth Plagueis June 20, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

WTF, you people are wasting time ...its pretty simple... just check for graph connectivity using DFS/BFS and you're done!
first solution by Rusabh is OK, rest people are just repeating the same things...sux man...

- Lord Wrath August 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

isn't a disjointed set enough?

- me October 31, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This can be easily checked for N computers whether they are connected by above rules,they must have N*(N-1)/2 distinct connection pairs(i.e. C[i,j] & C[j,i] are counted one time only)Now simply check whether given connection pair count is equal to N*(N-1)/2. if it is less than than certainly some disconnected computers are there. complexity: O(1)

- Shailu March 31, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

what about multiple links between two nodes ?

- Anonymous November 24, 2010 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More