Q:

When you call new[] to allocate an array for N integers is it guaranteed that the array is going to be allocated sequentially in physical memory? 

From my understanding every computer program always works with virtual memory and the way physical memory is handled is up to the operating system.  
I am attending an algorithm engineering's course and at some point it was mentioned that if the cache memory is infinite and one cache line is of size B then the expected amount of cache misses that would be incurred if you wanted to just scan through an array of N elements would be N/B
I can see how this would work in theory, because we assume that the N elements are positioned one after the other in physical memory. 
But, is this actually true in practice?  If virtual memory is allocated sequentially, does that also mean that the physical memory will also be allocated sequentially? 
It sounds to me that in practice, assuming that N is not larger than the cache size, you would get more than N/B cache misses if the N elements weren't allocated sequentially in the physical memory (RAM). 
Maybe I am misunderstanding the difference between virtual memory and physical memory, I am not sure. 

A:

It's just as you say: the array elements are contiguous in virtual memory, but not necessarily in physical memory. 
On a PC-like architecture, memory is allocated in pages, which are typically much larger than cache lines (typically several kilobytes versus dozens of bytes).  Each page maps a contiguous range of virtual memory to a contiguous range of physical memory.  So each cache line will still span a contiguous range of physical memory, and the discontinuities in physical memory won't cause any extra cache misses.