Amazon Interview Question for Developer Program Engineers


Country: India
Interview Type: In-Person




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

how the structure of Tree looks like?
struct node
{
  int data;
  node*link1;
  node*link2;
  node*link3;
};
one int and some links or something else data?

- Anonymous October 26, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I guess this is what he exepct ?

typedef struct node
{
int data;
struct node *child[N];
struct node *next
} *ptree;
ptree TraverNtree(ptree root)
{
	ptree q;
	for(int i=0;i<N;i++)
	{
		if(root->child[i]==NULL)
		{
		continue;
		}
		else
		{
		if (root->next==NULL) root->next=TraverNtree(root->child[i]));
		else
		{
			q=root->next;
            root->next=TraverNtree(root->child[i]));
			root->next->next=q;
		}
		}
	}
		return root;
}

- Charles December 29, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

void treeToDoublyList(treeNode *rootNode, treeNode *& prevNode, treeNode *& head)
{
if (!rootNode)
return;
treeToDoublyList(rootNode->pLeft, prevNode, head);
rootNode->pLeft = prevNode;
if (prevNode)
prevNode->pRight = rootNode;
else
head = rootNode;
treeNode *rNode = rootNode->pRight;
head->pLeft = rootNode;
rootNode->pRight = head;
prevNode = rootNode;
treeToDoublyList(rNode, prevNode, head);
}

treeNode* treeToDoublyList(treeNode *rootNode)
{
treeNode *prev = NULL;
treeNode *head = NULL;
treeToDoublyList(rootNode, prev, head);
return head;
}

- JobHunter October 27, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It is a Question of BFS / DFS . Write the 5 line DFS Code to do the JOB..

- hprem991 October 28, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

class node
{
int data;
node child[N];
}

Do BFS and form tree

- techcoder November 04, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

treeToLL(Node *root)
{
    if (root->prev == NULL)
    {
      root->prev = root->left;
      root->left = NULL;
    }
    else
    {
      root->left->prev = root->prev;
      root->prev = root->left;
    }

    if (root->next == NULL)
    {
      root->next = root->right;
      root->right = NULL;
    }
    else
    {
      root->right->next = root->next;
      root->next = root->right;
    }

    treeToLL(root->prev);
    treeToLL(root->next);
}

- Anonymous November 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

do a BFS or a DFS on the tree and instead of extracting and printing out from the stack move it in to the linked list...and display it...

- Anonymous October 26, 2011 | 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