Design an algorithm to assemble a jigsaw puzzle. Assume that each piece has four sides, and that

Question:

Design an algorithm to assemble a jigsaw puzzle. Assume that each piece has four sides, and that each piece’s final orientation is known (top, bottom, etc.). Assume that you have available a function

bool compare(Piece a, Piece b, Side ad)

that can tell, in constant time, whether piece a connects to piece b on a’s side ad and b’s opposite side bd. The input to your algorithm should consist of an n x m array of random pieces, along with dimensions n and m. The algorithm should put the pieces in their correct positions in the array. Your algorithm should be as efficient as possible in the asymptotic sense. Write a summation for the running time of your algorithm on n pieces, and then derive a closed-form solution for the summation.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: