Feature #5: Calculate the Search Ranking Factor

Implementing the "Calculate the Search Ranking Factor" feature for our "Search Engine" project.

Description

Consider that your company has decided to experiment with a different search ranking algorithm. This algorithm favors search results that reference each other and create a closed graph. All the web pages in the search result have already been assigned scores based on their content quality and relevance. Now, we want to determine the ranking factor of each page, which will be used in tandem with other criteria to determine the final page rank. To find this ranking factor, the team has decided to take the product of the scores of all pages that are referenced by the current page. This means that in the set of web pages where each one references the other, the ranking factor of each page will be determined by multiplying the scores of all the other pages in the set except itself.

To implement this feature, you will be provided with an array containing the page scores of web pages that reference each other. A page’s rank is calculated as the product of the scores of all the pages that link to it. For example, you are given the following scores of five web pages that link to each other: {1, 4, 6, 9}. The ranking factor found by the algorithm mentioned above will be: {216, 54, 36, 24}.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.