Question: a)Briefly explain what is the complexity of your algorithm. More specifically, has your solution has an acceptable complexity; is it scalable enough; etc. If not,

a)Briefly explain what is the complexity of your algorithm. More specifically, has your solution has an acceptable complexity; is it scalable enough; etc. If not, what are the reasons behind that? b)Explain the details of your algorithm, and provide its time and space complexity. You must clearly justify how you estimated the complexity of your solution.

c)Compare the complexities between the two versions.

static void UnHide(char[] row, int index, PrintStream p){ if(row.length == index){ System.out.println(row); p.println(row); } else if(row[index] == '#') { row[index] = 'X'; UnHide(row, index + 1, p); row[index] = 'O'; UnHide(row, index + 1, p); row[index] = '#'; } else UnHide(row, index+1, p); } static void IterativeUnhide(String row,PrintStream p){ ArrayList a = new ArrayList<>(); int index; a.add(row); while (!a.isEmpty()){ String temp = a.get(0); a.remove(0); if((index = temp.indexOf('#'))!=-1) { temp = temp.substring(0, index) + 'X' + temp.substring(index + 1); a.add(temp); temp = temp.substring(0, index) + 'O' + temp.substring(index + 1); a.add(temp); } else { System.out.println(temp); p.println(temp); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!