Microsoft Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

class Node {
int data;
Node nextNode;

public node(int data){
this.data= data;

}
public void setNode(Node next){
this.nextNode = next;
}
}
public static void main(String[] args){
int k= 10;
Node head = new Node(k); //first node
Node node = head;
for(i=0;i<6;i++){
Node next = new Node(i+k);//any value
node.setNode(next);
node=next;
}
}

- hotcoder October 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

If I am not wrong linked list should have nextNode and prevNode, in-order to achieve insertion and deletion of an element at the beginning and end of the list.

- Ganga October 16, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

ya in case of double linked list, couple of lines to above code should do it

- hotcoder October 16, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

So you leave the insertion/deletion/lookup code to the user of your class?

It is not as easy as you think.

- Anonymous October 16, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

//inside Node
public Node getNode(){
return this.nextNode ;
}

when deleting or adding use 'temp' in between to change the connections,
its just that they asked basic overview so have kept it as simple as possible

- hotcoder October 17, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Step1:
define interface List<T> which includes necessary method declaration.

Step2:
define class LinkedList<T> which implements List<T>, Serialiazable

- Kevin March 04, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.


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