P2 theory Flashcards

1
Q

computational thinking

A

decomposition - breaking down a complex problem into lots of smaller ones

abstraction - simplifying a problem by picking out important bits of information

Algorithmic thinking - coming up with a series of logical steps to get from a problem to a solution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

search algorithms

A

Binary search:

Pros:
- efficient at searching large lists
Cons:
- list must be ordered first

Linear Search:

Pros:
- simple
- works on unordered lists
Cons:
- inefficient at searching large lists

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

sorting algorithms

A

Bubble and Insertion sorting:

Pros:
- simple and easy to implement
- quick to check if a list is already sorted
- doesn’t need much memory, sorting only uses original list
Cons:
- inefficient on large lists

Merge sort:

Pros:
- efficient on large lists
- running time affected by order of items in original list
Cons:
- slower on small lists
- goes through whole process even if list is already sorted
- uses more memory in order to create sub-lists

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

subprograms

A

subprogram - a set of instructions stored under one name that are executed when called. They help to improve code structure, improve reliability and avoid repeating code.

Procedures - a subprogram that doesn’t return a value
Functions - a subprogram that does return a value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

maintainability

A

Ways to improve maintainability:
1) comments - write comments to explain what the code does
2) indentation - use indentation to make program flow easier to see
3) descriptive names - use descriptive names for variables, subprograms and parameters so its easier to keep track of them
4) subprograms - use subprograms to separate parts of the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

defensive design

A

Input Validation:

input validation - checking if data meets certain criteria before passing it into the program

programs normally use a variety of validation checks including:
1) range check - checks the datas in a specified range
2) presence check - checks the datas actually been entered
3) format check - checks the data has the correct format

Authentication:

authentication - confirming the identity of a user before allowing access. Passwords or biometrics are usually associated with a username.

Four ways to make passwords more secure:
1) force strong passwords
2) limit the number of failed authentication attemps
3) require passwords that are change regularly

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

errors

A

Syntax errors - when the rules of grammar of the programming language have been broken

Logic errors - when a program is able to run, but does something unexpected

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

testing

A

Iterative testing - testing a program whilst its being developed:
- individual modules can be tested and errors fixed
- process is repeated until modules work correctly
- fixing small errors early prevents large errors later on

Final testing - testing a program at the end of development:
- the whole program is tested at the same time
- check for errors where modules interact with eachother

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Languages

A

High level languages:

  • the majority of code is written in high level languages e.g. python
  • one instruction represents many instructions of machine code
  • code is easy to read and write
  • must be translated or interpreted before executed
  • slower and less memory efficient

Low Level Languages:

  • machine code and assembly languages
  • one instruction of assembly code can represent one of machine code
  • code is hard to read and write
  • code usually only works for one machine or processor
  • need to know the internal structure of CPU and how it managaes memory
  • machine code can be executed directly, without being translated
  • faster and more memory efficient
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Translators

A

Compiler:
- translates all code at once into machine code, creating an executable file
- only needed for initial translation
- returns a list of errors for whole program when compiling is complete
- compiling can take a long time, but program runs quickly once compiled

Interpreter:
- translates and runs one instruction at a time using its own machine code subroutines
- used everytime code is run
- stops and returns first error found
- programs run more slowly

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

IDEs

A

Integrated Development Environment - software to help develop programs

1) code editor - where code is written. can often automatically colour, indent, correct and complete code
2) run time environment - allows code to be run and tested within the IDE
3) error diagnostics - debugging toool to show information about detected errors
4) break points - pasues the program at certain lines. values can be checked to help diagnose logic errors
5) translator - a compiler or interpreter to allow source code to be executed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly