I'm trying to understand complexity class algorithms off of my professor's lecture notes, but I still can't get a hang of it.(adsbygoogle = window.adsbygoogle || []).push({});

void sort(int a[], int N) { //N is the length of the array

for (int base=0; base<N; ++base)}

for (int check=base+1; check<N; ++check)

if (a[base] > a[check])

std::swap(a[base], a[check]);

On his notes he says the expression for this is 8N^2+12N+6.

From what I understand fully the complexity class for this is N^2 because it is the fastest growing out of the rest. We ignore constants because they're irrelevant when going to infinity.

However, I want to knowhowhe got the coefficients.

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Why is the complexity class expression this?

Tags:

Loading...

Similar Threads for complexity class expression |
---|

C/++/# Class, Interface, Abstract, Static, Partial, Sealed |

C/++/# Question about a specific class method in C++ |

Purpose of Abstract Class |

**Physics Forums | Science Articles, Homework Help, Discussion**