KMS (algo ver.)

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/69

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

70 Terms

1
New cards

for solving problems with overlapping subproblems; solve each smaller subproblem once and record results in a table to derive the overall solution

Dynamic Programming

2
New cards

Time complexity of Dijkstra’s Algo (adjacency matrix + array)

O(V²)

3
New cards

Time complexity of Dijkstra’s Algo (adjacency list + min heap)

O(ElogV)

4
New cards

Apply to optimization problems for difficult combinatorial problems such as Knapsack Problem (Best first rule)

branch and bound

5
New cards

Apply to nonoptimization problems such as N queens, Knight’s tour, and Hamiltonian circuit (DFS)

Backtracking

6
New cards

Upper bound formula for Knapsack Problem

ub = (tot value so far) + (rem cap)(next best ratio)

7
New cards

Knapsack problem worst case time complexity

O(2^n)

8
New cards

Tractable

solvable in polynomial time

9
New cards

Intractable

Not solvable in polynomial time

10
New cards

P

Class P, decision problems solvable in polynomial time

11
New cards

Undecidable

Decision problem that cannot be solved by any algorithm

12
New cards

NP

Non deterministic polynomial class of decision problems solvable by non deterministic polynomial algorithms:
1) Generate candidate solution
2) Verify solution’s validity in polynomial time

13
New cards

NP complete

Set of problems in NP reducible to any other NP problem in polynomial time. Examples such as TSP, Knapsack, SAT.
(if one problem can be solved in P time, all other NP complete problems can also be solved in P time)

14
New cards

NP Hard

Every NP problem can be reduced to it in polynomial time but not vice versa. May be undecidable like the Halting Problem

15
New cards

Sequence of unambiguous instructions for solving a problem in a finite amount of time

Algorithm

16
New cards

Euclid’s GCD

gcd(m,n) = gcd(n,mmodn)

17
New cards

Why do we measure growth

to understand how performance scales with input size

18
New cards

Stable

Preserves the relative order of elements

19
New cards

In place

Does not require extra memory to sort

20
New cards

Bubble sort Worst case, stable or not?, in place or not?

O(n²), stable, in place

21
New cards

Selection sort Worst case, stable or not?, in place or not?

O(n²), in place

22
New cards

counting sort Worst case, stable or not?, in place or not?

O(n+k), stable

23
New cards

Insertion sort Worst case, stable or not?, in place or not?

O(n²), stable, in place

24
New cards

Sequential search worst case

O(n)

25
New cards

Binary Search worst case

O(logn)

26
New cards

Find the shortest tour through n cities that visits each city exactly once with the least cost via exhaustive search; generate the Hamiltonian circuit

Traveling Salesman Problem

27
New cards

Traveling Salesman Problem worst case

O((n-1)!) = (n!)

28
New cards

Traveling Salesman Problem worst case (undirected)

O([(n-1)/2]!) = (n!)

29
New cards

Search where examine each element linearly until key is found

Sequential search

30
New cards

Repeatedly halves the search space until key is found

Binary search

31
New cards

sorts integers by counting the number of occurrences of each distinct value in the input

Counting sort

32
New cards

Iterates through unsorted elements and and inserts them into sorted portion

Insertion sort

33
New cards

Lower or same order of growth

O notation

34
New cards

Same or higher order of growth

Omega notation

35
New cards

bounded above and below; exact order of growth

Theta Notation

36
New cards

Given n points on a plane, find the closest pair exhaustively by considering every pair of points (Give worst case time complexity)

Closest pair problem O(2^n)

37
New cards

Exhaustive traversal of a graph. Visits adjacent vertices until no adjacent unvisited vertices (dead end). Uses a stack to trace operation. Checks connectivity and acyclicity. Tree and back edges.

Depth first search

38
New cards

Visits all vertices adjacent, then all unvisited 2 edges apart, until all visited. Uses a queue to trace operation (enqueue when discovered as neighbor, deque when visited). Checks connectivity and acyclicity. Cross edges. Checks for minimum edge path (path with the least edge count).

Breadth first search

39
New cards

Top down approach

Recursive

40
New cards

Bottom up approach

iterative

41
New cards

Decrease and conquer: reduced by the same constant with O(n) complexity

Decrease by a constant

42
New cards

Decrease and conquer (recursion): reduced by a constant factor (division) with O(logn) complexity

decrease by a constant factor

43
New cards

Problem divides into subproblems, sorted, then combined to get solution
T(n) = aT(n/b) + f(n)

Divide and Conquer

44
New cards

Mergesort worst case, in place?, stable?

O(nlogn), stable

45
New cards

Depth first search and BFS complexity

O(n²)

46
New cards

Quicksort worst case, stable?, in place?

O(n²), inplace

47
New cards

Divides an array according to their partition (using first element Hoare’s partition).

Algo:
From left to right, stop when element is >= p, from right to left, stop when element is <= p. Swap elements if i and j have not crossed

If i and j have crossed, partition is complete where j is split partition position

Quicksort

48
New cards

Preorder traversal

root-left-right

49
New cards

inorder traversal

left-root-right

50
New cards

Postorder traversal

left-right-root

51
New cards

Technique where problem instance is modified to be more amenable to the solution and problem instance is solved

Transform and conquer

52
New cards

Transformation to a simpler or more convenient instance of the same problem

Instance simplification

53
New cards

Transformation to a different representation of the same instance

Representation change

54
New cards

Transformation to an instance of a different problem for which an algorithm is already available

Problem reduction

55
New cards

A binary tree with keys assigned to its nodes provided that it is complete (filled to the last level as far left as possible w/o gaps) and there is parental dominance

Heap

56
New cards

Max heap

Largest key at root

57
New cards

Preprocess the problem’s input and store information obtained to accelerate solving

Input enhancement

58
New cards

Some processing is done before solving but deals with access structuring (for faster accessing)

Prestructuring

59
New cards

Technique for resolving collisions using linked lists in a hash table

Open hashing

60
New cards

Technique for resolving collisions using linear probing in a hash table

Closed hashing

61
New cards

A greedy grab of the best alternative available in the hopes that a sequence of locally optimal choices will lead to a globally optimal solution to the entire problem. Each step where a choice is made, must be feasible, irrevocable, and locally optimal

Greedy technique

62
New cards

A subset of edges in a weighted, connected, and undirected graph that connects all vertices without cycles while minimizing the total weight of the edges

Minimum spanning tree

63
New cards

Constructs a mst through a sequence of expanding subtrees by attaching to the nearest vertex not already in the tree but connected to any vertex in the tree

Prim’s algorithm for vertices

64
New cards

Constructs an mst as an expanding sequence of subgraphs that are always acyclic but not necessarily connected during construction

Kruskall’s algorithm for edges

65
New cards

Heap time complexity

O(logn)

66
New cards

Construct a heap for an array and apply root deletion operation n-1 times

Heapsort

67
New cards

Place keys in tree in given array order and heapify

Bottom up heap construction

68
New cards

Attach key to the last leaf of existing heap and sift upward to its place

Top down heap construction

69
New cards

Where parental node keys are stored in first floor(n/2) positions and leaf keys are stored at last ceil(n/2) positions, and parents position i corresponds to children's position 2i and 2i+1. 0th element is unused or a sentinel value greater than every element in the heap

Using an array to store the heap

70
New cards

Heapsort with an increasing sorted array Time complexity, array is inplace?, stable?

O(nlogn), inplace