News for hackers. Stuff that matters.
Re:Exotic Data Structures (2011) by MichaelMoser123 on Tuesday July 11, 2017 @07:01AM (#14743094)
Compact dynamic array is an std::deque right? What's so exotic about that?
Re:Exotic Data Structures (2011) by pja on Tuesday July 11, 2017 @07:21AM (#14743183)
Once you get down to PMAs and van Emde Boas trees I think those are fairly exotic by the standards of most programmers - you won't meet them in your standard undergrad CS course IIRC.
Re:Exotic Data Structures (2011) by evincarofautumn on Tuesday July 11, 2017 @07:37AM (#14743266)
Seems like one possible implementation of std::deque, yeah. Dunno off the top of my head if the described implementation matches the requirements, though. IIRC C++ standard library implementations tend to use fixed-size chunks, except maybe the first and last chunks.
Re:Exotic Data Structures (2011) by wfunction on Tuesday July 11, 2017 @07:50AM (#14743333)
No, std::deque has O(n) space overhead... the goal here is to get that to O(sqrt(n)), and in the worst case too.
Re:Exotic Data Structures (2011) by mnarayan01 on Tuesday July 11, 2017 @09:38AM (#14744047)
Where are you getting O(sqrt(n)) space from? The linked article says O(n) for compact dynamic arrays.
Re:Exotic Data Structures (2011) by wuch on Tuesday July 11, 2017 @12:29PM (#14745510)
Note that the original article describes space complexity as "N + O(sqrt N)", i.e., there are N records and O(sqrt N) extra space.

Their data structure is considerably more complex than traditional implementations of std::deque, I wonder if it is actually of any practical interest.

Re:Exotic Data Structures (2011) by MichaelMoser123 on Tuesday July 11, 2017 @08:00AM (#14743396)
std::deque has the following constraints

  * Random access - constant O(1)
  * Insertion or removal of elements at the end or beginning - constant O(1)
  * Insertion or removal of elements - linear O(n)
Also in glibc/libstdc++ it is one https://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a015...
Re:Exotic Data Structures (2011) by wfunction on Tuesday July 11, 2017 @08:07AM (#14743427)
O(n) in my comment refers to space overhead. You're talking about time.
Re:Exotic Data Structures (2011) by MichaelMoser123 on Tuesday July 11, 2017 @07:32PM (#14748966)
[1] does not mention a linear space requirement, it mentions O(1) time for random access and removal of elements. Both major implementations implement std::deque in this way libstdc++ [2] and libc++ [3], but you say it can't be so. Well well.

[1] http://en.cppreference.com/w/cpp/container/deque

[2] https://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a015...

[3] https://github.com/llvm-mirror/libcxx/blob/master/include/de...

Re:Exotic Data Structures (2011) by wfunction on Tuesday July 11, 2017 @07:52PM (#14749074)
I don't get what you're arguing against, if anything. Can you make an actual claim and tell me where I'm wrong? Literally all I've been saying so far is that std::deque does not meet the O(sqrt n) space overhead of compact dynamic arrays. i.e.: yes it is more exotic than a mere std::deque, which is precisely the question you were asking and I was answering initially. So you're saying I'm wrong, or what? If you're saying I'm wrong, which implementation of std::deque do you think meets that overhead spec?
Re:Exotic Data Structures (2011) by MichaelMoser123 on Tuesday July 11, 2017 @07:59PM (#14749109)
"No, std::deque has O(n) space overhead... the goal here is to get that to O(sqrt(n))," implies that compact dynamic array can't be used for std::deque, when it is used as such, also I did not find a source that states this space requirement for std::deque in the first place.
Re:Exotic Data Structures (2011) by wfunction on Tuesday July 11, 2017 @08:07PM (#14749151)
...you were asking what's so "exotic" about compact dynamic arrays if they're just deques? I'm telling you they're not deques, because they have additional constraints that deques don't have.

Are you intentionally twisting this backwards or something? You're basically turning the conversation into something like this:

You: "Penguins are birds, right? What's so exotic about penguins when I see all these birds flying around me?"

Me: "Penguins live in Antarctica... and don't fly... (hence why people find them exotic...)"

You: "But who says birds can't live in Antarctica?? And chickens can't fly either. And penguins are birds. So what's so exotic about penguins?"

Me: {what sane response can I even give you here?!}

________________________________________

But anyway...

> implies that compact dynamic array can't be used for std::deque, when it is used as such

To entertain your new argument here:

Deque requires references to existing elements not to be invalidated when new elements are appended. I don't know how compact dynamic arrays work, but dynamic arrays generally move elements around in memory while maintaining guaranteed worst-case O(1)-time access to them, so it seems kind of impossible for them to meet both requirements.

Re:Exotic Data Structures (2011) by MichaelMoser123 on Tuesday July 11, 2017 @08:27PM (#14749223)
Where, where does it say that std::deque is supposed to have O(sqrt(n)) space requirement as worst case?
Re:Exotic Data Structures (2011) by wfunction on Tuesday July 11, 2017 @08:31PM (#14749241)
> Where, where does it say that std::deque is supposed to have O(sqrt(n)) space requirement as worst case?

Nowhere! Where did I even claim it said that anywhere?!

Re:Exotic Data Structures (2011) by jzwinck on Tuesday July 11, 2017 @08:08PM (#14749157)
No. std::deque is like a vector of small arrays. Small meaning 32 to 512 bytes or one T if larger. Compact dynamic arrays have sub-arrays which can be larger and can be dynamically sized.

The small fixed size of the sub-arrays in std::deque is basically a defect making the container a lot less useful.