Mind map
Computer science unit 2
Map content
Computer science unit 2
ALGORITHMS
- Searchs
- Linear
- searches each item in list, compare w/ target until it matches/finished searching list
- does not need to be sorted, simple to understand
- inefficient on long lists, takes too long
- Binary
- needs to be sorted
- efficient on large lists
- very fast
- cancels half of list by finding midpoint
- very fast
- finds midpoint of list
- compares with search target
- if search target > midpoint - looks at upper bound
- continues until found
- if search target < midpoint - looks at lower bound
- if search target > midpoint - looks at upper bound
- compares with search target
- Linear
- Sorts
- Merge
- halves list into two until single elements then merges back together in order
- efficient on large lists
- fastest out of all sorts
- too complicated for smaller lists
- Insertion
- go through data one by one + check if current data is bigger/smaller than the number that was before it
- slow + inefficient on large lists
- good for small lists, simple + accurate
- pass through the array once
- Bubble
- repeatedly swapping adjacent item if they are in wrong order, until they are in the correct order.
- not as efficient, takes many passes
- simple to understand + implement
- Merge
- Searchs
PROGRAMMING TECHNIQUES
- Sequence
- executed in the order they are written:
- total = mark1 + mark2 average = total / 2 print (total, average)
- Selection
- next statement to be executed depends on whether the condition being tested is true or false
- if statement
- if average >= 80 then print ("Distinction") else print ("Pass") endif
- if statement
- next statement to be executed depends on whether the condition being tested is true or false
- Iteration
- repetition
- for... next
- execute the loop a specified number of times - for counter = 1 TO 7
- while... endwhile
- execute the loop while a certain condition is true, tested at beginning
- while emailAddress does not contain “@”
- execute the loop while a certain condition is true, tested at beginning
- do... until
- execute loop until certain condition is true, tested at the end of loop
- do ... until emailAddress contains “@”
- not in python, used for pseudocode
- do ... until emailAddress contains “@”
- execute loop until certain condition is true, tested at the end of loop
- for... next
- repetition
- Sequence
TRANSLATORS/COMPILERS
- 1st generation
- machine code
- Directly Executable by the processor, computer understands
- hard to debug, hard to understand, difficult to program in
- 0001 - input 1100 - store 0010 - output
- no translator needed
- machine code
- 2nd generation
- assembly code uses mnemonics
- easier to program in compared with 1st generation but still difficult
- slower than 1st generation- needs to be translated
- One Assembly Language instruction translates to one Machine Code Instruction (1-1 relationship)
- uses assembler to translate
- used to program Device Drivers
- control the operation of a Hardware Device, GCD
- 3rd generation
- uses compiler to translate: translates in 1 go + displays error message afterwards
- harder to debug, hardware specific - suited to certain computer
- uses interpreter to translate: translates as program running (line by line) + if error found interpreting stopped; if not continue
- longer to run, slower
- easier to understand (uses English like key words) easier to debug
- One instruction translates into many machine code instructions
- uses compiler to translate: translates in 1 go + displays error message afterwards
- 1st generation
ARRAYS/LISTS
- data structure that is fixed in size, capable of storing data, accessed by an index
- use 0 based counting (starts at zero)
- sorce = [ ]
- declaration
- memory set aside for contents, giving name to memory space
- x
- memory set aside for contents, giving name to memory space
- declaration
- score[0] = 3
- 3 is value to be stored at index
- assingment
- putting data into memory location
- x = 6
- putting data into memory location
- assingment
- 0 is position in list
- 3 is value to be stored at index
- score = [1,2,3,4,5]
- scores[0] = 4
- score = [4,2,3,4,5]
- changed value stored at position 0
- scores[0] = 4
- data structure that is fixed in size, capable of storing data, accessed by an index
SUBROUTINES
- code broken up into manageable segments
- set of program instructions that do specific task
- call
- execute subroutine
- Menu ()
- instruction that starts subroutine
- execute subroutine
- parameters
- info about data being passed to a function in brackets
- def FirstTask (textToDisplay, num) :
- num + textToDisplay = paramters
- def FirstTask (textToDisplay, num) :
- arguments
- value passed to parameter
- meal = input("Enter meal") price(meal)
- sending response to subroutine
- meal = input("Enter meal") price(meal)
- value passed to parameter
- info about data being passed to a function in brackets
- function
- section of code, performs specific task, returns value
- algorithm to calculate VAT
- section of code, performs specific task, returns value
- procedure
- does not return value
- algorithm for making a square
- code broken up into manageable segments
Information
- Description
- Includes : Searchs and sorts Programming techniques (sequence, iteration, selection, arrays/lists + subroutines) Translators/compilers (1st generation, 2nd generation ...)
- Created by
- Somto Ibeme
- Views
- 180
- Tags
- Rating