Epic Systems Interview Question for Software Engineer / Developers






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

Cmon...does epic ask these questions...u must be jokin..

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

Will this work?
Do a depth first search on the binary tree and every time a node is complete (all the children are traversed), detach that from the tree and start creating a binary search tree (insert function)

- Sudhakar September 14, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

you cannot do a pre order traversal because on detaching the node you will also have to make its left and right child as NULL. Instead do a post order traversal.

- chirag April 15, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

sudhakar, your approach looks vague to me. would you mind putting an example and then explain the logic you are thinking of inline with the example. thank you for your time.

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

For every node you found during the depth first search which has null, you can safely detach that from the current tree and use that object reference to add to a binary search tree... Every node you will be removing will always have nulls as their children because you have removed them already...

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

1)binary tree to doubly link list
2) sort the link list
3) again convert sorted doubly link list to bst

conmplexity: o(nlogn)

- idea September 18, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Since the question mentions it is to be done in place; we can't use another data structure.

My idea - Do a BFS using a queue. Whenever you visit a node; check left and right children. Put the middle value among them at the place of current node, smallest at the left and largest at right. (BST concept)

Do it n times so that every element would be at proper place.

Time complexity - O(n)
Space complexity - O(1)

- S3 October 10, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think we need to do a depth first search instead of breadth first search.

@S3 wouldn't using a queue be a additional space complexity.correct me if iam wrong..

- mouthit October 15, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

how about doing a post order traversal. when we are at a root node, we compare the root with left and right child, put the middle value in root lesser value in left child and greater value in right child?

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

can we use a modified version of quick sort? use the root as pivot, and make every note in the left sub-tree less than pivot, every note in the right sub-tree greater than pivot, and recursive ..

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

it seems like heap sort.

- Anonymous February 13, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Simply do a postorder traversal. While visiting each node, send its pointer to a func insert_into_bst(struct node * ptr); which takes a pointer to a node, inserts it into the bst and makes the left and right child of the node both NULL. Complexity O(nlogn)

- chirag April 15, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

geeksforgeeks.org/binary-tree-to-binary-search-tree-conversion/

- Taru May 10, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

search for binary-tree-to-binary-search-tree-conversion on google

- Taru May 10, 2015 | 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