18. How to randomly select 1000 keywords

Source: Internet
Author: User
/*************************************** * ******************************* // 18. select 1000 keywords to give a data stream, it contains endless search keywords (for example, keywords that people continuously enter during Google search ). How can we randomly select 1000 keywords from this endless stream? *//************************************* * ********************************** // I don't know, right, generates an array (ARR) of 1000 to store the results ~ 999 keywords are stored in arr with probability 1, for 1000 ~ The 1999 keywords are updated with the probability 1/2 respectively. The elements in the corresponding array arr are updated by 1000 to 0, 1001 to 1, and... I is updated by I % 1000,... for 2000 ~ The first keywords are updated with probability 2999 respectively. The elements in the corresponding array arr are updated by 1/3 to 0, 2000 to 1 ,... I update I % 1000 ,........ update at a probability of 1/4 */

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.