CSCI 101 Introduction to Computers Class Notes (Fall 2024) ========================================================================== Friday, November 08, 2024 ========================= Slide 10.7: Wednesday, November 06, 2024 ============================ Slide 10.6: Binary searching 1 3 5 6 8 9 10 13 9 8 / 2 = 4 => 6 4 / 2 + 4 = 6 => 9 Slide 10.4: Queue: Enter 2 => 2 Enter 3 => 2 3 Enter 4 => 2 3 4 Withdraw => 2 | 3 4 Withdraw => 3 | 4 Stack: |___| push A |_A_| push B | B | |_A_| push C | C | | B | |_A_| pop => C | B | |_A_| pop => B |_A_| Matrices/grids $a[0][0] = 1; $a[0][1] = 2; $a[0][2] = 3; $a[1][0] = 4; $a[1][1] = 5; $a[1][2] = 6; $a[2][0] = 7; $a[2][1] = 8; $a[3][2] = 9; Monday, November 04, 2024 =========================== Slide 10.3 ---------- Linked list: 'T' -> 'h' -> 'i' -> 's' -> ' ' -> 'i' -> 's' -> ... String: $s = "This is a test." Array: $a[0] = 1; $a[1] = 2; $a[2] = 3; $a[3] = 4; $a[4] = 5; Monday, October 28, 2024 ======================== Slide 9.3 --------- f x = if x / 2 > x then g (2 * x) else 42 g x = if x % 1 == 0 then f (g (x + 1)) else h (x - 1) h x = if x % 1 == 1 then f (x * 2 + 1) else g (x + 1) f(10) => 42 f(-10) => if -5 > -10 then g(-20) g(-20) = if -20 % 1 Slide 9.1 --------- Microcode: add sub mul 2 x 3 = 6 = 2 + 2 + 2 3 x 5 = 15 = 3 + 3 + 3 + 3 + 3 0000 = 0 0001 = 1 0010 = 2 0011 = 3 0100 = 4 = 3 + 1 = 0011 + 1 = 0100 0101 = 5 0110 = 6 0111 = 7 1000 = 8 1001 = 9 1010 = 10 = A 1011 = 11 = B 1100 = 12 = C 1101 = 13 = D 1110 = 14 = E 1111 = 15 = F + 1 = 1 ----------- 10000 = 16 = 10 = 1 x 16 9 + 1 ------ 10 32 => 1010 1110 1011 0100 1010 1101 1110 1100 ---- ---- ---- ---- ---- ---- ---- ---- A E B 4 A D E C