planar graphs course homework 3
submission for:
- eden asta 209147487
- mahmood sheikh 212835466
in class we sketched how to solve the maximum matching problem in planar graphs using separators. we argued that the running time for any input graph
is bounded by the
recurrence:
where
is the number of vertices of
and
and
are the number of vertices of the two parts of
obtained by deleting the vertices of the separator. prove that
. hint: use induction on
. beware of using the big-oh notation too liberally...
recurrence:
we include the definition of
:
, for the base step, consider
or
, the problem can be solved in constant time (no need to apply a divide-and-conquer approach because there's nothing to divide), we have
trivially. assume for the induction hypothesis that for every
we have
(for some constant
), we apply the induction step:
which gives us the constant
for which we have
for any sufficiently large
and this means
by definition.
if
are two functions from
to
, then we
we apply strong induction on - say that
if there exists a constant
such that
for every sufficiently large
,
- say that
if
,
- say that
if
and
,
- say that
if for every
for every sufficiently large
, and
- say that
if
.
in class we mentioned that there are data structures that can support all the necessary operations for MSSP in
time per operation. in this problem you will develop a simpler data structure that supports similar operations on sequences (i.e., on paths) instead of on trees. this will give you a feeling for how the data structure for trees may be constructed.
we shall represent a sequence of numbers
by storing the numbers in a balanced binary search tree, where element
is considered less (in the tree order) than element
if
.
we shall represent a sequence of numbers
- describe how to support the operations
, which splits the sequence immediately after the
'th element, and
which, given two sequences
with a total of
elements, returns a single sequence consisting of all the elements of
followed by all the elements of
. the running time should be
, where
is the total number of elements. you may use the standard BST operations split and join (make sure you understand how they are implemented in at least one specific balanced BST implementation, but you do not have to explain that in your answer). make sure to address the following issue: you cannot afford to store the index of each element explicitly since the indices of many elements are changed by the join operation.
- describe how to also support in
time the operation
, which returns the
'th number in the sequence, and the operation
, which, adds
to the first
elements of the sequence.
- describe how to also support in
time the operation
, which reverses the order of the elements between indices
and
in the sequence.
- (bonus 5 points) describe how to also support the operation
, which returns the minimum number among the first
elements in the sequence.
using AVL trees we can concatenate two trees in
, search is also
, which can be used to split a given sequence.
let
denote the BSTs corresponding to the sequences
, respectively.
to implement
we consider the following: the elements of
should be placed before the elements of
in the tree, so that for any
, we have that
in the tree, and more generally we need to have that
according to the order of the tree, to accomplish this we "stitch" the two trees
together in such a way that rebalancing the resulting tree isnt too expensive.
note that the keys in
arent the values themselves but rather the indicies, each node holds both an index and a value (among other potential metadata), for example the node corresponding to
will have the value of
, but its key in the tree will be the index
, which means that the tree will be ordered according to the indicies of the sequence, but not necessarily the values, this allows us to place arbitrary values in the sequence but maintain the order that we like.
the steps for
are:
rotations to the new root to get the tree to be balanced, this would still take
time. this algorithm runs in
. an example is demonstrated in [[blk:fig-planar-graphs-homework-3-1]].
/home/mahmooz/brain/pen/2024-12-23-Note-22-35.xopp
to implement
, we search for
(
refers to the node whose key is
) as we would in a binary search tree, which takes
, and while looking for
, we store the first node that has an index bigger than
that we encounter, call it
, once we reach
, we extract the subtree rooted at
and apply a left rotation to
to get its right child to become the parent of the subtree that was rooted at
, then remove the left subtree that is now rooted at the node whose index was
, this is demonstrated in [[blk:fig-planar-graphs-homework-3-2]]. note that if we store the path we took to get from
to
during the search, splitting the tree would be a matter of pointer manipulation and would take constant time.
/home/mahmooz/brain/pen/1735029847.303587.xopp
to implement
we apply the same search routine and grab the element with key
and return its value.
to support
we use
to first identify the set of nodes that we need to operate on, but we cant apply the operation directly because that would take time that is linear in
, we instead use a technique called lazy propagation.
we place a special mark we call "to-add" (using node "metadata") on the root of the first split of the tree, and other marks named "dont-add" on the nodes where we make the green cuts shown in [[blk:fig-planar-graphs-homework-3-2]], the first mark will hold the value
which will tell us that all values of the nodes of the subtree rooted at the marked node need to be increased by
(
can be equal to
or can be an accumulation of
for subsequent calls to
). the latter marks called "dont-add" will tell us that the effect of the first mark ends at those nodes, so that we dont apply add
to the entire subtree unnecessarily. this wont modify the values of the nodes directly, but rather would be handled upon a call to one of the functions
or any other function that applies a search routine to the tree, the function that applies the seaerch routine needs to check if the node it visits are descendants of a marked node, and apply the addition if so, then it needs to propagate the mark to its children, unless one of them has the "dont-add" mark that stops the "to-add" mark of its parent.
to support
we use the same idea of lazy propagation where we mark nodes for reversal instead of for adding a constant
, to apply the reversal we would rotate the positions of the children of a node that we visit, so that the right child becomes the left child, and the left child becomes the right child (we apply this operation whenever we visit a node that is marked for reversal during later traversal of the tree).
let
to implement
note that the keys in
the steps for
- remove the rightmost node from
as you would in any AVL tree (this node would have the biggest key in
, due to the ordering property of AVL trees),
- construct a new tree with the left child being the modified tree
, and the right child being the tree
,
- apply AVL rotations to
as necessary as if we just inserted it into the tree.
/home/mahmooz/brain/pen/2024-12-23-Note-22-35.xopp
to implement
/home/mahmooz/brain/pen/1735029847.303587.xopp
to implement
to support
we place a special mark we call "to-add" (using node "metadata") on the root of the first split of the tree, and other marks named "dont-add" on the nodes where we make the green cuts shown in [[blk:fig-planar-graphs-homework-3-2]], the first mark will hold the value
to support
- let
be an
-vertex planar graph with non-negative dart lengths. let
and
be two faces, and
be a simple path from a vertex on
to a vertex on
. give an
-time algorithm that returns a minimum length simple cycle that enclosess exactly one of
and
, and crosses
at most once. you probably understand intuitively what is meant by saying a path
crosses
. here is a formal definition: we say dart
enters a simple path
from the left if
is an internal vertex of
, and if the orbit of
induces the cycle
, where
is the dart of
whose head is
, and
is the dart of
whose tail is
.
enters
from the right if the induced cycle is
. we say dart
emanates left (right) of a simple path
if
enters
from the left (right). we say a path
crosses
if there is a subpath of
that can be written as
, where
enters
from the left (right),
is a (possibly empty) subpath of
, and
emanates right (left) of
. hints: this problem is related to MSSP. the following thought experiment is useful. think of the graph
embedded on a piece of paper. what becomes of the path
when you take a knife, make an incision along
, and then pull apart both sides of the incision? You may assume that the representation of the primal tree
at any time along the execution of the MSSP algorithm allows you to query the length of the path in
from the root to any vertex
in
time.
- let
be an undirected connected planar graph with non-negative edge lengths. let
and
be two faces of
. give an
-time algorithm that finds the shortest cycle in
that separates
and
.
- for vertices
,
in an undirected graph with edge capacities, a minimum st-cut is a set of edges that separates
and
and whose sum of capacities is minimum. let
,
be two distinct vertices in an undirected connected planar graph
with non-negative edge capacities. give an
-time algorithm that returns a minimum st-cut in
.