Coding and algorithms [ARCHIVED]

Cards (39)

  • Pseudocode is an informal, high-level description of an algorithm using plain English statements.
  • An algorithm is a step-by-step procedure used to solve a problem or perform a task.
  • A flowchart is a graphical representation of the steps involved in solving a problem or completing a task
  • Sorting algorithms sort unordered list of items so search algorithms can be used
  • The bubble sort algorithm compares adjacent elements in a list and swaps them if they are out of order
  • Searching algorithms find specific data within ordered lists
  • Insertion sort takes one item at a time from the input list and places it into its correct position within the sorted portion of the output list
  • Merge sort divides the list into two halves until there are no more sublists left then merges them back together (also known as divide-and-conquer method)
  • Binary search is a searching algorithm that repeatedly divides the search interval in half until the target value is found
  • Selection sort selects the smallest element from a list and moves it to the beginning of the list
  • Bubble sorts are simple algorithms that can be easily implemented, memory effiecient and an efficient way to check if a list has been sorted but is an inefficient way of sorting a list and cannot cope will with larger lists.
  • A merge sort is more effiecient and faster than a bubble sort and has a very consistant run-time but slower than other algorithms for small lists, uses more memory and will still go through the process regardless of if the list is sorted or not.
  • The main advantage of using binary search over linear search is that it reduces the number of comparisons needed by half on average per iteration which makes it much quicker especially for large datasets.
  • The main disadvantage of using binary search over linear search is that it requires the dataset to be sorted first which may take longer depending on how many elements need to be compared.
  • An insertion sort is used when the data set is already partially ordered so only needs minor adjustments to become fully ordered.
  • Arrays have fixed size so they must be declared when created and their length cannot change once set
  • An insertation sort is the simpliest algorithm so can easily be coded, is intuitive, fast at inputting more items to an already sorted list and quick at checking if the list is already sorted but doesn't cope well with larger lists.
  • Procedures are sets of instructions stored under one name
  • Functions are procedures that return values
  • Procedures and functions help avoid repeating code and gives the program more structure and readability
  • Most sub programs will use parameters and arguements
  • parameters are special variables used to pass values into a sub program
  • arguements are the actual values passed into the parameter when calling the function or procedure.
  • Trace tables give a simple way of testing that a piece of code is working correctly. They keep track of the values that certain variables take as you go through the code. Their main use is to help find logic errors.
  • An IDE is a piece of software that provides features to help a programmer develop their program
  • IDE features include
    • Syntax highlighting
    • Debugging
    • Error diagnostics
    • Run-time
    • Breakpoints
    • Outpout window
    • Line and character number
    • GUI builder
    • Translator
    • Auto-documentation
  • A compiler translates source code directly into machine language instructions which can be executed by the computer's processor. The compiled code is stored on disk until it needs to run. Compilers do not produce any intermediate form of code such as bytecode.
  • Interpreters translate one line of code at a time from high level programming languages into machine code. This means they have to read the entire file every time the program runs. Interpreters usually only work with scripting languages like Python and Ruby.
  • Compilers translate high-level code directly into machine code and create an executable file
  • Interpreters take each instruction in the code and call machine code subroutines to carry out that instruction
  • A syntax error is an error in the program due to it not following the rules of the programming language so the program cannot be run.
  • A logic error is when the program is able to be run but the output is something unexpected
  • Input validation checks:
    • Range check - checks the data is within a specified range
    • Presence check - checks the data has actually been entered
    • Format check - checks the data has the correct format
    • Look-up check - checks the data against a table of acceptable values
    • Length check - checks the data is the correct length
  • The main difference between a compiler and interpreter is that compilers convert all the source code into machine code, whereas interpreters execute instructions as soon as they are encountered during runtime.
  • Iterative testing is when the program is being tested on while it is being developed
  • Final (terminal) testing is when the program is tested at the end of the development process
  • The column of a trace table represent values or information the programmer is interested in (e.g, length of an array or output). Each row represents the value that the variables take at a particular point in the algorithm
  • Incrementing means adding one to a variable
  • Decrementing means subtracting one from a variable