Search
Create
Log in
Sign up
Log in
Sign up
CS Set 1
STUDY
Flashcards
Learn
Write
Spell
Test
PLAY
Match
Gravity
Terms in this set (11)
Adjacency List
-Array of linked lists
-Can also store weighted edges
-Space = O(|V| + |E|) -- max O(V^2)
-Add edge in constant time (to front of list)
-O(V) to query edge (or get adjacent edge)
Adjacency Matrix
-2D Array
-if adj[i][j] == 1, edge from i to j (can be weighted = w)
-Query, addition, and removal at O(1) for edges
-Has to be symmetric
-O(V^2) space
-Adding vertex = O(V^2) -- resize and copy
Graph as Objects and References
-Space: Average = O(V + E) --- Worst = O(V^2) space
-O(n) access time
-need a way to keep track of all nodes (array of V pointers)
ELO Scoring
-Win -> Rating = Old + 10 x [1 - 1 / (1 + 10 ^ (yours - opps)/400))]
-Lose -> Rating = Old - 10 x [1 - 1 / (1 + 19 ^ (opps - yours)/400))]
*10 = constant... I used the one for HoN with a starting ELO of 1500
Is It Prime?
if(x < 2) false;
for(int i = 2; i < Math.sqrt(x); i++)
{
if (x % i == 0)
return false;
}
return true;
List of Primes (Sieve of Eratosthenes)
-boolean[] = new Boolean[max + 1]
-set all flags to true except 1 and 0
-while(prime <= math.sqrt(max)), prime starts @ 2
--Cross of all prime*prime + prime multiples
--Next prime = increment until next true flag
Probability of A & B
P(A & B) = P(B given A) * P(A)
Probability of A or B
P(A or B) = P(A) + P(B) - P(A & B)
Probability of Independent Events
-P(A & B) = P(A) * P(B)
Probability of Mutual Exclusion
*If one event happens, then the other cannot happen
-P(A or B) = P(A) + P(B)
Math # of Permutations of a String
total letters!
-----------------------------------
(# A's)! x (# B's)! x .... (#Z's)!
YOU MIGHT ALSO LIKE...
Differential Equations and Linear Algebra
60 Terms
MaxwellMcGee85
Chapter 9: Linear Data Structures
27 Terms
srppr42
Java 2 FINAL EXAM
100 Terms
shanil_jasani2018
Medical coding and billing chapter 6 icd-10-cm coding
51 Terms
JUDEAILAWTON
OTHER SETS BY THIS CREATOR
CS Set 5
20 Terms
mrhappyasthma
CS Set 4
30 Terms
mrhappyasthma
CS Set 3 - Powers of 2
8 Terms
mrhappyasthma
CS Set 2
10 Terms
mrhappyasthma
THIS SET IS OFTEN IN FOLDERS WITH...
Swahili Numbers
21 Terms
kasahorow
Swahili Chapter 1
44 Terms
mrhappyasthma
Swahili verbs
46 Terms
BY-star
Swahili words
366 Terms
SpenWise
;