There are N students in both Cmpt125 and Cmpt127 in a given semester. Most stude
ID: 3786790 • Letter: T
Question
There are N students in both Cmpt125 and Cmpt127 in a given semester. Most students who take Cmpt125 and also in Cmpt127 but due to different pre-requisites, past fails of one course or another, the class for both courses do not exactly match up. Let C125[N] and C127[N] be two arrays representing the student numbers of students registered in each class, write a pseudocode algorithm called duplicate_students (C125[N] TNI, C127[N]) to determine the number of students who are taking both courses. For example, given that: C125 = [210, 125, 138, 243, 152, 262, 970, 183, 199, 100] C127 = [340, 199, 100, 262, 210, 183, 464, 125, 907, 243] Executing the duplicate students(C125[N], C127[N]) function would return 7 (the duplicate students have been highlighted)Explanation / Answer
Below is the O(nlogn) solution : Sort C125[] and C127[] using quick sort or merge sort i = 0 j = 0 found = 0 while iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.