Exam 3

Patterns and Transformations

CS 3530
Design and Analysis of Algorithms

Thursday, April 17, 2014 @ 1:00 PM



Use this problem description for Problems 1-2.
Let A = [ a1, a2, ... an ] be an array of integers. We would like to find d, the distance between the two closest numbers in the array. The distance between any two numbers ai and aj is |ai - aj|. For example, if A = [9, 14, 25, 6, 16], then d = 2.

  1. Design a brute force algorithm to compute d. How many times does this algorithm compare two distances?

  2. Use presorting to design an algorithm to compute d. How many times does this algorithm compare two distances?

  3. Answer briefly these questions about about Bloom filters.

  4. We would like to use a heapsort to sort the letters in my name, EUGENE, in ascending order.

    You may use either a tree implementation or an array implementation for your heap. Be sure to use a parental dominance rule where a node is all of its children, not strictly <. You will receive partial credit for using the bottom-up algorithm to construct the heap.

  5. Network Services is considering consolidating all of its on-campus labs into a single lab, in the basement of Maucker Union. They want to know the maximum number of users they will have at any point in time, so that know how many computers they will need in the consolidated lab.

    To help us help them solve this problem, they have created a large number of data files, one for each day of the year. Each file contains an even number of integers, in pairs that correspond to the login time and session length for every lab user on campus on that day. For example, a file that contains:

                    0115 47
                    0737 3
                    1104 78
                    1852 422

    records four users. The first logged in at 1:15 AM and worked for 47 minutes. The last logged in at 6:52 PM and worked for 7 hours, 2 minutes. (He must have had an algorithms project to do!)

    Use the Sliding Delta pattern to design an algorithm to find the maximum number of users at any point in time last year.

Eugene Wallingford ..... wallingf@cs.uni.edu ..... April 17, 2014