HW5. Heap, Union-find (8th of Oct, 23.59)
EX1. Read: Kamp (CACM 2010 53:7) "You're doing it all wrong.". What is the main criticism in the article? What is your opinion about the article? Discuss how exactly should the Heap use implicit indexing (i => 2*i, 2*i+1; and parent==i/2 ) be changed according to Kamp's article.
EX2. Consider an interval (x, y). In this exercise we will interpret these intervals as geometrical points in 2D space, such that x would be on the x-axis and y on the y-axis. First of all we will fix one interval (5, 10) and use it as a reference interval. The rest of the points in this 2D space need to be coloured according to the type of relationship they have with the reference interval. For example interval (1, 3) would be non-overlapping from the left to the reference interval, interval (11, 14) non-overlapping from the right etc. How many types of relationships are there in this 2D space? Visualise these types by colouring points (making coloured regions) in the space accordingly. Include reference interval and also one example interval from each region.
EX3. Simulate inserting values 6, 4, 2, 9, 12, 20, 12, 13, 7, 5, 11 into a min-priority Binomial heap. Draw the final state. Then delete the min value 4 times in a row. Draw the final state.
EX4. Implement Union-Find with path compression. Simulate the efficiency of it by generating one million singletons and then performing merges between two random elements until only one set is left. Count the number of unsuccessful mergers (both items i and j were already in the same set) and the number of edge lookups needed to achieve the final situation where only one single set is left. Repeat the same simulation for 10 times and discuss how stable are those two measured numbers are.
singletone: single isolated node with no edges
EX5. Use 4-D data points given below. Define a random hyperplane direction. Find such a hyperplane that would split the data points at “median” - half on one side, half on another side. Label the below points accordingly and calculate the distance from the hyperplane. Provide formulae in your report.
X Y Z D 69.09 54.00 25.41 53.81 20.94 1.42 81.92 22.04 37.50 17.07 67.45 47.57 81.43 12.07 34.50 43.36 45.47 48.67 20.09 71.35 61.15 37.69 66.32 82.65 10.36 40.16 73.01 28.76 81.32 48.76 92.31 66.00 25.58 97.98 33.35 86.06 41.63 95.85 29.15 97.37 12.32 1.54 32.08 38.43 15.24 79.05 83.79 48.47 65.94 44.86 35.05 65.39 66.48 75.14 39.06 63.50 90.28 34.17 97.13 92.62 60.91 38.70 26.60 81.90 22.75 26.87 51.45 89.81 72.22 23.59 7.51 53.80 77.12 73.64 94.43 44.94
EX6. (bonus 2p) Oct-tree is a generalisation of quad-tree from 2D into 3D. Now generalise it further into 4D and show how the data from previous exercise would be distributed. Note that to identify a particular (largest bounding) cell a binary vector - 0/1 along each dimension is sufficient. Assign to each point the label of a bounding box with such 4-bit numbering. If cell has more than one value, split it further. For the first data point the outermost bounding box is 1101 and for the second point it is 0010. If some cell contains multiple values and needs to be split further, indicate that particular next-level split as well. How would you search for a new query point listing all points within a radius 10 from it?