forked from guifre/notes
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprogramming.txt
34 lines (28 loc) · 1.44 KB
/
programming.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Concepts
**Type erasure** is the process in which the compiler replaces the generic types with their bound or object.
**Plain old java object (POJO)** is a simple java object that does not require any fancy library in classpath other than the JVM to be instantiated.
SOLID
Single responsibility principle
A class should have only a single responsibility (i.e. changes to only one part of the software's specification should be able to affect the specification of the class).
Open/closed principle
Software entities should be open for extension, but closed for modification.
Liskov substitution principle
Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
Interface segregation principle
Many client-specific interfaces are better than one general-purpose interface.
Dependency inversion principle
One should depend upon abstractions, concretions.
Given a balanced BST
* 4
2 5
1 3*
Depth First Traversals
Inorder (Left, Root, Right) : 1 2 3 4 5
Preorder (Root, Left, Right) : 4 2 1 5 3
Postorder (Left, Right, Root) : 1 3 2 5 4
Breadth First 4 2 5 1 3
Sorting algorithms
Bubble sort. Time O(N^2) Space O(1)
Selection sort. Time O(N^2) Space O(1)
Merge sort. Time O(N log(N) Space O(1)
Quick sort. Time average O(N log(N). Worst case O(N^2). Space O(log(N)).