computing

Cards (238)

  • Algorithm
    A set of instructions to do something
  • Bubble sort

    • Looks through each pair to sort them out, can be slow
  • Merge sort

    • Splits the group, merges it back together after sorting
  • Insertion sort
    • Inserts each number into correct position
  • Binary search
    1. Write 1 on "low"
    2. Write 100 on "high"
    3. Repeat: pick a number about halfway between "low" and "high"
    4. Write this number on "middle"
    5. Ask "secret" if "middle" number is right
    6. If too low, change "low" to what "middle" is
    7. If too high, change "high" to what "middle" is
    8. Until "secret" says it's right
  • Find the largest number
    1. Length of all the integers in the list
    2. Bubble sort
    3. 1 pass
    4. Print .(index position 'length-1')
  • Find the largest number
    1. Have a variable called large
    2. The first number in the list is put into large
    3. Large is compared with the next value
    4. If next value > large, replace large
    5. Repeat until you can't and find the largest number
  • Average of numbers
    1. Sum = 0
    2. Count = 0
    3. Repeat:
    4. Num = input (user inputs number)
    5. Count = Count + 1
    6. Sum = sum+num
    7. Print: sum/length of numbers
  • Find sum of 10 numbers
    1. Sum = 0
    2. Repeat 10 times:
    3. Ask the user to input a number
    4. Sum = sum+num
    5. Print (sum)
  • C#

    Case sensitive programming language
  • C# Pseudocode
    1. PRINT "what is you name"
    2. INPUT name
    3. PRINT "welcome to C#" name
  • C# Code
    1. Console.WriteLine "what is your name"
    2. String name = Console.ReadLine
    3. "Welcome to C#" + name
    4. Remember to put ; at the end of each line
    5. To tell user to enter something: Console.ReadLine
    6. Have to specify its data type eg int not string
    7. Use a plus sign to join things together ie "Welcome to c#" + name
    8. For numbers use int not string
    9. Int is integer and is needed because that's the type of data needed. Input is by default a string in python and in c sharp so you need int to convert it into the type of data it needs to be. Called typecasting.
    10. So when you need to do a number thing you have to do Convert.ToInt32
    11. ToDouble for decimals
  • Programming constructs
    • Sequence: order of execution
    • Selection: choosing things based on conditions (which is true, which block of code should be executed(if statements))
    • If _ then _ else
    • Nested if: one if statement inside another if statement
  • AND statement

    Both conditions have to be true at the same time
  • OR statement

    Either condition is true for the condition to be true
  • Nested if example
    1. If age < 18
    2. Then print ("you are at school")
    3. Else if age<60
    4. Then print ("you can work")
    5. Else print ("you can retire")
  • Switch case
    • Switch choice is like if statement, used instead of one
    • Benefits: less time to process
    • User doesn't input- they choose a choice
  • Binary numbers
    Only two digits: 0 and 1
  • Decimal numbers
    0-9 digits
  • Why computers use binary
    • They cannot understand the decimal system
    • 0 and 1 can represent true and false
    • Easier to represent two numbers electronically
    • Transistors and capacitors only have two states (form of 0s and 1s)
    • Only two voltages ie high and low- if decimal system was used they'd need ten
  • Decimal system
    Runs in powers of ten (10 to power of 0, 10 to power of 1 etc)
  • Binary system
    Runs in powers of two (2 to power of 1, 2 to power of 2 etc)
  • Hexadecimal
    Sixteen numbers, runs in powers of sixteen
  • Converting binary to decimal
    1. Multiply each bit by one or zero
    2. Eg converting 1101 is 8x1 + 4x1 + 2x0 + 1x1 = 13
  • Bit, byte etc

    Measures storage in a computer
  • Max number in n bits

    2 to the power of n - 1
  • Binary addition
    1. 0 + 0 = 0
    2. 0 + 1 = 1
    3. 1 + 1 = 0 (carry one)
    4. 1 + 1 + 1 = 1 (carry one)
  • Shift operations
    • Used for multiplication and division
    • New spaces are filled with 0s
    • Shift to left multiplies by 2 every bit it is moved
    • Shift to right divides by 2 every bit it is moved
  • Hexadecimal
    • Uses base of 16
    • 0-9 and A to F to represent numbers
  • Converting binary to hexadecimal
    1. Put binary numbers into groups of 4
    2. Each hexadecimal digit represents 4 binary digits
  • Machine code
    Language that computers understand (not binary)
  • Character set
    Collection of characters used to represent text in a computer system
  • ASCII

    Every letter in the alphabet is given a number
  • Unicode
    Supports all languages
  • Pros and cons of ASCII
    • Pros: short length (7 bits per character)
    • Cons: doesn't represent enough
  • Pros and cons of Unicode
    • Pros: more characters
    • Cons: lots of storage space used
  • Bitmap
    Map that converts an image into bits/ a digital image which is divided into a grid of picture elements called pixels
  • Bitmap graphic
    • Digital image which is divided into a grid of picture elements called pixels
    • Each pixel on an image has a different colour because they are all addressable and use different shades etc
  • Colour depth
    The number of bits used to represent a colour value of a single pixel in the image
  • Image resolution
    Expressed as the number of pixels per inch