Click here to Skip to main content
15,888,461 members

Comments by mike@codeproject (Top 6 by date)

mike@codeproject 9-May-21 14:36pm View    
... since log_a(x) = log_b(x) * (1 / log_b(a)) for any bases a > 1 and b > 1.
mike@codeproject 9-May-21 14:32pm View    
The base of a logarithm doesn't matter in big-O or big-theta notation. O(log x) = O(ln x) = O(lg x) = O(log_b x)
mike@codeproject 24-Apr-21 1:00am View    
The Python syntax a R1 b R2 c translates (by definition) to (a R1 b) and (a R2 c), where R1,R2 are any comparison operators. So 0 < x < 1 does the expected thing (0 < x) and (x < 1), but also other combinations are possible: a==b==c tests for three numbers being equal, while 1 != x < 0 tests for a positive number that's not 1 (e.g. the domains of a logarithm.) This is handy when the central value is a complicated expression.
OP's syntax is not C++, though, and (as you have observed) isn't what he wanted even if it were allowed.
mike@codeproject 22-Apr-21 14:52pm View    
What I forgot to mention in my answer was that you should get the first part coded and fully tested before worrying about--or asking questions about--later parts of the assignment. It's pointless to talk about how to find the average/maximum/minimum of a sequence of k values when you haven't yet figured out how to generate those values. Step 1 is to get your input, step 2 is to use the input to generate the required sequence of k values. Get those done, in order if you don't want to go crazy, and ask about the first problem you can't solve on your own--not about the whole assignment.
mike@codeproject 22-Apr-21 14:37pm View    
Okay, I misunderstood. FWIW, if OP had a Computer Science Concepts class, that could be a source. That's a warm-up for AP Computer Science, often based on Python (but JS can also be used) and that triple inequality syntax is valid in Python. Thanks again.