1. Basics Flashcards
State 3 rules for Flowcharts
- Use Rectangles for states, steps and instructions
- Use Rhombus for decisions
- Mark the start and the end of the chart
What is PseudoCode?
Human friendly code that cannot be understood by machines
What is a Model?
A set of concepts to represent a problem and its characteristics
A –> B / A
If the water is cold –> I wont swim / !A –> !B
Explain the logic XOR (Exclusive OR)
XOR expresses ideas are of opposing truths
one of the two must be true for XOR to be true. If both true, or both false, then XOR returns false
AND / OR Associativity rule
Parentheses are irrelevant for the sequence of AND/OR operations:
A && (B && C) = (A && B) && C
A || (B || C) = (A || B) ||C
AND / OR Distributivity rule
Factoring multiplicative terms from sums:
a x (b+c) = axb + axc;
A && (B || C) = A&&B || A&&C
A||(B&&C) = A||B && A||C
AND / OR DeMorgan’s Law
!(A&&B) = !A || !B !(A||B) = !A && !B
Sumer and Winter cannot be at the same time, so it is either not Summer, or not Winter.
It is not Summer and not Winter when it is not either Summer or Winter
If an event happens in M different ways, and another event happens in N different ways. What is the number of ways both events can happen?
M x N
A PIN code is composed of two digits and a letter. It takes one second to try a PIN. In the worst case, how much time do we need to crack a PIN?
Two digits can be chosen in 100 ways (00-99) and a letter in 26 ways (A-Z). Therefore, there are 100 × 26 = 2, 600 possible PINs. In the worst case, we have to try every single PIN until we find the right one. After 2,600 seconds (43 minutes), we’ll have cracked it.
There are 23 candidates who want to join your team. For each candidate, you toss a coin and only hire if it shows heads. How many team configurations are possible?
Before hiring, the only possible team configuration is you alone. Each coin toss then doubles the number of possible configurations. This has to be done 23 times, so we compute 2 to the power 23:
How many ways are there to order N items?
N!
Are Permutations ordered? what does it mean?
Yes. It means if we are choosing Richard, Polly, and Nico out of 30 people, the order in we choose will determine their classes. So RPN will have different outcome than PNR.
How to calculate a combination which is ordered, have n options, happens r times and allows for repetition?
An ordered combination is Permutation. If it allows for repetition it makes each arrangement of r independent of the other, so N x R ==> N^R
How to calculate an ordered Combination, which does not allow for repetition, where r items need to be chosen out of n?
An ordered combination is Permutation.
N! / (N-R)!