Am I allowed to add snippet of code from the internet that doesn't have a license?
No license means no license meaning you are not licensed to use it beyond looking at it in most cases.
For example if I used this reference to implement depth first search and copied some of the code?
The site you are linking to links to this Copyright page:
The content may not be redistributed or reproduced in any form without
the written permission from Sanfoundry. However, if you are linking the
content from our website, you can use a short description (no more than
25-30 words) from our website with the content in quotes plus you must
provide a link to our original article or post.
You cannot use the content (either whole or partial) for any commercial
So it has a clear license that does not allow you to do much and would be conflicting with the terms of the GPL. Contact the author for a proper license compatible with the GPL.
Another example is I found a good pretty_print function on a website with no license. While I can change the names of things, the idea remains the same. Can I include the pretty_print function in my own code with the GNU Public License?
Same answer as above: you are not licensed by default and the lack of an explicit license means you have no rights. By default all rights are mostly reserved. Masquerading the code by doing some renaming would be even worse. Do not do that!