The word "top" is used here because David went up in elevation and is at the top of a hill. Alternate translation: "at the top of the hill" (See: [[rc://en/ta/man/translate/figs-explicit]])
This is an act showing shame or repentance. Here the word "earth" means dirt. Alternate translation: "He had torn his clothes and put dirt on his head to show that he was very sad" (See: [[rc://en/ta/man/translate/translate-symaction]] and [[rc://en/ta/man/translate/figs-synecdoche]])