# Algorithms | Applied Sciences homework help

- Suppose that you are looking through some boxes stored in your parents’ attic and you find an old cassette tape music player of the type that was popular in the 1980s. The recording functions work perfectly, so you can record your favourite songs, but some of the playback functions are not working properly. The fast forward does not work at all and when you press stop after playing a song, the player rewinds the tape to the beginning. So, if you want to listen to a song, you have to listen to all of the songs that precede it on the tape.

You want to record n of your favourite songs on the tape. Song i has length li and the

probability that you will play song i is pi, 1 ≤ i ≤ n. (Of course, ????ni=1 pi = 1.) If the songs

are recorded on the tape in the order i1,i2,…,in, then the average time to play a song is n????j????

T = ???? pi ???? li . Prove that recording the songs in decreasing order of pi minimizes T . jk li

j=1 k=1

- You are given an undirected graph G = (V, E) with positive weights on the edges. If the edge weights are distinct, then there is only one MST, so both Prim’s and Kruskal’s algorithms will find the same MST. If some of the edge weights are the same, then there can be several MSTs and the two algorithms could find different MSTs. Describe a method that forces Prim’s algorithm to find the same MST of G that Kruskal’s algorithm finds.

- A connected graph G = (V,E) with n = |V| vertices can have many different spanning trees, each with exactly n − 1 edges. The relationships among these spanning trees can be represented by a meta-graph SG. Each vertex of SG corresponds to one of the spanning trees of G. There is an edge between two vertices of SG if the corresponding spanning trees Ti and Tj have n−2 common edges in G (so Ti has exactly one edge of G that is not in Tj and Tj has exactly one edge of G that is not in Ti). Prove that the meta-graph SG of any connected graph G is also connected.

4. Consider the meta-graph SG of question 3, and suppose that the edges of G have positive integer weights. The weights are not necessarily distinct, so there can be more than one minimum spanning tree (MST) of G. Some vertices of SG will correspond to MSTs of G and the other vertices correspond to spanning trees of G that do not have minimum weight. Prove that the subgraph of SG that is induced by the vertices of SG corresponding to MSTs of G is connected.