CIS 320 – Spring 2018 (02/26/18)1Midterm Exam 1 SolutionsImportant Note: Do not distribute or share these solutions. They are strictlyfor the personal use of students registered in the Spring 2018 edition of CIS320 at University of Pennsylvania. Any violations will be referred to the Officeof Student Conduct.Problem 1.For each of the four subproblems problem below, a clear description ofyour solution, an analysis of its time complexity, and a brief justification of your approachis sufficient.No detailed proof of correctness is needed for problems 1a – 1d.(a) You are given anunsorted arrayAthat containsnpositive integers. Design anO(n)expectedtime algorithm to determine whether or not all values inAare distinct.(10 points)
Get answer to your question and much more
(b) You are given asorted arrayAcontainingndistinct positive integers from the set{1,2,3, . . . , n, n+ 1}.Design anO(logn) time algorithm that outputs the uniquevalue from the set which is not present in the arrayA. You may assume thatn= 2kfor some positive integerk.(10 points)
Get answer to your question and much more