Algorithm plagarism? Say I watch some YouTube videos to learn merge sort, and during the lesson the code for merge sort is shown and explained, if after this I write my own program and use the merge-sort algorithm I learned from the video, am I plagiarizing? 

Say if I need to hand in an project for university and it requires a mergesort on an array of integers in a part of the program like the example in the lesson was, can I get wrecked for plagiarism if I used the mergesort method from the lesson to use in my project?

edit: assuming that I completely understand the algorithm and can explain every part
Plagiarism is using the words or ideas of another without proper credit.  So, if you don't give credit, you're plagiarizing.  If you do give credit, you're not.  It is really that simple.

In your particular case, there may be something else at work.  If your professor taught merge sort, and the assignment is to demonstrate that you know how to do it, then you might be in trouble for copying another's code even if you give proper credit; it's not plagiarism, but it still might not be allowed.   As Mad Jack has said in the comments, ask your professor.