-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Substring, searching, queue, stack, linked list and bunch morw
- Loading branch information
1 parent
97b7848
commit 622cc4d
Showing
19 changed files
with
828 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
Kubernetes is developed and originated by Google, a solution for Borg | ||
|
||
K8s - for containerization | ||
- Containers are ephemeral in nature, meaning they're short lived. Dies anytime. | ||
|
||
Problems with Docker | ||
- Single Daemon or host nature | ||
- Docker fail with Auto-healing, which happens when containers restart without human interaction | ||
- Docker doesn't scale automatically or balance load(auto-scaling) | ||
- Docker-O, bridge networking | ||
- Docker doesn't provide any enterprise support | ||
For an application to be enterprise ready, it should contains: | ||
Load balancer, Firewall, API gateway, Auto healing and Auto scaling, | ||
SSH, distributed system, Circuit breaker, Messaging, Streaming | ||
|
||
That's why we need Kubernetes, it solves countless of problems presented by Docker | ||
|
||
k8s Bring aboard the following: | ||
1. Replication Controller or Replica Set | ||
2. k8s heavily depends on yaml file(manifest file) | ||
3. HPA(Horizontal Port Auto-Scaler) | ||
4. Solve the problem of auto-healing and auto-scaling | ||
5. If for some reasons your container is going down, docker will need you to manually | ||
check the container status and the developer will have to manually restart. | ||
In the case of k8s, containers immediately recreate new containers even before | ||
the container goes down. | ||
- Master, worker and slave node | ||
|
||
7. Ingress | ||
|
||
K8s Architecture | ||
The simplest thing in Docker is Container and the simplest thing in k8s is Pod | ||
- The container runtime in Docker is called Docker strim | ||
- k8s supports Cri-O containerd, Docker strim and other container runtimes | ||
- kube-proxy provides networking, IP addressing and default load balancing capability | ||
- Container Runtime is responsible for running the containers | ||
- Kubelet is responsible for the creation and maintenance of pods | ||
It is responsible for ensuring that containers are running in a pod. | ||
|
||
k8s Platform | ||
- Development environments: KPS, Minikube, Micro8Ks, K3S, KanD | ||
|
||
Linux Distribution | ||
- Red Hat, CentOS, Amazon Linux, Kali Linux, Ubuntu | ||
|
||
K8s Distribution | ||
- Amazon Elastic Kubernetes Service (EKS) | ||
- Google Kubernetes Engine (GKE) | ||
- Azure Kubernetes Service (AKS) | ||
- DigitalOcean Kubernetes | ||
- K3s , Minikube, KubeSphere, Pharos, Tanzu, Ranctier | ||
|
||
K8s Installation | ||
- Kops(kubernetes operation), kubeadm(kubernetes administration) | ||
- minikube start --memory=4096 --driver=virtualbox | ||
- minikube delete | ||
- kubectl cheat-sheet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx-pod | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:latest | ||
ports: | ||
- containerPort: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Experiment | Dataset | Preprocessing | Model Architecture | Training Duration | Test Accuracy | Precision | Recall | F1 Score | | ||
|------------|------------------|------------------------------------|-----------------------------------------|-------------------|---------------|-----------|--------|----------| | ||
| Experiment 1 | ImageNet | Resize to (224x224), Normalize | SGH-CNN (as described) | 12 hours | 0.85 | 0.86 | 0.84 | 0.85 | | ||
| Experiment 2 | CIFAR-10 | Resize to (32x32), Augmentation, Normalize | SGH-CNN with additional CNN layers | 8 hours | 0.78 | 0.79 | 0.77 | 0.78 | | ||
| Experiment 3 | MNIST | Resize to (28x28), Normalize | SGH-CNN with dropout layers | 6 hours | 0.96 | 0.97 | 0.95 | 0.96 | | ||
| Experiment 4 | Fashion MNIST | Resize to (28x28), Normalize | SGH-CNN with batch normalization | 7 hours | 0.91 | 0.92 | 0.90 | 0.91 | | ||
| Experiment 5 | Stanford Dogs | Resize to (224x224), Normalize | SGH-CNN with transfer learning (ResNet50) | 15 hours | 0.89 | 0.90 | 0.88 | 0.89 | | ||
| Experiment 6 | Flowers | Resize to (224x224), Normalize | SGH-CNN with increased SGH resolution | 10 hours | 0.87 | 0.88 | 0.86 | 0.87 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,141 @@ | ||
package advance; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Heap data structure is a complete binary tree that satisfies the heap property, where any given node is | ||
* <p> | ||
* always greater than its child node/s and the key of the root node is the largest among all other nodes. | ||
* This property is also called max heap property. | ||
* always smaller than the child node/s and the key of the root node is the smallest among all other nodes. | ||
* This property is also called min heap property. | ||
* This type of data structure is also called a binary heap. | ||
* <p> | ||
* Heapify is the process of creating a heap data structure from a binary tree. | ||
* It is used to create a Min-Heap or a Max-Heap. | ||
* <p> | ||
* Peek operation returns the maximum element from Max Heap or minimum element from Min Heap without deleting the node. | ||
* <p> | ||
* Heap Data Structure Applications | ||
* Heap is used while implementing a priority queue. | ||
* Dijkstra's Algorithm | ||
* Heap Sort | ||
* <p> | ||
* The index of a child element divide by 2 is equal to its parent's index/2 | ||
* Index of the root node is 1 | ||
* Parent = (i - 1) / 2 | ||
* Left = ((2 * i) + 1) | ||
* Right = ((2 * i) + 2) | ||
* <p> | ||
* The value of a given node has to be less than all of its children | ||
* O(log(n)) for insertion | ||
* Heap sort - O(Nlog(N)) | ||
*/ | ||
public class Heaps { | ||
|
||
public static void main(String[] args) throws Exception { | ||
Heap<Integer> heap = new Heap<>(); | ||
heap.insert(34); | ||
heap.insert(45); | ||
heap.insert(22); | ||
heap.insert(89); | ||
heap.insert(76); | ||
System.out.println(heap.heapSort()); | ||
} | ||
} | ||
|
||
class Heap<T extends Comparable<T>> { | ||
|
||
private ArrayList<T> items; | ||
|
||
public Heap() { | ||
this.items = new ArrayList<>(); | ||
} | ||
|
||
public void swap(int first, int second) { | ||
T temp = items.get(first); | ||
items.set(first, items.get(second)); | ||
items.set(second, temp); | ||
} | ||
|
||
public int parent(int index) { | ||
return (index - 1) / 2; | ||
} | ||
|
||
public int right(int index) { | ||
return index * 2 + 2; // Gives the right side | ||
} | ||
|
||
public int left(int index) { | ||
return index * 2 + 1; // Gives the left side | ||
} | ||
|
||
public void insert(T value) { | ||
items.add(value); | ||
upheap(items.size() - 1); | ||
} | ||
|
||
// Going up the heap | ||
private void upheap(int index) { | ||
if (index == 0) return; | ||
|
||
int parent = parent(index); | ||
|
||
// Swap if the current item is smaller than parent | ||
if (items.get(index).compareTo(items.get(parent)) < 0) { | ||
swap(index, parent); | ||
upheap(parent); // Call the parent element | ||
} | ||
} | ||
|
||
// Remove the smallest element | ||
public T remove() throws Exception { | ||
if (items.isEmpty()) | ||
throw new Exception("Removing from an empty list"); | ||
|
||
T temp = items.get(0); | ||
T lastElement = items.remove(items.size() - 1); | ||
if (!items.isEmpty()) { | ||
items.set(0, lastElement); | ||
downHeap(0); | ||
} | ||
return temp; | ||
} | ||
|
||
// O(log(N)) | ||
private void downHeap(int index) { | ||
int min = index; | ||
int left = left(index); | ||
int right = right(index); | ||
|
||
// if the left element is the minimum element | ||
if (left < items.size() && items.get(min) | ||
.compareTo(items.get(left)) > 0) { | ||
min = left; | ||
} | ||
|
||
// If the right element is the minimum element | ||
if (right < items.size() && items.get(min).compareTo(items.get(right)) > 0) { | ||
min = right; | ||
} | ||
// Swap if the minimum element isn't equal the index. | ||
if (min != index) { | ||
swap(min, index); | ||
downHeap(min); // Go downwards | ||
} | ||
} | ||
|
||
public ArrayList<T> heapSort() throws Exception{ | ||
ArrayList<T> data=new ArrayList<>(); | ||
while (!items.isEmpty()) { | ||
data.add(this.remove()); | ||
} | ||
return data; | ||
} | ||
|
||
// Construct a max-heap from an unsorted array | ||
public void maxHeapUnsorted(){ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.