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
    
  
  
    
  | # -*- mode: ruby -*- | |
| # vi: set ft=ruby : | |
| # All Vagrant configuration is done below. The "2" in Vagrant.configure | |
| # configures the configuration version (we support older styles for | |
| # backwards compatibility). Please don't change it unless you know what | |
| # you're doing. | |
| Vagrant.configure(2) do |config| | |
| config.vm.box = "ubuntu/trusty64" | |
| config.vm.network :forwarded_port, guest: 80, host: 8000 | 
  
    
      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
    
  
  
    
  | // "static void main" must be defined in a public class. | |
| public class Main { | |
| public static void main(String[] args) { | |
| Node n0 = new Node(0); | |
| Node n1 = new Node(1); | |
| n0.left = n1; | |
| Node n2 = new Node(2); | |
| n0.right = n2; | |
| Node n3 = new Node(3); | |
| n1.left = n3; | 
  
    
      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
    
  
  
    
  | Below are the Big O performance of common functions of different Java Collections. | |
| List | Add | Remove | Get | Contains | Next | Data Structure | |
| ---------------------|------|--------|------|----------|------|--------------- | |
| ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array | |
| LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List | |
| CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array | 
  
    
      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 java.io.*; | |
| import java.util.*; | |
| class GFG { | |
| public static void main (String[] args) { | |
| TextJustifier tester = new TextJustifier("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc tempor erat sed libero vehicula, a cursus ipsum elementum. Donec et convallis felis. Nam euismod sit amet est quis elementum. Suspendisse nec porta erat, eget suscipit risus. Nam et pellentesque quam. Duis dapibus lectus eu ante tincidunt porttitor. Nam mollis lectus quis elit consequat, at semper odio maximus. Nullam nisi odio, dictum id viverra vel, consectetur a velit."); | |
| for (String line: tester.getMessages(50)) { | |
| System.out.println(line); | |
| } | |
| } | 
  
    
      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
    
  
  
    
  | Latency Comparison Numbers | |
| -------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |