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 without having to give the details of how it is implemen
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 , a1 = a2 n, a0 = x n(a2 n + a1 ) 2 n n
In other words
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 integers in the range 0 to n3 1. Your algorithm must run in
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 running time T (n) of Quicksort satises: T (n) = T (n 1) +
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 on input A is (n2 ). Question 2 Consider the following
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 following observation: Observation Suppose that A(k ) B (k )
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 should prepare written solutions alone. Copying assignment