Course Hero Logo

midterm1-solutions.pdf - CIS 320 – Spring 2018 02/26/18 1...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 3 out of 6 pages.

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)
(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)
Strictly for the personal use of students registered in CIS 320, Spring 2018 at University of Pennsylvania.

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 6 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
Stroud
Tags
Big O notation, Natural number, Binary heap

Newly uploaded documents

Show More

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture