click below
click below
Normal Size Small Size show me how
Computer Science OCR
2.1 2.2 and 2.3
| Term | Definition |
|---|---|
| 2.3 Time complexity | How long a program takes as the number of inputs (n) increases. It's notation is O(f(n)). The faster f(n) grows, the faster the function's duration grows. |
| 2.3 Space complexity | How much space a program takes as the number of inputs (n) increases. It's notation is O(f(n)). The faster f(n) grows, the faster the function's space requirements grows. |
| 2.3 How do you determine Time complexity of given code? | Break down the code into parts. Each line / loop is a part. Then, figure out the big O of those parts. Then, take the largest one, and that's the big time complexity of the whole program. |
| 2.3 Bubble sort | For each pair starting from the left. If the current < next: then good, Else: swap them. Repeat until last pair Then loop the whole process again, going up until 1 less pair until everything is sorted. |
| 2.3 Insertion sort | Similar to bubble sort, except when 2 elements get swapped, the small one, gets recursively checked with the previous ones, until it finds its right place. |
| 2.3 Merge sort | Start by splitting the original list in half recursively until you only have single elements. Then merge them recursively in the same groups, but now when you merge them, you arrange the elements in ascending order each time. |
| 2.3 Quick sort | Choose a pivot, and then split the list. One group smaller than the pivot. The other is the bigger than the pivot. Then repeat for all of these smaller groups, choosing a pivot for each of them, repeat until there are just lists of one. Then merge again |
| 2.2 What 3 criteria should be met to allow a computer to be used to solve a problem, | Can it be solveable with an algorithm? Can i be solved in a reasonable amount of time Do you have enough processing pwoer to sole it. |
| 2.2 Backtracking | Backtracking is going down the branches of each possible solution to a problem, once you reach the bottom a possible solution see if its valid, if yes: great! If no, go back up a branch, mark the one you were just on as bad, and go down the next path. |
| 2.2 Data mining | Data mining is a more vague thing, and it’s the idea of analysing large datasets for patterns or trends. With this data, you can then make better, more informed choices. |
| 2.2 Heuristics | A heuristics value is an estimation of how far it is from the solutions, so it ensures the algorithm roughly goes in the right direction, by elimninating values which it can estimate aren't worth processing. |
| 2.2 Visualisation | Making a diagram or similar to help understand something better. It is a simplification that boils away unnecessary detail so it’s more easy to understand in a visual format. Its a form of abstraction. |
| 2.1 Thinking absractly | Abstraction is removing unnecessary information from the problem. Representiational abstraction is simplifying a problem Abstraction by Generalisation is figuring out what type of a problem it is. Data abstraction is classes and etc. |
| 2.1 Thinking ahead | Think about how you could save time and effort in programming. What methods you could use to program, and what might already exist that you can reuse. |
| 2.1 Thinking procesdurally | Try to break down a big problem into many smaller problems. Think about how important some of these are, and what the priority of solving them is. This can help to split it between multiple people, and makes each small problem easier to solve. |
| 2.1 Thinking logically | Try to employ logic so that everything actually makes sense. Don’t just do random things until it works, actually just think (not ai bro) It makes the program run better and makes it easier to maintain. |
| 2.1 Thinking concurrently | Try to do multiple things at the same time when it fits. |
| 2.3 Trees | All nodes are connected. Undirectional No cycles |
| 2.3 Binary trees | They are tree. They have a root. They have at most 2 children per node. |
| 2.3 Root trees | They are a tree. They have a root. |
| 2.3 Graphs | Nodes that are or aren't connected. They can have weights and directions. |
| 2.3 Queues | First in, First out. You can Enqueue and Dequeue data from it |
| 2.3 Stacks | First in, Last out. You can push and pop data from it. |