Assignment 1 – review questions
Due date June 16, 2020
In this assignment we review the basic algorithms and data structures. You
have five problems, marked out of a total of 100 marks.
NOTE: Your solutions must be typed, machine readable .pdf files. All
submissions will be checked for plagiarism!
1. You are given an array A of n distinct integers.
(a) You have to determine if there exists a number (not necessarily
in A) which can be written as a sum of squares of two distinct
numbers from A in two different ways (note: m2 +n2 and n2 +m2
counts as a single way) and which runs in time n2 log n in the
worst case performance. Note that the brute force algorithm
would examine all quadruples of elements in A and there are n4 =
O(n4) such quadruples. (10 points)
(b) Solve the same problem but with an algorithm which runs in the
expected time of O(n2). (10 points)
2. Suppose that you bought a bag of n bolts with nuts scr
The post basic algorithms and data structures appeared first on Assignment Freelancers.