title: MapReduce fundamentals
body: <p>1) `
        map(nr, txt)</p>
  
  <pre><code> words = split (txt, ' ')
   for(i=0; i&lt; |words| - 1; i++)
      emit(words[i]+' '+words[i+1], 1)
  
  reduce(key, vals)
  s=0
  for v : vals
      s += v
  if(s = 5)
       emit(key,s)`
  </code></pre>
  
  <p>2)   `map(nr, txt)</p>
  
  <pre><code>  words = split (txt, ' ')
    for(i=0; i &lt; |words|; i++)
        emit(txt, length(words[i]))
  
    reduce(key, vals)
     s=0
     c=0
    for v : vals
        s += v
        c += 1
        r = s/c
   emit(key,r)`
  </code></pre>
  
  <p>I am new to MapReduce and when I am not able to understand if the "if condition in the code(1) will ever satisfy" </p>
  
  <p>Q1 We need to determine what this MapReduce function do in both the code?
  Could you please give any input on the above question.</p>