Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago