Home / Expert Answers / Computer Science / j-implement-the-pseudocode-for-n-queen-problem-slide-6-in-c-with-the-following-modifications-pa404

(Solved): j Implement the pseudocode for N -Queen Problem (slide #6) in C++, with the following modifications: ...



j Implement the pseudocode for N -Queen Problem (slide #6) in C++, with the following modifications: In the base case (r=n+1), after print Q[1dotsn]n=4 t as a vector. Sets a pass-by-reference variable to tru(e)/(f)alse depending on whether the target t can be made or not. Note that this is similar to what we have done for the SubsuetSum question in the class on( 10)/(7) (Slide 18-19). Write pseudocode for the following generalizations of the SubsetSum problem: (a) Given an array .. n-1 of positive integers and an integer T, compute the number of subsets of x whose elements sum to T. (b) Given two arrays x[0..n-1] and W[0..n-1] of positive integers and an integer T, where each {:W_(i)] denotes the weight of the corresponding element x[i], compute the maximum weight subset of x whose elements sum to T. If no subset of x sums to T, your algorithm should return -1. For example, suppose T=32,x={15,17,12,18,2},W={3,4,3,3,3} The following two subsets of x both sum up to 32 : {15,17} and {12,18,2}. The first subset's total weight Is 3+4=73+3+3=9 We would return the second subset as the total weight of all elements chosen is larger. Note: You can refer to the SubsetSum that returns the smallest subset (as given in the slides, and described in class).


We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe