calculating number of comparison in a vector

1 visualización (últimos 30 días)
Liza Afeef
Liza Afeef el 3 de Sept. de 2018
Comentada: Liza Afeef el 3 de Sept. de 2018
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 comentarios
Liza Afeef
Liza Afeef el 3 de Sept. de 2018
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 el 3 de Sept. de 2018
This does not seem to be a matlab question at all.

Iniciar sesión para comentar.

Respuestas (1)

Dimitris Kalogiros
Dimitris Kalogiros el 3 de Sept. de 2018
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 comentario
Liza Afeef
Liza Afeef el 3 de Sept. de 2018
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by