CSCI140Name: Maxim KoretskyAssignment 0 #: January 19thProblem 2AWrite pseudocode for a function dedup that takes as input an array/list and returns anew array/list with all of the duplicates removed. You don’t have to necessarily follow theconventions used in class, but use something reasonable and be consistent.Solution:Pseudocode:newSet←()newList←[]i←0 for e in L:if e in S:continue;S.add(e);M.append(e);Problem 2BWhat is the big-O running time of your function? Give a brief (one sentence) justification.Solution:The run time of my pseducode would have to be o(n2) as the list is being iterating n timesand being checked for the duplicates n times. Hence o(n2)Problem 5AThere are two buses, A and B, about to take students on a field trip. Bus A contains 50 1stgrade students. Bus B contains 50 2nd grade students. Before the buses leave, 8 students runout of Bus A and onto Bus B. The teachers then randomly choose 8 of the now 58 studentson Bus B and force them to move to Bus A. The buses then (finally!) drive off. Are theremore 2nd grade students in Bus A or more 1st grade students in Bus B?Solution:There will be less 1st grade students in Bus B than 2nd grade students in Bus A. Explanationis as follows. Once the 8 1st graders leave their respective Bus A and leave for Bus B, nowthere will be 42 1st graders in Bus A and 50 2nd graders with 8 1st graders in Bus B. Oncethe teacher orders 8 random students from the 58 to go to Bus B, there is a 8/58 chance that1
a 1st grader will go back to bus A and a 50/58 chance that a 2nd graders will be selectedto go to their new Bus A. The odds that a 2nd grader will be selected opposed to a first isabout 6 times higher. This suggested that it is quite low likeihood that a 50/58 chance willhit at least 4 times. The amount of 2nd graders has to be higher than the amount of 1stgrader sent back to bus A therefore it is of higher likeihood that there will be less 1st gradestudents in Bus B than 2nd grade students in Bus A.Problem 5BProve by induction that∑ni=11i(i+1)=nn+1for all integersn≤1. Do you need strong induc-tion? Why or why not?SolutionBase Case (n=1):11(1+1)=12. This shows 0.5 is equal to 0.5Inductive hypothesis:∑ni=11i(i+1)=nn+1is true for all integersn≤1Inductive proof (k+1 = n):∑k+1i=11i(i+1)=k+1k1.∑k+1i=11i(i+1)=k+1k2.∑k+1i=11i(i+1)=11∗2+12∗3+13∗4+...1k∗(k+1+1(k+1)∗(k+2)3. (11∗2+12∗3+13∗4+...1k∗(k+1)+1(k+1)∗(k+2)4.kk+11(k+1)∗(k+2)=k+1k+2(this holds true through algebra)2