Reinstalling the system back to how it was when it left the factory by using the recovery disk will fix the problem IF it's caused by viruses or system files being damaged.
It won't fix it if the random restarts are caused by a hardware fault such as the RAM (the memory chips). Even if the laptop is quite new, it's possible to be unlucky and get one with a faulty component.
It's unusual for viruses to cause random restarts. Usually they cause different symptoms from that, various kinds of strange behaviour in the system rather than just restarts.
I would try a memory test using the freeware memtest86+ from
Memtest86+ - Advanced Memory Diagnostic Tool
Get the file near the top of the list called "Download - Pre-Compiled Bootable ISO (.zip)" unzip it and burn the image file inside it (memtest86+-2.01.iso) it to make a bootable CD using Imgburn from here if you don't already have a CD burner such as Nero
The Official ImgBurn Website
Insert the memtest86+ CD, reboot the laptop and give it a long run, such as overnight. If it reports any fauts, you should get the RAM replaced under warranty if possible. If it's out of warranty you'll need to buy new ram. (Or possibly the ram is loose in its slot and just needs to be pulled out and pushed in again firmly).
If it passes the memory test, then try a fresh operating system using the recovery disks described above.
Or you could do it the other way round: Try reinstalling the operating system and if that fails you will know it's a hardware fault. If so you would do a memory test because that is usually the first suspect.
Of course there are lots of other possible hardware faults which can cause the restarts you describe, such as a loose connection or a faulty motherboard.