day 21 4/1/98 ``I knew there should have been another step in here.''
Running time of merge sort:
T(n) = 2T(n/2)+n with T(1) = 0
Assume we want T(n) = O(n)
Then T(n) = 2O(n/2)+n = O(n)? Wrong! Bad!
Instead, try: T(n) = cn then T(n) = 2cn/2+n = (c+1)n which doesn't work.
try: T(n) = cnlogn then T(n) = 2cn/2logn/2+n = cnlogn/2+n = cnlogn-cn+n which is solvable for c = 1 .
The Random-Mate algorithm essentially has every node in the list guess it's parity. The algorithm (covered last meeting) works in 2 phases. In the first phase, nodes are eliminated while in the second phase, you back up the tree filling in the values of each node as in Wiley's algorithm.
Probability that a node is removed from the list at each stage in the forward algorithm is 3/4 . So Pt = (3/4)t = probability that a node is still in the list after t rounds. If we want Pt = [1/( n2)] then t = 2log4/3n .
The probability that no node is left in the list is: Pleft £ åi = 1n-1Pt £ nPt £ 1/n if t = 2log4/3n
Because of the random nature of this algorithm it is difficult to group enough nodes on each processor s.t. every processor will always have work to do. A prescan can be done over the elements to reallocate their location at each step.
The algorithm works on a doubly linked list.
Timing is O(logn) with high probability
Let P(head) = 1/4 and P(tail) = 3/4
Let Spt = #head in t trials.
P(Spt < logn) can be bounded by Chernoff Bounds
P(Stp < (1-b)pt) < e-b2[(pt)/ 2] for 0 £ b £ 1
In particular, P(S16logn1/4 < (1/4)4logn) < e-[(32)/( 42)][(4logn)/ 2] = e-9/8logn = [1/( n9/8)] < 1/n
= probability that a processor is not done.
The probability that all processors is done is £ åi = 1nlogn1/n = [(n)/( logn)]1/n = [1/( logn)] .