title: Error: Vector subscript out of range. Line 1201
body: <p>I am facing the vector subscript out of range erro. I have managed to locate the code that is causing the problem but i dont know how to solve it. </p>
  
  <p>the defined variable types are,</p>
  
  <pre><code>typedef vector &lt;string&gt; v1; //vector string
  
  typedef vector &lt;v1&gt; v2; // vector (v1) to create a double vector
  
  typedef map&lt;string, int&gt; mapstint; //vector (string, int)
  
  typedef vector&lt;int&gt; vint; // vector (int)
  
  typedef vector&lt;double&gt; vd;
  </code></pre>
  
  <p>The CODE is as follows,</p>
  
  <pre><code>string splitgain(v2 &amp;table)
  {
      int col, i;
  
      string coln;
      mapstint map;
      double min = DBL_MAX;
      int splitcol = 0;
      vint eval,nos;
  
      for (col = 0; col &lt; table[0].size() - 1; col++)
      {
          coln = table[0][col];
          vint counts = countno(table, col);
          vd atteval;
          double colval = 0.0;
          for (i = 1; i &lt; table.size() - 1; i++)
          {
              double val = 0.0;
              if (map.find(table[i][col]) != map.end())
              {
                  map[table[i][col]]++;
              }
              else
              {   map[table[i][col]] = 1;
                  v2 tempt = prune(table, coln, table[i][col]);
  
                  vint ccounts = countno(tempt, tempt[0].size() - 1);
                  int j, k;
                  for (j = 0; j &lt; ccounts.size(); j++)
                  {
                      double temp = (double)ccounts[j];
                      val -= (temp / ccounts[ccounts.size() - 1])*(log(temp / ccounts[ccounts.size() - 1]) / log(2));
                  }
                  atteval.push_back(val);
                  val = 0.0;
              }
          }
  
          //------THIS IS WHERE THE ERROR IS COMING FROM-------
  
          for (i = 0; i &lt; counts.size() - 1; i++)
          {
              colval += ((double) counts[i] * (double) atteval[i]);
          }
          //----------------------------------------------------
  
          colval = colval / ((double)counts[counts.size() - 1]);
          if (colval &lt;= min) 
          {
              min = colval;
              splitcol = col;
          }
      }
      return table[0][splitcol];
  }
  </code></pre>