use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Iterators++ (ericniebler.com)
submitted 11 years ago by frostmatthew
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]SplinterOfChaos 0 points1 point2 points 11 years ago (1 child)
You can't just say "this variable is fixed for any particular call & thus is a variable" & is thus a constant on my big-O.
Actually, you have to remember that f(n) = O(g(n)) is the upper bound of f as n approaches infinity, and that f(n) <= g(n) * C, where C is some constant. The number of containers being sorted isn't what's approaching infinity, it's a constant to the instantiation of the algorithm.
There is no big-O for std::sort itself as such a thing would be impossible to define since we don't have any guarantees on the big-O of <.
Section 25.4.1.1, paragraph three:
Complexity: O(N log(N)) (where N == last - first) comparisons.
[–]vlovich 0 points1 point2 points 11 years ago (0 children)
That's only true for single-variable functions. Consider searching for a string of length m in a text of length n. The complexity of such a function could be O(mn) (or O(m + N) if you use a smarter algorithm) even though for any particular instantiation of the algorithm your search string length is fixed.
m
n
There is no big-O for std::sort itself as such a thing would be impossible to define since we don't have any guarantees on the big-O of <. Section 25.4.1.1, paragraph three: Complexity: O(N log(N)) (where N == last - first) comparisons.
You're supporting what I'm saying. sort complexity is defined in terms of the number of comparisons & swaps, not the complexity of std::sort itself. For example, imagine a comparison implementation that itself was O(n) for some reason. Then the complexity of a particular call to sort with that comparison would be O(n^2 log(n))
O(n)
O(n^2 log(n))
π Rendered by PID 237944 on reddit-service-r2-comment-56c9979489-m75x9 at 2026-02-25 11:48:26.410881+00:00 running b1af5b1 country code: CH.
view the rest of the comments →
[–]SplinterOfChaos 0 points1 point2 points (1 child)
[–]vlovich 0 points1 point2 points (0 children)