Some interview questions I created for recent candidate interviews

Home Projects

Triangulations

Polygon Triangulation

A polygon is a plane (2D) shape formed by straight line segments connected end-to-end to form a closed figure. Each side meets exactly two other sides at its endpoints, and no two non-adjacent sides intersect. Examples include triangles, rectangles, and pentagons. A circle is not a polygon because its boundary is curved.

Prompts

  1. Can every polygon be divided into triangles using diagonals that lie entirely inside the polygon?
  2. If a polygon has n vertices, how many triangles will such a triangulation contain?
  3. How many diagonals are added in the triangulation?

Answers

  1. Every simple polygon can be triangulated. The smallest polygon possible is a triangle. If we add an additional vertex, there must still be a triangle in the result. Conversely, any polygon with more than three vertices can be reduced by one vertex while preserving simplicity by removing an ear.
  2. A triangle has 3 vertices and yields 1 triangle. In general, a polygon with N vertices admits N − 2 triangles.
  3. A triangulation of a polygon with N vertices adds N − 3 diagonals.

Raytracing

Point Inside or Outside a Polygon

I will provide pen and paper. This will only be asked if we move through other questions quickly.

  1. A polygon is a plane shape (2D) with straight lines connected by vertices. Examples include triangles, rectangles, and pentagons. A circle is not a polygon because it has a curved side.
  2. A point can either exist inside or outside a polygon. For this example, points cannot exist on line edges or vertices.
  3. Come up with a rule that determines whether a point is inside or outside a polygon. The only thing you are allowed to do is draw a line from anywhere that only stops when the point is hit. Consider what patterns, intersections, or counts might help determine whether the point is inside or outside.