Quote:
Originally Posted by mayankladoia
arr.resize(x,vector<double>(x,0));
but while trying to run with large data ie x = 5000000 approx it is giving error
|
I'll bet it is.
The long story:
What you're doing is making
x vectors, and each one of them gets a
different copy of a vector that has enough storage space for
x doubles.
On my machine, a double is 8 bytes. 5,000,000 doubles is 8 * 5,000,000 = 40,000,000 bytes = 39,062.5 kB = 38.1 MB. That's the size (the absolute
minimum size) of
each vector<double>. Make 5,000,000 of
those and that's 38.1 * 5,000,000 = 190,500,000 MB = 186,035.1 GB = 181.7 TB.
I'd bet it's actually impossible for you to have that much hard disk space, and I
know it's physically impossible for you to have that much RAM.
The short story:
Use a smaller
x.