-
Essay / Recursive N-Queens Algorithm with Multi-Threading
Now we place the 3rd queen in the available column. Again, we don't have room to put the fourth queen. So we return to the first queen and change its position to the second column as shown in Figure 7 below. 7 Placement of three queensAs shown in Fig. 8 below, for the 2nd queen, we only have one location to place it on the board.Fig. 8 Placement of the first queen with the next column after backtracking After placing the 2nd queen, the options available for the next queen are shown below.Fig. 9 Placement of two queens with different positions Again, after placing the third queen, the available option is the one shown in Fig. 10 below.Fig. 10 Placement of three queens with varying positions After placing all the queens, one of the possible solutions will look like the diagram below.Fig. 11 One solution for all placed queens We will repeat all the steps above to find another solution to the 4 queens problem. This entire process is illustrated in the diagram below.Fig. 12 Complete Process Tree for Placing 4 Queens The data I collected is in the form of the execution time required to find all possible unique solutions for a given number of queens. I used two timestamps to find the actual execution time required for this serial algorithm. I placed a timestamp named "start" at the start of the function and a timestamp named "end" after that function completed. Then I calculated the total execution time to find all the solutions by simply taking the difference between these two values. I used 'Netbeans IDE' profiler to run the program and collect the data. After collecting this data, I redirected these results to the respective log files. I...... middle of article......IEEE IBM Journal of Research and Development Volume 31, July 1987, Issue 4, p. 464-474[7] Collins, RL, Vellore, B. and Carloni, LP (March 2010). Recursion-based parallel code generation for multi-core platforms. In Proceedings of the Conference on Design, Automation and Test in Europe (pp. 190-195). European Association for Design and Automation.[8] Rolfe, T. J. (2008). “A Specimen of MPI Application: N-Queens in Parallel” ACM SIGCSE Bulletin, 40(4), 42-45.[9] Acar, UA, Charguéraud, A. and Rainey, M. (February 2013). “Work-stealing parallel program scheduling with private deques” In Proceedings of the 18th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (pp. 219–228). ACM.[10]http://scalibq.wordpress.com/2012/06/01/multi-core-and-multi-hreading/#comment-4565[11]http://theory.cs.uvic.ca/ amof/e_queeI.htm#application