Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the scale of time complexity of this algorithm?

I have a list of list, in different length, and my algorithm runs on every element in the sub lists.

What should be my time complexity?

I don’t know if it’s okay to write O(n * m), as n length of parent list and m is the average length of t
E sub lists, or maybe O(n) as n is the number of total elements.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Please explain what the meaning of the symbols (for example n is the length of the parent list).

>Solution :

If you have n sublists with m elements each, n*m represents the total number of elements being processed, hence it has a complexity of O(n*m).

If your sublists have an unequal number of elements, it is okay to summarise it as O(N), where N is the total number of elements in the array.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading