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

Multi tool use


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.