Senior Software Engineer Interview Questions | Glassdoor.co.uk

Glassdoor uses cookies to improve your site experience. By continuing, you agree to our use of cookies. OK | Learn More

Senior Software Engineer Interview Questions

225

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.

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

2 Answers

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

Can a variable be both const and volatile ?

1 Answer

Can't quite remember. Everything was reasonable for the technical level they were hiring for.

1 Answer

about the cache and If I could write program in different ways with a CPU with cache systems

1 Answer

when an interrupt routine is enabled

1 Answer

It's one of those "where is the bug" questions. They show you a C++ program with some thread synchronisation code.

1 Answer

meaning of some C keyword (volatile, const, static)

1 Answer
110 of 225 Interview Questions