IBM Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

This is a minimum spanning tree starting at each node.

- fayezelfar January 19, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

That's correct.

- william.brandon.lee83 January 19, 2016 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

DFS of all the nodes from all the nodes

- OneCode January 18, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Also correct, but the interviewer was looking for a specific answer (which is stupid...)

- william.brandon.lee83 January 19, 2016 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>

void swap(char *s, int i, int j)
{
	char temp = s[i];
	s[i] = s[j];
	s[j] = temp;
}

void foo(char *s, int j, int len)
{
	int i;
	if (j == len-1) {
		printf("%s\n", s);
		return;
	}
	for (i=j;i<len;i++) {
		swap(s, i, j);
		foo(s, j+1, len);
		swap(s, i, j);
	}
}

int main()
{
	char s[] = "abc";
	foo(s, 0, strlen(s));
}

- aka January 19, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think that interviewer wants to generate all hamilton paths, starting from each character ( each Node). Actually this is DFS form each Node as it was suggested above
P.P william do you have already feedback from so many interviews or still wainting?

- EPavlova January 19, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Hi, sorry for the late reply. Yes the feedback was given during the interview (meaning, she mentioned that she was looking for the minimum spanning tree solution).
As for the on-site interview (this was a phone interview) I am expecting an invitation soon (I hope). The recruiter said I did well.

- william.brandon.lee83 January 24, 2016 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

by dfs or bfs we can trace out all the elements in the string
then write all the permutations of the string

s="abc"
n=len(s)
k=n
def permutation(s,n,res,count,k):
if count==k:
print res
else:
for i in range(n):
permutations(s[:i]+s[i+1:],n-1,res+[s[i]],count+1,k)
permutations(s,n,[],0,k)

- yashodhar January 27, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

isn't this the anagram problem ?

- nakeer February 23, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

from itertools import permutations

print( [''.join(p) for p in permutations("ABC")])

- Manav Mehra December 31, 2018 | Flag Reply


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