Docsity

Data Structures & Algorithms: Skipping Lists, Polynomial Multiplication, Independent Sets, Study notes of Introduction to Computers

Toggle sidebar
bg1
Data Structures and Algorithms - COMS21103
Skipping, Multiplying and Independence
Problem Sheet
1. This question is about skip lists.
(a) Write out in pseudocode an Insert(SL, X) function which inserts an element into an existing
skip list called SL and provide a brief explanation of how it works. You can assume a coin
toss function CT which takes no arguments and returns a 1 or 0 with 50% probability of each.
(b) What does the term with high probability mean when applied to a randomised algorithm?
(c) Assume that for some reason the random number generator has broken so that instead of
giving 1 or 0 with 50% probability it produces an alternating sequence of ones and zeros (i.e.
1,0,1,0, . . .). Discuss what difference this makes to the time complexity of the Insert and
Search operations when compared to the standard skip list with a uniform random number
generator.
2. The goal of this question is to reduce the asymptotic performance of polynomial multiplication
where one polynomial is of degree nand the other is of degree m. We will reduce the space
complexity from Θ(n) to Θ(m) and the time complexity from Θ(nlog n) to Θ(nlog m). Show how
this can be achieved by making a new algorithm that repeatedly makes calls to the polynomial
multiplication algorithm given in the lectures. Prove that the new space and time complexities are
as required.
3. Let G= (V , E) be a graph with nvertices, that is V={v1, v2, . . . , vn}, and assume that each
vertex vihas associated with it a strictly positive weight wi∈N. We define the weight of a subset
S⊆Vas the sum of the weights of the vertices in S. Also, we say that a set of vertices S⊆Vis
independent if no two vertices in Sare connected by an edge in E.
(a) Assume that the vertices in Gare on a line, that is the set of edges of Gis
E={(v1, v2),(v2, v3), . . . , (vn−1, vn)}.
Give an efficient algorithm that returns the maximum weight of an independent subset S⊆V.
Give the running time of your algorithm in big Oh notation.
(b) Explain how to modify your algorithm to actually output an independent set S of maximum
weight.
(c) Assume that the number of vertices in the graph Gis a multiple of 3, that is n= 3kfor
some integer k≥1. Argue that the weight of a maximal independent set should be at least
k·wmin, where wmin is the minimal weight of vertices in V.
1

Partial preview of the text

Download Data Structures & Algorithms: Skipping Lists, Polynomial Multiplication, Independent Sets and more Study notes Introduction to Computers in PDF only on Docsity!

Data Structures and Algorithms - COMS

Skipping, Multiplying and Independence

Problem Sheet

  1. This question is about skip lists.

(a) Write out in pseudocode an Insert(SL, X) function which inserts an element into an existing skip list called SL and provide a brief explanation of how it works. You can assume a coin toss function CT which takes no arguments and returns a 1 or 0 with 50% probability of each. (b) What does the term with high probability mean when applied to a randomised algorithm? (c) Assume that for some reason the random number generator has broken so that instead of giving 1 or 0 with 50% probability it produces an alternating sequence of ones and zeros (i.e. 1 , 0 , 1 , 0 ,.. .). Discuss what difference this makes to the time complexity of the Insert and Search operations when compared to the standard skip list with a uniform random number generator.

  1. The goal of this question is to reduce the asymptotic performance of polynomial multiplication where one polynomial is of degree n and the other is of degree m. We will reduce the space complexity from Θ(n) to Θ(m) and the time complexity from Θ(n log n) to Θ(n log m). Show how this can be achieved by making a new algorithm that repeatedly makes calls to the polynomial multiplication algorithm given in the lectures. Prove that the new space and time complexities are as required.
  2. Let G = (V, E) be a graph with n vertices, that is V = {v 1 , v 2 ,... , vn}, and assume that each vertex vi has associated with it a strictly positive weight wi ∈ N. We define the weight of a subset S ⊆ V as the sum of the weights of the vertices in S. Also, we say that a set of vertices S ⊆ V is independent if no two vertices in S are connected by an edge in E.

(a) Assume that the vertices in G are on a line, that is the set of edges of G is

E = {(v 1 , v 2 ), (v 2 , v 3 ),... , (vn− 1 , vn)}.

Give an efficient algorithm that returns the maximum weight of an independent subset S ⊆ V. Give the running time of your algorithm in big Oh notation. (b) Explain how to modify your algorithm to actually output an independent set S of maximum weight. (c) Assume that the number of vertices in the graph G is a multiple of 3, that is n = 3k for some integer k ≥ 1. Argue that the weight of a maximal independent set should be at least k · wmin, where wmin is the minimal weight of vertices in V.