18-07mar29arrays

# 18-07mar29arrays - 1 1 CS100J 29 March 2007 Arrays...

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

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.

Unformatted text preview: 1 1 CS100J 29 March 2007 Arrays: searching & sorting. Reading: 8.5 Why did I get a Christmas Card on Halloween? Searching and sorting algorithms are on the course website. Decimal 00 01 02 03 04 05 06 07 08 09 10 Octal 00 01 02 03 04 05 06 07 10 11 12 Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 Decimal 11 12 13 14 15 16 17 18 19 20 21 Octal 13 14 15 16 17 20 21 22 23 24 25 Binary 01011 01100 01101 01110 01111 10000 10001 10010 10011 10100 10101 Decimal 22 23 24 25 26 27 28 29 30 31 32 Octal 26 27 30 31 32 33 34 35 36 37 40 Binary 010110 010111 011000 011001 011010 011011 011100 011101 011110 011111 100000 2 Decimal 5482: 5*10 3 + 4*10 2 + 8*10 1 + 2*10 Octal 3726: 3*8 3 + 7*8 2 + 2*8 1 + 6*10 Binary 1011: 1*2 3 + 0*2 2 + 1*2 1 + 1*2 /** = a string that contains the binary representation of n. Precondition: n >= 0 */ public static String binary( int n) { if (n <= 1) return “” + n; return binary(n/2) + (n%2); } 3 Getting an invariant as picture:...
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

18-07mar29arrays - 1 1 CS100J 29 March 2007 Arrays...

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

View Full Document
Ask a homework question - tutors are online