Sorting Algorithms and Big O notation Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Big O notation

A

This is a special notation for classifying algorithms based on how their computational times grows as their input size grows

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

Time Complexity

A

How much time they need to solve a given problem

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

Space Complexity

A

The amount of resource e.g. memory they require

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

Factorial

A

The permutation of a set of objects simply means the number of ways you can arrange those objects

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

Function maps one set of values to another

A

Nothing more than mapping of one set of inputs onto a set of outputs, one element of the input set always relates to one element of the output

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

Key terms for Function

A
  • Domain: All the possible inputs of a function f
  • Range: Set of all outputs of f
  • Codomain: All the possible values that may be output from a function f
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Serial Array big o notation

A

Adding items to a serial array and a list is constant time complexity - O(1)

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

Linear Search

A

Linear time complexity is O(n) at worst case scenario and if directly to an element of an array O(1)

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

Sequential array

A

adding items to a sequential array is time complexity O(n)

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

Sorted array

A

uses binary search, halves the set of numbers with each selection, therefore is time complexity O(log n)

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

Stack or Queue

A

Pushing and popping from stacks or queues O(1), searching through a stack / queue is O(n)

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

Hashing

A

Hashing is 0(1) to insert and find assuming item isn’t a synonym otherwise it is O(n) to find an item in the overflow, constant time complexity is much better

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

Linked List

A

Searching in a linked list is O(n), inserting/ deleting items from a linked list is O(1)

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

Binary tree insertion

A

binary tree insertion and searching is O(log n). Traversal is O(n)

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

Bubble and Insertion sort, and quick sort

A

They use a nested loop and they use O(n^2)

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

Quick tips for exams if you see these you can assume it is the big o notation on the other side - No loop, for while loop, nested loop, halving a data set, recursive

A

No loop = O(1)
For/While loop = O(n)
Nested Loop = polynomial: O(n^number of loops)
Halving a data set = logarithmic: O(log n)
Recursive = exponential: O(2^n)