Hi guys, how can I do an array with space complexity O(1) ?
if I do it by constant compiler time like "int arra[20] " it takes O(n) and not O(1) .. maybe here I'm wrong about that but at least that what I've realized...
Hi guys, how can I do an array with space complexity O(1) ?
if I do it by constant compiler time like "int arra[20] " it takes O(n) and not O(1) .. maybe here I'm wrong about that but at least that what I've realized...
Who told you "to implement array with space complexity O(1)"?
Anyway, I'd say that what you're missing is that 20 is a constant, i.e., no matter how large your input, you still only have space for 20 ints, so the space complexity is constant.
Last edited by laserlight; 12-31-2018 at 07:49 AM.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I'm wondering whether RyanC is a native English speaker.
Because the buzzword bingo he keeps posting looks like the mangled ramblings of google translate, rather than coherent thought.
No, you can't implement arr[n] in anything less than O(n) space.
Pauli exclusion principle - Wikipedia
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
None, but lemme ask you , should be take the space complexity of a given array?! meaning with this, if there's an assignment which telling you to do ..."something" .. with space complexity space O(1) and already given two arrays ..so should you take the two given arrays into consideration of space complexity? or actually we just calculating the complexity space of what're going to do and not what's given?!
thanks
I can't believe people still respond to this entity. It's pointless.
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson
You basically ignored what I wrote and then came up with a hypothetical scenario that either won't happen or conforms to what I wrote. If it does happen and doesn't conform to what I wrote: go ask your instructor what on earth is going on.Originally Posted by RyanC
It is a legit compsci question, I suppose, except that I don't want to fuel his wild thinking with more random ideas on how it is legit.Originally Posted by bruteforce
Neither. I think he's just a learner who likes to do a shotgun approach, which I guess works for some people, except that then he couples it with either missing what's obvious, or overthinking it until he feels compelled to post instead of just taking a nap.Originally Posted by stahta01
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
maybe you miss understood and that's why you think I'm ignoring what've wrote !
I'm asking if I have a function for instance String(char A[40], int size) , my question are we taking into consideration the given array for calculating the time complexity/space of that function? or we just assuming it as given and it doesn't take time at all?!
Obviously. Note that this is a plausible call to the String function:Originally Posted by RyanC
Code:char my_real_array[12345]; String(my_real_array, 12345);
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson
Are you serious?
I doubt a genius would have such poor grammar and ability of expression. He is borderline incoherent at points. Even google translate would generate better posts. He is a troll alright, although not a good one. Admittedly he got me recently, when I replied to one of his threads. But that's only because I have the tendency to focus on the question and ignore the user name, not falling for that again.
Don't get me wrong, I like trolls -good ones that is. I don't know, there's a certain je ne sais quoi about 'em that I quite enjoy.
This is one of my all time favorites:
My (25 M) girlfriend (26 F) baked all the beans, now I consider to end our relations? What does I do? : copypasta
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I like your AI idea better.
Or a brain in a vat, sans brain.
Idiot savant, emphasis on idiot.
Cat on a keyboard.
Noise in a cable.
Indigestion?
Anyone who insists on interacting with him should be directed to the NULL pointer saga of 2015. That will cure them. It's painfully reminiscent of what's going on now.
People have been telling this guy to "read a book" for four years.