Lecture 09 Ticket

Complete before the beginning of class on Wednesday, 09/21

Download this ticket in pdf format or .tex source.

  1. Suppose \(a\) is an array of binary values of size \(n\). That is, for every index \(i\), we \(a[i] = 0\) or \(1\). Give pseudocode for a procedure that sorts \(a\) in \(O(n)\) time.

  2. Each row below represents a 12-bit binary integer (where the right most bit is the 1s bit, etc). Sort the list of numbers in ascending order.

1
2
3
4
5
6
7
8
9
  110110100110
  100110001001
  001000101000
  101100111001
  000010001010
  111100011100
  101111001100
  010100010010
  011011100010