Algorithm for removing entries from an array, by removing “middlest” items?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Algorithm for removing entries from an array, by removing “middlest” items?



Given a list of items of length n, where a maximum number of wanted items is m, and m < n, and in which the items in the list which are most valuable / useful are those that are furthest from any other item. How can I remove items from the list to reduce the size of the list to m.


n


m


m < n


m



e.g., for [ a, b, c, d, e ] with an m == 2, we would get [ a, e]


[ a, b, c, d, e ]


m == 2


[ a, e]



e.g., for [ a, b, c, d, e ] with an m == 3, we would get [ a, c, e ]


[ a, b, c, d, e ]


m == 3


[ a, c, e ]


[ a, b, c, d, e ]


m == 4


[ a, b, c, e ]


[ a, c, d, e ]



Note: I am generalizing a real problem, which is selecting representative frames from a video. The code will be written in python.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

CRM reporting Extension - SSRS instance is blank

Keycloak server returning user_not_found error when user is already imported with LDAP