Integer Multiplication: Reading & Research

(This exercise is for your own reading and research based on a textbook chapter we skipped in class.) Read the discussion on Integer Multiplication algorithm using divide-and-conquer in Section 5.5 of the textbook (pages 231 – 234 provided below), and provide answers as specified below. Assume the integers multipled are binary integers.

  1. Write the key idea that enables the algorithm to divide the problem into three disjoint subproblems — that is, to achieve the multiplication of two n-bit integers from multiplying two n/2-bit integers three times.

  2. Write the resulting divide-and-conquer algorithm in an executable pseudocode. Name the algorithm “MultInt”. Do not copy the pseudocode in the texbook but write your own pseudocode. Make sure to add the base case; the textbook code may not have the base case. Make use of the following functions as needed in your pseudocode.

  • MultInt(x, y, n) returns the multiplication of two n-bit integers x and y.
  • Add(x, y, n) returns the sum of two n-bit integers x and y, i.e., x + y.
  • Sub(x, y, n) returns the difference of n-bit integer y from n-bit integer x, i.e., x – y. LSL(x, b) returns x shifted to the left logically by b bits. (Logical shift left (LSL) shifts in bit 0’s on the least significant bits.)
  • LSR(x, b) returns x shifted to the right logically by b bits. (Logical shift right (LSR) shifts in bit 0’s on the most significant bits.)
  • ceil(b) returns the ceiling of b.
  • floor(b) returns the floor (i.e., truncation)of b.

Note:

  • Dividing (i.e., separating) an n-bit integer into the upper n/2-bit integer and the lower n/2-bit integer can be implemented in linear time by calling logical-shift by n/2 bits (LSL and LSR below).

  • Multiplying an integer by 2n can be implemented in linear time by calling logical- shift left by n bits.

  1. Write a recurrence relation that expresses the run-time, T(n), of the recursive algorithm, and explain how each term in the recurrence relation is formed.

  2. Write the steps of solving the recurrence relation to derive the run-time complexity T(n) = O(nlg3) (=O(n1.585)). (Here, lg3 log23.) Use the recursion tree technique to derive the run- time complexity; make a simplifying assumption that n is a power of 2 integer. Do not use the master theorem in Section 5.2. There is no need to give a formal proof of big-O.

1. Key Idea

Our key idea that allows us to divide our problem into 3 smaller problems is to use the following formula instead of just the 4 products by factoring:

Henceforth, we can do recursively, recursively, and recursively, we can get the desired middle term using subtraction:

Leaving us with a problem of only 3 recursive multiplacions, which greatly reduces time complexity.

2. Pseudocode

See figure 1(may be on a different page due to latex compilation quirks.

Pseudocode multiply two n-bit integers using divide and conquer

3. Recurrence Relation

For a running time :

where we imagine to represent a constant.

The is the 3 recursive call structure we had before, is the divide/conquer overhead(given than both divide and conquer operations are ).

4. Recurrence Solutino with Recurrence Tree

where we assume that for an integer , and where is a power of .

Performing recursion tree analysis yields:

And the tree height:


Weighted Interval Scheduling: Algorithm Tracing

Consider the dynamic programming algorithm we discussed for the weighted interval scheduling problem. Run the bottom-up (i.e., iterative) implementation of the algorithm on the problem instance shown below. Show the algorithm trace in the same manner as in Figure 6.5(a) and (b) (page 260) of the textbook - specifically, show in your answer:

  1. The plot of sorted jobs
  2. The list of values of for each job . (Note thte job numbers here are the number after the sorting.)
  3. The memoization table (array) filled in after each iteration of the algorithm, with arrows pointing to the array entries containing solutions to the two subproblems.
  4. the set of jobs selected as sa result. (There are two alternative optimal sets of jobs possible with the algoirthm; either one can be given as the answer)

Given job graph

1. Sort Job by Finishing time

Jobs sorted by finish time as a gantt diagram made using mermaid: see figure 03

Gantt Diagram Job Schedule

2. COmpute Values

Given each job , we know that is the largest index where job is compatible with job .

3. Memoization Table

Where we set recurrence as :

Yielding a final array of:

4. Optimal Solution

We can find this by performing a traceback to find our selected jobs:

Then, using selected jobs :

Yielding a total value of .