title: When is it dangerous to have too many dynamic arrays?
body: <p>I'm currently writing code for an assignment that deals with cities and bridges. I have to print the cities and bridges out in their respected districts such as:</p>
  
  <pre><code>//unorganized inputs from user given the # of "paths" we need
  4       // the # of paths
  1 2 5  // 1 = city , 2 = city, 5 = bridge length
  6 7 5  // 6 = city , 7 = city, 5 = bridge length
  2 3 7  // 2 = city , 3 = city, 7 = bridge length
  6 9 7  // 6 = city , 9 = city, 7 = bridge length
  </code></pre>
  
  <p>After run through program, it will be sorted as:</p>
  
  <pre><code>first district
  1 2 5
  2 3 7
  
  2nd district
  6 7 5
  6 9 7
  </code></pre>
  
  <p>Now, I'll be reading these inputs through cin. I want to store all the possible paths such as 1 2 5 into an array and then sort and organize them through the program. The problem is that I may have over 500,000 paths from the user. I want to create 500k dynamic arrays. Will this cause serious problems in terms of memory?</p>
  
  <p>I have looked at other possible ways of solving this such as kruskal's algorithm and disjoint sets(I think is the most useful). I'm having a very hard time understanding the coding of disjoint sets, I figured I try a way I'm more familiar with.</p>
  
  <p>Any help with where to store the values and compare and organize them would be great. Links to places where I read info on this would help. I've read a lot over the past few days. Hasn't helped much.</p>
  
  <p>To sum it all up, my questions are:</p>
  
  <ul>
  <li>Will 500k dynamic arrays cause serious problems in terms of memory?</li>
  <li>Where to store the values and compare and organize them given the paths?</li>
  </ul>