calculating number of comparison in a vector

조회 수: 1 (최근 30일)
Liza Afeef
Liza Afeef 2018년 9월 3일
댓글: Liza Afeef 2018년 9월 3일
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
Liza Afeef
Liza Afeef 2018년 9월 3일
as an example, if I have a vector with 100 elements and need to take 25 elements that have the highest value, I need to make a comparison between all the elements in the vector. So my question is how many comparison operations I need ??
jonas
jonas 2018년 9월 3일
This does not seem to be a matlab question at all.

댓글을 달려면 로그인하십시오.

답변 (1개)

Dimitris Kalogiros
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).
  댓글 수: 1
Liza Afeef
Liza Afeef 2018년 9월 3일
I've already made the sorting inside my code but I need to know the number of operations that Matlab make to make the sorting.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by