quiz حل الأسئلة الجامعية manage_search الأرشيف

تم الحل ✓
categoryبرمجة وتطوير البرمجيات schoolبكالوريوس event_available2026-07-15

السؤال

Transcribed Image Text:

1) (25 pts) Consider the Find and Replace Problem: Input: A two dimensional n x n binary array, a11 a12 aln A an1 an2 Ann W11 W12 and 2 x 2 binary arrays v= V11 V12 V21 V22 and w= W21 W22 Output: Continuously find the v array in the A array and replace them with the w array until there is no more v array in the A array. 1 0 0 1 0 1 1 0 1 10 Ex: Let n 6 and the array be A 0 0 1 1 0 1 10 10 00 and we want to continously find the array v = = [ ] 1 0 1 1 00 0 100 10 to replace with the array w = Note that, we highlight the v arrays in A with colors. Observe that the entry 0 is in the intersection of two v arrays. To avoid ambiguity, whenever you detect a v array in A immediately replace it with the w array. Then, after the first round of the replacement we obtain 1 A' = 1 100 100 1 1 1 101 001 1 10 1 0 1 0 1 1 0100 00 which still includes a v array. Then, in the second round we obtain 1 1 1 1 1 1 1 0 0 100 1 1 1 1 0 1 A"= 1 1 1 1 10 00101 1 0 1 0 0 0 0 the final result since there is no more v array. (1.1) (15 pts) Design an algorithm, say Find & Replace algorithm, to obtain the updated array. Write the pseudocode of your algorithm. Code your algorithm in Java by randomly generating the input arrays A, v and w. (1.2) (7 pts) Analyze the time complexity of your algorithm. Give an asymp- totic upper bound on the running time of your algorithm. Calculate the running time of your Java code for n = 10, 100, 1000 and visualize the asymptotic upper bound and the experimental time complexity in one plot. (1.3) (3 pts) Is Find & Replace algorithm an efficient algorithm? Why, why not? Submit the Java codes.

check_circle الجواب — حل مفصل خطوة بخطوة

hourglass_top