These notes helped me alot in my final exam for ICS3M.Computers Exam NotesTermsDeclaring a variable -setting aside some memory that will be used to store a valueIndentifier -The name of the variableConstants -Declared using: var name-of-constant : type-of-constant :=value. Constants are variables that you want to stay the same through the entire program, they are useful if it's a variable that you may wish to changeVariables -Must begin with a letterCan use digits or underscoresCan't use special characters like hyphens or spacesAre case sensitiveAssignment-Occurs when a variable is assigned a specific value (initialized)Condition/Comparison -Is used when comparing a value/variable to anot ...view middle of the document...
Eg. drawfillOval(200,300,100,50,blue)File I/OWhen a text file is read in and used in turingFile input -Open: filenum,filename, putFile OutputOpen: filenum, filename, getArraysArray -An array is a variable that holds an entire list of informationSelection Sort-The selection sort works by using 2 arrays: an unsorted list and a sorted list. The sorted list is empty to start. The sort works by selecting the smallest item from the unsorted list, copying it into the next empty spot in the sorted list, and then changing the element that was just copied to a very large # (larger than all the # that you are working with)Unsorted ListSorted listsmallestlocation9,3,7,2,10-- -- -- -- -- 249,3,7,999,102 -- -- -- -- 32Insertion SortThe insertion sort uses 2 arrays (just like the selection) but, instead of searching for the smallest in the original list, we simply begin with the first element in the unsorted list, and do the work of sorting when we insert into the new-sorted list. When we insert the sorted list, we maintain sorted order.IndexUnsortedLocation in insertSorted19,3,7,2,1019 - - - - -29,3,7,2,1013,9 - - -39,3,7,2,1023,7,9 - -49,3,7,2,1012,3,7,9 -59,3,7,2,1052,3,7,9,10Bubble SortThe bubble sort only uses 1 array. It works by comparing 2 elements at a time. If the 2 elements are incorrect order, it swaps them. This continues until the largest element is "bubbled" to the end and this whole process is repeated until the entire list is sorted.IndexSwap?List1no swapE M N A P Z O B D C2no swapE M N A P Z O B D C3swapE M A N P Z O B D C4no swapE M A N P Z O B D C5no swapE M A N P Z O B D C6swapE M A N P O Z B D C7swapE M A N P O B Z D C8swapE M A N P O B D Z C9swapE M A N P O B D C DDisplaying a loopFor i 1..30 listPut list(i)End forAssignment Statement vs Conditions• To assign a value to a variable, we use assignment statements Ex. var age: intage := 16After variables have been assigned values, we may want to compare those values using a comparison statement also called a conditionA condition/comparison will be true or false BOOLEAN= equalnot= not equal< less than= greater then or equal toMike is way gayer then Anders x10Complex Comparisons• we can connect comparison statement with the words and, orEx. var age: int := 16 Var myage : int :=15Put age >=16 and myage = 15 ~TRUE Put age >=16 and age = 17 ~FALSE Put age >=16 or age = 17 ~TRUEStrina ComparisonsString can also be compared in TuringTuring does this by translating the strings into numbers by using ASCII codeIf StatementsIf statements are used when making a decision in a computer programThey use comparisons/conditions and evaluate those comparisons/conditions to one of two possible values: TRUE or FALSEAn if statement follows the balls structure below:If condition then(in this space code is written which will run only if condition = true) elsif condition2 then(in this space code is written that will run only if conditon2 = false) else(in this space code is written that will...