CMPS 144L Spring 2019
Lab #13

The activities in this lab mimic problems that you are likely to see on the final exam and can be answered using pen(cil) and paper.

Activity #1: Operations in Heaps

                2
               / \
              /   \
             /     \
            /       \
           /         \
          /           \
         /             \
        5               7
       / \             / \
      /   \           /   \
     /     \         /     \
    /       \       /       \
   6        15     12        9
  / \      /  \
 /   \    /    \
8    14  23    18
Consider the min-heap shown nearby, assumed to represent a priority queue in which priorities increase as keys decrease. (Only the keys are shown and not any associated data.)

1. Show the contents of an array that represents the heap.

2. Carry out the following operations in succession, showing what the heap looks like after each operation has been completed.

(a) insert(16)
(b) insert(-1)
(c) deleteMin()
(d) deleteMin()


Activity #2: Kruskal's Algorithm

Apply Kruskal's Algorithm to the graph shown below to produce a minimum spanning tree. In addition to showing the edges that were chosen to be in the tree, identify the edges that were candidates to be included but were rejected because they would have given rise to a cycle.