0% found this document useful (0 votes)
187 views2 pages

Comp 251 Assignment 5

1. The document describes an algorithms assignment with three problems: (1) designing an algorithm to partition a sequence into pairs to minimize the maximum sum and proving its correctness, (2) designing an O(n^2) algorithm to find the minimum edit distance between two strings, (3) proving properties about graph embeddability. 2. For COMP-252 students, it provides one additional problem: constructing an example where quicksort uses Ω(n^2) comparisons when choosing the pivot as the median of the first, last, and middle elements.

Uploaded by

dergachev
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
187 views2 pages

Comp 251 Assignment 5

1. The document describes an algorithms assignment with three problems: (1) designing an algorithm to partition a sequence into pairs to minimize the maximum sum and proving its correctness, (2) designing an O(n^2) algorithm to find the minimum edit distance between two strings, (3) proving properties about graph embeddability. 2. For COMP-252 students, it provides one additional problem: constructing an example where quicksort uses Ω(n^2) comparisons when choosing the pivot as the median of the first, last, and middle elements.

Uploaded by

dergachev
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Data Structures and Algorithms COMP-251

Problem Assignment #5

1. Algorithms on Sequences
You are given a sequence S of n real numbers, where n is even.
(a) Design an algorithm to partition S into n/2 pairs in the following way. For each pair we
compute the sum of its two numbers, obtaining n/2 sums. The algorithm should find the
partition that minimizes the maximum sum.
(b) Prove the correctness of your algorithm.

2. Edit Distance between Strings


Let A = a1, a2,..., an and B = b1, b2,..., bm be two strings of characters. Denote by A[i] the
string ai, ai+1,..., an. Let di be the minimal edit distance between B and A[i]. Design an
O(n2) time algorithm to find the minimum value of di over all i = 1, 2,..., n.

3. Graph Embeddability
(a) Prove that a graph G is embeddable in the plane if and only if it is embeddable on the
sphere.
(b) Prove that a planar embedding of a graph can be transformed into a different planar em-
bedding such that any specified face becomes the exterior face.

-1-
For COMP-252 students only
Problem Assignment #5

1. Quicksort
Construct an example for which quicksort will use Ω(n2) comparisons when the pivot is
chosen by taking the median of the first, last, and middle elements of the sequence.

-2-

You might also like