# Game programmer Interview Questions

# 195

Game Programmer interview questions shared by candidates### How do you find the max depth of a binary tree?

5 Answers↳

breadth first search will be better than the recursion method for min-depth searching, but works same as recursive in the case of finding max depth problem Less

↳

public static int maxDepth(TreeNode root) { if (root == null) return 0; //base case return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1; } Less

↳

This entirely depends on the implementation. It can be calculated as the integer log base 2 of the highest index of the tree. This would prevent quite a few cache misses from traversing the tree each time, and would be a fairly quick calculation using bitwise operations. int val;// the value int result;// the result int tmp; result = (val > 0xFFFF ? 0 : 1) >= result; tmp= (val > 0xFF ? 0 : 1) >= tmp; result |= tmp; tmp= (val > 0xF ? 0 : 1) >= tmp; result |= tmp; tmp= (val > 0x3 ? 0 : 1) >= tmp; result |= tmp; result |= (val >> 1); While this may seem like a lot, assuming the tree is small, these calculations are actually quite fast, don't involve branching, and don't require arbitrary pointers to sub-tree members. This works best for trees that are either complete or nearly complete, however, since otherwise there will be a lot of wasted memory for indices that contain nothing. Less

### What is negative 2 in hex?

3 Answers↳

0xFE

↳

For a 32 bit, 0xFFFFFFFE (or 0xFE if sign extension is guaranteed)

↳

-0x2

### Given several cities and their mutual distance, find an algorithm to find the minimum time to spread a message throughout all cities.

3 Answers↳

Dijkstra's algorithm will make more sense

↳

Dijkstra's algorithm will make more sense

↳

use Prim's algorithm

### Told to code a small 2d game.

2 Answers↳

It is not bad.

↳

Hello - thanks for your feedback. Because of the many perks we offer to our team members (flexible working hours, ability to work from home, the opportunity to have a positive impact on the world with their work, etc.), we tend to get around 120 applications on average for every open position that we have in Learning Yogi. This means that our recruitment process necessarily needs to be extremely rigorous and selective, and only a handful of candidates are able to clear the initial technical tests that we ask all potential team members to do. We are sorry that we were unable to offer you the position because of this, and wish you all the best for your career in the future. You are of course welcome to apply again after a few years :-) Thank you. Less

### Very basic programming questions

2 Answers↳

Can you please elaborate on the questions asked in technical interview???

↳

Can u please tell the question that were asked

### Portfolio

2 Answers↳

By showing it

↳

In these sorts of interviews you really need to drill down and understand what the interviewer is looking for. A good way to simulate a real interview experience is to do a mock with one of the Ubisoft Game Programmer experts on Prepfully, rated super strongly on TrustPilot... prepfully.com/practice-interviews Less

### Given two rectangles on a plane, determine if they are overlapping.

1 Answers↳

// Check if the rects overlap. // Checks 4 conditions: // 1. Is the right side of one rect to the right of the other's left bound? (if not, this rect is completely left of the other) // 2. Is the left side of that same rect to the left of the other's right bound? (if not, this rect is completely right of the other) // 3. Is the top side of that same rect above the bottom side of the other's? (if not, this rect is completely below the other) // 4. Is the bottom side of that same rect below the top side of the other's? (if not, this rect is completely above the other) // // Note that this checks all cases: // Either rect will always be totally to the right, totally to the left, or horizontally overlapping with the other. // Either rect will always be totally above, totally below, or vertically overlapping with the other. // // By process of elimination, we simply need to check the failure cases // (completely left, completely right, completely above, and completely below). // If none of those are true when comparing either rect to the other, then the two rects overlap. // // rect0: the first rect to check for overlap // rect1: the second rect to check for overlap bool checkRectsOverlap(Rect rect0, Rect rect1) { return (rect0.xMax > rect1.xMin) && (rect0.xMin rect1.yMin) && (rect0.yMin < rect1.yMax); } Less

### What do you thing about overtime?

1 Answers↳

This is one of those questions that I hate because that assumes you are ok working unpaid hours. I said that I do it if we need to, because I undertand that a small company has a tight schedule and budget and every project can be the last. However I expected this overtime being moderate and not usual as it became in my previous job. Less