This file contains hidden or 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
| type Node struct { | |
| Data int | |
| Left *Node | |
| Right *Node | |
| } | |
| func NewNode(data int) *Node { | |
| return &Node{data, nil, nil} | |
| } |
This file contains hidden or 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
| func DFRec(n *Node) { | |
| if n == nil { | |
| return | |
| } | |
| DFRec(n.Left) | |
| n.Process() | |
| DFRec(n.Right) | |
| } |
This file contains hidden or 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
| func DF(n *Node) { | |
| s := Stack{} | |
| current := n | |
| for { | |
| if s.IsEmpty() && current == nil { return } | |
| if current != nil { | |
| s.Push(current) | |
| current = current.Left | |
| } else { | |
| current, _ = s.Pop() |
This file contains hidden or 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
| func main() { | |
| start := time.Now() | |
| n := NewNode(1) | |
| n.Left = NewNode(2) | |
| n.Right = NewNode(3) | |
| n.Left.Left = NewNode(4) | |
| n.Left.Right = NewNode(5) | |
| n.Right.Left = NewNode(6) | |
| n.Right.Right = NewNode(7) |
This file contains hidden or 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
| var wg sync.WaitGroup | |
| func DFRecImproved(n *Node){ | |
| if n == nil { | |
| return | |
| } | |
| wg.Add(1) | |
| go DFRecImproved(n.Left) | |
| n.Process() | |
| wg.Add(1) |
This file contains hidden or 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
| func main() { | |
| n := NewNode(1) | |
| n.Left = NewNode(2) | |
| n.Right = NewNode(3) | |
| n.Left.Left = NewNode(4) | |
| n.Left.Right = NewNode(5) | |
| n.Right.Left = NewNode(6) | |
| n.Right.Right = NewNode(7) | |
| n.Right.Right.Left = NewNode(8) |
This file contains hidden or 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
| package main | |
| import ( | |
| "fmt" | |
| "sync" | |
| "time" | |
| ) | |
| var wg sync.WaitGroup |
This file contains hidden or 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
| import * as cdk from "@aws-cdk/core"; | |
| import * as eks from "@aws-cdk/aws-eks"; | |
| import * as ec2 from "@aws-cdk/aws-ec2"; | |
| import * as iam from "@aws-cdk/aws-iam"; | |
| import { CfnJson } from "@aws-cdk/core"; | |
| export class MyCluster extends cdk.Construct { | |
| constructor(scope: cdk.Construct, id: string) { | |
| super(scope, id); |
This file contains hidden or 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
| enableAutoscaling(cluster: eks.Cluster, ng: eks.Nodegroup, version: string = "v1.17.3") { | |
| const autoscalerStmt = new iam.PolicyStatement(); | |
| autoscalerStmt.addResources("*"); | |
| autoscalerStmt.addActions( | |
| "autoscaling:DescribeAutoScalingGroups", | |
| "autoscaling:DescribeAutoScalingInstances", | |
| "autoscaling:DescribeLaunchConfigurations", | |
| "autoscaling:DescribeTags", | |
| "autoscaling:SetDesiredCapacity", | |
| "autoscaling:TerminateInstanceInAutoScalingGroup", |
This file contains hidden or 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
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: nginx-scale | |
| spec: | |
| replicas: 1 | |
| selector: | |
| matchLabels: | |
| app: nginx | |
| template: |
OlderNewer