Question: Design an algorithm to assemble a jigsaw puzzle. Assume that each piece has four sides, and that each pieces final orientation is known (top, bottom,
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.
Step by Step Solution
3.43 Rating (153 Votes )
There are 3 Steps involved in it
To design an algorithm to assemble a jigsaw puzzle efficiently we can use a technique similar to dep... View full answer
Get step-by-step solutions from verified subject matter experts
