Algorithms Flashcards

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

Recursion

A

when a function calls itself
features:
- subroutine must have a base case
- subroutine must call itself for any inputs other than base case
- subroutine must halt after a finite number of calls

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

Stack overflow

A

when the call stack pointer exceeds the stack bound - occurs when a recursive algorithm has used up all of the available memory

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

Big-O notation

A

measure of the time complexity of an algorithm

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

Permutation

A

collection of objects from a set where the order of the chosen objects matter

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

O(1) constant time

A

takes constant time to execute regardless of size of input data set

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

O(n) linear time

A

an algorithm whose performance grows in linear time

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

O(n^2) quadratic time

A

algorithm’s performance ∝ square of the size of data set

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

O(2^n) exponential time

A

time taken to execute algorithm doubles with every additional item added to data set

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

O (log n) logarithmic time

A

time taken to execute algorithm will grow very slowly as size of data set increases

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

O(n!) factorial time

A

execution time of algorithm will grow more quickly than O(2^n) (worst possible time complexity)

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

Linear search

A

involves starting from the beginning of a list and checks one item at a time to see if it is the right one
Time complexity: O(n)

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

Bubble sort

A

works by repeatedly going through a list of items, compares consecutive pairs of items and swaps the items if they are in the wrong order
Time complexity: O(n^2)

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

Binary search

A

starts at the middle of a sorted set of numbers and removes half of the data - process repeated until desired value is found or all elements have been eliminated
Time complexity: O(log n)

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

Binary tree search

A

technique for searching a binary tree that traverses the tree until the search term is found
Time complexity: O(n)

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

Merge sort

A

list is divided into the smallest unit, then each element is compared with the adjacent list to sort and merges the two adjacent lists; done until all elements are sorted and merged
Time complexity: O(nlog n)

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

Breadth-first traversal

A

explore all the neighbours of the current vertex, then the neighbours of those vertices and etc.
Time complexity: O(n^2)

17
Q

Brute force method

A

finding a solution by checking every possible option

18
Q

Tractable problem

A

problem defined as tractable if an existing algorithm to solve it can be executed in polynomial time or less

19
Q

Intractable problem

A

problems that have no efficient solution to solve them - grow exponentially or worse

20
Q

Heuristic method

A

return solutions that are not entirely accurate, optimal, or complete, but are fit for purpose and achievable in a reasonable time frame

21
Q

The Halting problem

A

when there are no algorithmic solutions for a problem/determines if a program will halt without running it

22
Q

Depth-first traversal

A

go as far down as you can before backtracking and going down the next path
Time complexity: O(n)