# Lecture14 - Divide and Conquer Algorithms CSE 421...

This preview shows pages 1–2. Sign up to view the full content.

1 CSE 421 Algorithms Richard Anderson Lecture 14 Inversions, Multiplication, FFT Divide and Conquer Algorithms • Mergesort, Quicksort • Strassen’s Algorithm • Closest Pair Algorithm (2d) • Inversion counting • Integer Multiplication (Karatsuba’s Algorithm) • FFT – Polynomial Multiplication – Convolution Inversion Problem • Let a 1 , . . . a n be a permutation of 1 . . n •( a i , a j ) is an inversion if i < j and a i > a j • Problem: given a permutation, count the number of inversions • This can be done easily in O(n 2 ) time – Can we do better? 4, 6, 1, 7, 3, 2, 5 Counting Inversions 14 10 13 6 8 16 5 9 15 3 2 7 1 4 12 11 Count inversions on lower half Count inversions on upper half Count the inversions between the halves 1 4 12 11 15 3 2 7 15 3 2 7 1 4 12 11 8 16 5 9 14 10 13 6 14 10 13 6 8 16 5 9 Count the Inversions 14 10 13 6 8 16 5 9 15 3 2 7 1 4 12 11 4 1 2 3 14 10 19 8 6 43 Problem – how do we count inversions between sub problems in O(n) time?

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/25/2012 for the course CSE 421 taught by Professor Richardanderson during the Fall '06 term at University of Washington.

### Page1 / 4

Lecture14 - Divide and Conquer Algorithms CSE 421...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online