The given name (or 'first' name) is sometimes, but not always, determined by the following pattern:
1st son = Father's father's name
2nd son = Mother's father
3rd son = Father
4th son = Father's grandfather
5th son = Mother's grandfather
1st daughter = Father's mother's name
2nd daughter = Mother's mother
3rd daughter = Mother
4th daughter = Father's grandmother
5th daughter = Mother's grandmother
To arrive at the last name, for the male children, 'son' was added to the father's first name. For the female children, 'datter' was added. For example, in the Travland family, Peder Pederson had a son Andreas, who then became Andreas Pederson*. Had Peder Pederson had a daughter named Marta, she would have become Marta Pedersdatter.
For those families that lived on farms, the farm had a name which was used by the family as a second last name. If the family moved, their last name would change to match that of their new residence. This was common not only for farmers but for families living in small villages or towns.
For more information on the Norwegian naming system, the following website provides more detail:
*The 'p' was dropped after moving to the United States and a 't' was added - Peterson.