+ 2

Which data structure is more efficient for backbite algorithm?

Which data structure is more efficient for implementing backbite algorithm for making a hamiltonian path on a 2d lattice? Simle arrays or linked list or others...?

14th Jun 2021, 9:40 AM
ACADEMIC
ACADEMIC - avatar
2 Answers
+ 5
I'd use an N*M sized array where each entry stores the coordinates for the next and previous vertex in the path. Linked lists are probably not the best tool for the job since you are choosing vertices at random, and looking up a random vertex is O(n) in a linked list. With arrays it's O(1).
14th Jun 2021, 9:53 AM
Schindlabua
Schindlabua - avatar
+ 1
Schindlabua thanks for your answer, I gotta go implement it...
14th Jun 2021, 10:43 AM
ACADEMIC
ACADEMIC - avatar