calculating number of comparison in a vector
1 次查看(过去 30 天)
显示 更早的评论
if I have a vector with N elements and want to find the maximum M elements from them, how many comparison operations I need??
4 个评论
回答(1 个)
Dimitris Kalogiros
2018-9-3
It depends on the algorithm than you will use.
You can use a bubble sort routine to sort the vector and then to choose M most max elements (or min elements).
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!