Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. While(x not found in S) {
  2.     // Find the value of the difference or S2
  3.     int difference = x - S[Element]
  4.  
  5.     // if the difference is < 0 this would mean that
  6.     // the element is greater than x
  7.     // and thus S1 + S2 != x
  8.     if (difference < 0)
  9.         Discard
  10.     else {
  11.         // Firstly check if S[Element] == to Difference in Hash Table
  12.         // If S[Element] == Key in Hash then that would mean Hash.Key.Value + S[Element] == x
  13.         if (S[Element] is a key in Hash Table)
  14.             return S1 = S[Element] & S2 = Hash.Key(S[Element]).Value
  15.  
  16.         // We insert it into the hash table if it does not already exist
  17.         // Difference is not a key in the Hash Table
  18.         else
  19.             Insert into hash table (Key == Difference, Value = S[Element]
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement