homework#4 divide and conquer - basic studies in...

1

Click here to load reader

Upload: doanmien

Post on 16-Jun-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Homework#4 Divide and Conquer - Basic Studies in …basics.sjtu.edu.cn/~xiaojuan/algo16/homework/hw4.pdf · 2016-09-26 · Space complexity of Quicksort. Modify QUICKSORT to ensure

Homework#4 Divide and Conquer Textbook:

Counting inversions. An inversion in an array a[] is a pair of entries a[i] and a[j] such that i<j but a[i]>a[j]. Given an array, design a linearithmic (O(nlogn)) algorithm to count the number of inversions. Space complexity of Quicksort. Modify QUICKSORT to ensure its work space is Θ(log n).