CS 111 – Nov. 5 Sorting –Selection and Bubble √ –insertion: place next element in correct place by shifting over other ones to make space –Merge: Repeatedly split list in half until 1-2 elements each. Then merge adjacent lists by collating them. Computer languages 3 kinds of software errors Commitment –For next week, please read sections 6.2 (review); 9.1, 9.2
Language evolution Machine language Assembly language –Like machine language, also unique to each manufacturer High-level language –FORTRAN, COBOL –Pascal, Algol, Ada –C, C++, C# –Java, Javascript, Python –many more
Example How would we calculate: … ? Let’s create our own solution, and see what the “code” looks like in different types of languages: –Machine language –Assembly language –High-level language
Machine language : :200c : :3c0a c:354a :8d4a :018a :1d c:018c : :010b :218c c: : a : c help me!
Assembly language numValue:.word 20 __start: addi $12, $0, 1 addi $8, $0, 0 lui $10, 0 ori $10, $10, 0x3000 lw $10, 0($10) while: sub $9, $12, $10 bgtz $3, end mult $12, $12 mflo $11 add $8, $8, $11 addi $12, $12, 1 j while end: addi $8, $0, 10 syscall
HLL (Pascal) var sum : integer; count : integer; begin sum := 0; for count := 1 to 20 do sum := sum + count * count; writeln(sum); end.
Bugs Any mistake made in a computer program Term ‘bug’ coined by Grace Hopper, ca kinds of bugs –Syntax errors –Run-time errors –Logical errors Beyond bugs, program can be just slow! –Ex. Ineffective ways of finding the divisors of some number.