Doubt in N-Queen Problem


Please tell me what is the problem in my code for the N-Queen problem.

hello @sahilkhan2312000131
there are so many mistakes in ur canplace function

a) u are using || in place of &&
b) u are checking of arr[i][j]==2 but ur array will never have value 2
c) ur ar checking arr[t][i] in pace of arr[t][j]

Coding Blocks IDE
made those changes…now getting segmentation fault…please help

chekc now->

I think you have send some wrong link of code

@sahilkhan2312000131

I have one query: In the recursive case where we have used loop for j, is there any way in which we can do this question without using this loop??

yes, u can.
then u need to pass j as argument to ur recursive function

Coding Blocks IDE
I am doing the same, can you check what is the problem.

check now->

u havent added else section

code is not giving any output…please check

@sahilkhan2312000131

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.