Senior Software Engineer Interview Questions |

Senior Software Engineer Interview Questions


Senior software engineer interview questions shared by candidates

Top Interview Questions

Sort: RelevancePopular Date

Write an algorithm to rotate a node of a binary tree.

2 Answers

void rotateLeft( Node p) { Node r = p.right; p.right = r.left; if (r.left != null) r.left.parent = p; r.parent = p.parent; if (p.parent == null) root = r; else if (p.parent.left == p) p.parent.left = r; else p.parent.right = r; r.left = p; p.parent = r; } void rotateRight(Node p) { Node l = p.left; p.left = l.right; if (l.right != null) l.right.parent = p; l.parent = p.parent; if (p.parent == null) root = l; else if (p.parent.right == p) p.parent.right = l; else p.parent.left = l; l.right = p; p.parent = l; }

To help visualise, right rotation is shown below. Consider a given tree: R /\ / \ P C /\ / \ A B Imagine nodes as metal coins suspended by strings (branches). For right rotation: 1. Pick up node P and pull it up so that node R falls down to the right of P. 2. Take B (right child of P) and make it left child of node R. The tree has been right rotated now and looks like this: P /\ / \ A R /\ / \ B C Similar process can be applied to this tree to rotate it left. This time start by pulling up R above P. Hope it helps.

I completely froze on following question which could be useful in a function that reverses order of words. How would you move a chunk of memory in C++/C?

2 Answers

How will you prevent the code in finally block from executing? The question isn't a very fair one as a good programmer would not write the code in finally block that he/she doesn't want to execute

3 Answers

Architecture design exercise: online ticket sales system

1 Answer

All questions around multithreading.

1 Answer

The most difficult part was the accent. I had some problems with understanding the basic words like "synchronised".

1 Answer

Can a variable be both const and volatile ?

1 Answer

Could you please sign this NDA and not post the questions in Glassdoor?

1 Answer

What are signals in Unix and how are they used..?

1 Answer
110 of 431 Interview Questions