First – the category or top chart ranking algorithm (free, paid and grossing) is much simpler than the keyword ranking algorithm. App category ranks improve with more downloads (free or paid) or more revenue from purchases (grossing). While the exact calculation in terms of installs or purchases volume to rank is unknown and varies between categories (e.g. photos and video vs weather), but it is logarithmic (i.e. moving from rank 1000 to 500 is much easier than from moving from 10 to 5) and the most important factors are installs or purchases. Apps will first achieve a rank in their category or sub-category (e.g. #1500 entertainment apps), followed by their country (e.g. #1500 US overall).
The initial factor of the keyword ranking algorithm is whether an app is relevant for that keyword or not. Without being relevant, you app is even eligible to show up (i.e. Facebook is the most popular app but only shows for a certain set of relevant keywords). Relevancy is determined by several factors including those in question #3 below.
For all apps that are relevant for a keyword, each is assigned a keyword rank score that changes with each user interaction (e.g. pageview, install, purchase). An app’s keyword rank score is updated with each interaction and either goes up with positive engagement (e.g. a click, install or review) or goes down with each negative engagement (e.g. an impression but no click, pageview but no install or uninstall before the app is ever used). Apps compete with one another to rank for keywords and when one app’s rank score for a keyword becomes higher than the score of the app above it, it will move up one spot. Engagements are sourced back to each keyword that the user came from, meaning that scores are different from each keyword. That said, engagements for an app overall will improve its ranking for all relevant keywords to some degree, meaning that if Facebook were to become eligible for a new keyword, it would likely start at a very high ranking.
The keyword ranking algorithm is also logarithmic and most installs come from the top 10 ranked apps for a keyword.