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

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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: Combine pre- and...
View Full Document

This note was uploaded on 03/03/2012 for the course CS 100J taught by Professor Davidgries during the Spring '07 term at Cornell University (Engineering School).

Page1 / 10

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online