Question: Please do Problem 2a,2b,3(3a) carefully (preferably give an explanation for each question) 2 he backtracking algorithm CHOOSE is written using Cormen s pseudocode notation he
Please do Problem 2a,2b,3(3a) carefully (preferably give an explanation for each question)


2 he backtracking algorithm CHOOSE is written using Cormen s pseudocode notation he parameters n an e are nonnega re inte er prints a series of sets; each set is a subset of 1,2n). The symbol is the empty set, and the symbol "U" is set union he paramete: sa ton nonnegative inte ers ea gorithm CHOOSEn,e,s) if 0 else for e to n CHOOSE(n, -1.e'1.s Ue')) 2a. (5 points.) What sets will CHOOSE(4, 3, 1, O) print? Hint: enumerate the recursive calls breadth-first. 2b (5 points) Let I and m be nonnegative integers. What does CHOOSEm, 1 O) compute? Your answer must be one short sentence, stated in terms of Z and m 3. Suppose that q is a priority queue. It has the following operations. IS-EMPTY () Test if g is empty. Return either true or false IS-FULL(@) Test if g is full. Return either true or false ENQUEUE(g, e, p) If g is full, then assert an error. Otherwise add the element e to q with integer priority p. DEQUEUE(a If q is empty, then assert an error. Otherwise remove the element from q with the highest priority. Return the removed element. 3a. (5 points.) Explain how to implement a stack (last-in, first-out) using these operations. Your answer may be in English, in Cormen's pseudocode notation, or in a programming language 2 he backtracking algorithm CHOOSE is written using Cormen s pseudocode notation he parameters n an e are nonnega re inte er prints a series of sets; each set is a subset of 1,2n). The symbol is the empty set, and the symbol "U" is set union he paramete: sa ton nonnegative inte ers ea gorithm CHOOSEn,e,s) if 0 else for e to n CHOOSE(n, -1.e'1.s Ue')) 2a. (5 points.) What sets will CHOOSE(4, 3, 1, O) print? Hint: enumerate the recursive calls breadth-first. 2b (5 points) Let I and m be nonnegative integers. What does CHOOSEm, 1 O) compute? Your answer must be one short sentence, stated in terms of Z and m 3. Suppose that q is a priority queue. It has the following operations. IS-EMPTY () Test if g is empty. Return either true or false IS-FULL(@) Test if g is full. Return either true or false ENQUEUE(g, e, p) If g is full, then assert an error. Otherwise add the element e to q with integer priority p. DEQUEUE(a If q is empty, then assert an error. Otherwise remove the element from q with the highest priority. Return the removed element. 3a. (5 points.) Explain how to implement a stack (last-in, first-out) using these operations. Your answer may be in English, in Cormen's pseudocode notation, or in a programming language
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
