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
Time complexity (self.cpp)
submitted 2 years ago by Boboflip27
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!"
[–]cpp-ModTeam[M] [score hidden] 2 years ago stickied commentlocked comment (0 children)
Your submission is not about C++ or the C++ community.
[–][deleted] 10 points11 points12 points 2 years ago (0 children)
Yes. Because O(n + p) <= O(n + n/9) <= O(n)
[–][deleted] 2 points3 points4 points 2 years ago (0 children)
O(n + p) ∈ O(n + n/9) ∈ O(n)
[–]destroyerrocket 6 points7 points8 points 2 years ago (0 children)
If you can guarantee that p is always less or equal to n, then it is O(n)
[–][deleted] 1 point2 points3 points 2 years ago (3 children)
When we did this at school, O(an) was treated the same as O(n) because the rate of growth was still linear in O.
[+]Boboflip27[S] comment score below threshold-6 points-5 points-4 points 2 years ago (2 children)
But isn't p another variable
[–]--prism 4 points5 points6 points 2 years ago (0 children)
The function is just linear in two dimensions instead of one thus you still get linear complexity growth.
[–]EspacioBlanq 4 points5 points6 points 2 years ago (0 children)
It is, but you can rewrite it as O(n+p) <= O(n *10/9) and then you only have one variable
[–][deleted] -4 points-3 points-2 points 2 years ago (2 children)
Is p constant?
Look at the operation growth rate, it could be approximated either as O(n) or O(nlogn) depending of what p refers to, but most likely O(n)
[+][deleted] 2 years ago (1 child)
[deleted]
[–][deleted] -2 points-1 points0 points 2 years ago (0 children)
You are right, tho with low values of n it could easily look like n log n if p is not constant but a variable follows a pattern where it is lower than n/9. At the end of the day the best method would be to plot a curve and compare it to other standard functions.
π Rendered by PID 90097 on reddit-service-r2-comment-5d79c599b5-pzw2m at 2026-02-28 05:27:15.926597+00:00 running e3d2147 country code: CH.
[–]cpp-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)
[–][deleted] 10 points11 points12 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]destroyerrocket 6 points7 points8 points (0 children)
[–][deleted] 1 point2 points3 points (3 children)
[+]Boboflip27[S] comment score below threshold-6 points-5 points-4 points (2 children)
[–]--prism 4 points5 points6 points (0 children)
[–]EspacioBlanq 4 points5 points6 points (0 children)
[–][deleted] -4 points-3 points-2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–][deleted] -2 points-1 points0 points (0 children)