McGill University COMP251: Assignment 4
Worth 10%. Due November 12 at the beginning of lecture (10am sharp!) Note For this assignment, you can simply say insert (an element) x into (a linked list) L w
McGill University COMP251: Assignment 3 Solution
Question 1 Idea: A number x in cfw_0, 1, . . . , n3 1 can be expressed in the form a2 n2 + a1 n + a0 where 0 a2 , a1 , a0 n 1. More precisely, a2 = x x
McGill University COMP251: Assignment 3
Worth 10%. Due October 29 at the beginning of lecture (10am sharp!) Question 1 Give an algorithm that sorts (into non-decreasing order) an input array of n inte
McGill University COMP251: Assignment 2 Solution
Question 1 The partition procedure on a sorted array of length n always gives an empty subarray and an subarray of length n 1. So in this case the runn
McGill University COMP251: Assignment 2
Worth 10%. Due October 1 at the beginning of lecture (10am) Question 1 Suppose A is already sorted in increasing order. Prove that the running time of Quicksort
McGill University COMP251: Assignment 1 Solution
Question 1 (a) Idea Let k = n . Then A[k ] is the median of A, and B [k ] is the median of B . 2 The Divide-and-Conquer algorithm arises from the follo
McGill University COMP251: Assignment 1
Worth 10%. Due September 17 at the beginning of lecture (10am) The work you submit must be your own. You may discuss problems with each others; however, you sho