Dev1 Flashcards

1
Q

What does the ‘L’ in S.O.L.I.D. stand for?

A
Liskov Substitution Principle: 
The principle defines that objects of a superclass shall be replaceable with objects of its subclasses without breaking the application. That requires the objects of your subclasses to behave in the same way as the objects of your superclass. 
An overridden method of a subclass needs to accept the same input parameter values as the method of the superclass. That means you can implement less restrictive validation rules, but you are not allowed to enforce stricter ones in your subclass.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the ‘I’ in S.O.L.I.D. stand for?

A

Interface Segregation Principle:

“Clients should not be forced to depend upon interfaces that they do not use.”

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

What does the ‘D’ in S.O.L.I.D. stand for?

A

Dependency Inversion:
he general idea of this principle is as simple as it is important: High-level modules, which provide complex logic, should be easily reusable and unaffected by changes in low-level modules, which provide utility features. To achieve that, you need to introduce an abstraction that decouples the high-level and low-level modules from each other.

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

What is the maximum size of a 16-bit integer (short)

A

A 16-bit integer can store 216 (or 65,536) distinct values. In an unsigned representation, these values are the integers between 0 and 65,535; using two’s complement, possible values range from −32,768 to 32,767. Hence, a processor with 16-bit memory addresses can directly access 64 KB of byte-addressable memory.

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

What is a Long?

A

A Long is a 64-bit Integer.

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

What is a Float?

A

A Float is a 32-bit floating point number

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

What is a Double?

A

A Double is a 64-bit floating point number

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

What is Constant Time?

A

An algorithm is said to be constant time (also written as O(1) time) if the value of T(n) is bounded by a value that does not depend on the size of the input. For example, accessing any single element in an array takes constant time as only one operation has to be performed to locate it.

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

What is Logarithmic Time?

A

An algorithm is said to take logarithmic time when T(n) = O(log n). Since loga n and logb n are related by a constant multiplier, and such a multiplier is irrelevant to big-O classification, the standard usage for logarithmic-time algorithms is O(log n) regardless of the base of the logarithm appearing in the expression of T.

Algorithms taking logarithmic time are commonly found in operations on binary trees or when using binary search.

An O(log n) algorithm is considered highly efficient, as the ratio of the number of operations to the size of the input decreases and tends to zero when n increases. An algorithm that must access all elements of its input cannot take logarithmic time, as the time taken for reading an input of size n is of the order of n.

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

What is Linear Time?

A

An algorithm is said to take linear time, or O(n) time, if its time complexity is O(n). Informally, this means that the running time increases at most linearly with the size of the input. More precisely, this means that there is a constant c such that the running time is at most cn for every input of size n. For example, a procedure that adds up all elements of a list requires time proportional to the length of the list, if the adding time is constant, or, at least, bounded by a constant.

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

What is Polynomial Time?

A

An algorithm is said to be of polynomial time if its running time is upper bounded by a polynomial expression in the size of the input for the algorithm, i.e., T(n) = O(nk) for some positive constant k

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

What is NP?

A

NP (nondeterministic polynomial time) is the set of all decision problems (questions with a yes-or-no answer) for which the ‘yes’-answers can be verified in polynomial time (O(nk) where n is the problem size, and k is a constant) by a deterministic Turing machine. Polynomial time is sometimes used as the definition of fast or quickly.

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

What is P?

A

P is the set of all decision problems which can be solved in polynomial time by a deterministic Turing machine. Since they can be solved in polynomial time, they can also be verified in polynomial time. Therefore P is a subset of NP.

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

What is NP-Complete?

A

A problem x that is in NP (“nondeterministicpolynomial time”) is also in NP-Complete if and only if every other problem in NP can be quickly (ie. in polynomial time) transformed into x.

In other words:

x is in NP, and
Every problem in NP is reducible to x
So, what makes NP-Complete so interesting is that if any one of the NP-Complete problems was to be solved quickly, then all NP problems can be solved quickly.

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

What is NP-Hard?

A

NP-Hard are problems that are at least as hard as the hardest problems in NP. Note that NP-Complete problems are also NP-hard. However not all NP-hard problems are NP (or even a decision problem), despite having NP as a prefix. That is the NP in NP-hard does not mean non-deterministic polynomial time. Yes, this is confusing, but its usage is entrenched and unlikely to change.

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

What does the regex /^[a-z0-9_-]{3,16}$/ mean?

A

We begin by telling the parser to find the beginning of the string (^), followed by any lowercase letter (a-z), number (0-9), an underscore, or a hyphen. Next, {3,16} makes sure that are at least 3 of those characters, but no more than 16. Finally, we want the end of the string ($).

17
Q

^The end$

A

exact string match (starts and ends with The end)

18
Q

What does a regex of abc+ mean?

A

matches a string that has ab followed by one or more c

19
Q

Regex: abc?

A

matches a string that has ab followed by zero or one c

20
Q

Regex abc{2}

A

matches a string that has ab followed by 2 c

21
Q

Regex: abc{2,}

A

matches a string that has ab followed by 2 or more c

22
Q

a(bc)*

A

matches a string that has a followed by zero or more copies of the sequence bc

23
Q

\d

A

matches a single character that is a digit

24
Q

\w

A

matches a word character (alphanumeric character plus underscore)

25
Q

What does git revert do?

A

Revert is an operation that takes a specified commit and creates a new commit which inverses the specified commit.git revertcan only be run at a commit level scope and has no file level functionality