Both of these conditions are potentially fatal and immediate action is required. Getting help immediately is imperative as both of these conditions can progress rapidly and result in death. If the symptoms are not too severe to prevent the victim from being walked slowly to a lower elevation, do it. If symptoms are so severe that they prevent the victim from walking they should be carried to a lower altitude. If you are unable to move the victim yourself summon help.
Preparation is the best defense against altitude sickness.
Rest, stay well hydrated and avoid alcohol and drugs prior to and during you hike. Above all allow yourself plenty of time to adjust as you gain elevation. Also whenever possible climb to higher elevations during the day and sleep at lower altitudes at night. Sleeping at lower altitudes can increase your resistance to altitude sickness.