Mike Simmons wrote:Yes.
Dylan Kwon wrote: They have a set order and can be sorted, so they are sequential,
In data structures, a data structure is said to have sequential access if one can only visit the values it contains in one particular order.
Dylan Kwon wrote:and they have indices that allow you to access their elements in random order, so are they also indexed?
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
Paul Anilprem wrote:So, you see, these two things are contradictory. If a data structure is indexed, it cannot be sequential.
... if one can only visit the values it contains in one particular order.
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
Stephan van Hulst wrote:I'm not arguing the definition you used for the word "sequential".
I'm arguing that this definition does not preclude a "sequential collection" from being "indexed".
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
Indexing into a list that has sequential access requires O(n) time, where n is the index.
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
Paul Anilprem wrote:A linked list is indeed sequential because it provides only one way (sequential) access.
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
That is an implementation detail, but I think it is a subtype of Iterator called ListIterator. Another implementation detail: that linked list is doubly linked.Tim Holloway wrote:. . . the Java LinkedList class defines a descendingIterator . . .
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
According to your interpretation of the definition given in the cited Wikipedia article, it just stops being a sequential data structure, even though nothing in the inner workings of the class has changed?
I don't think such a definition would be useful, and I don't think your interpretation is correct.
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
wikipedia wrote:There is no consistent definition in computer science of sequential access or sequentiality.
wikipedia wrote:In data structures, a data structure is said to have sequential access if one can only visit the values it contains in one particular order.
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
Tim Holloway wrote:
wikipedia wrote:There is no consistent definition in computer science of sequential access or sequentiality.
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
Paul Anilprem wrote:The data structure that the world see is SimpleLinkedList (not the "inner workings" part) and adding the method to provide indexed access does change SimpleLinkedList. It is no more a sequential data structure and shouldn't be treated as such.
May be my interpretation is incorrect, but I am not sure what is your interpretation of "one can only visit the values it contains in one particular order".
Stephan van Hulst wrote:
That makes absolutely no sense. Adding a method called get(index) does not magically make its elements accessible in a random-access fashion.
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
Tim Holloway wrote:If a List truly wants to forbid random access, then it should overide and throw an UnimplementedMethodException.
Certain methods are specified to be optional. If a collection implementation doesn't implement a particular operation, it should define the corresponding method to throw UnsupportedOperationException. Such methods are marked "optional operation" in method specifications of the collections interfaces.
Paul Anilprem wrote:
Yes, I already acknowledged that in an earlier post and I too am curious to know a better definition of sequential
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
Paul Anilprem wrote:Whenever you access all the elements of a data structure, you access them in some sequence!
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
Tim Holloway wrote:
Stephan van Hulst wrote:That makes absolutely no sense. Adding a method called get(index) does not magically make its elements accessible in a random-access fashion.
Well, actually, it does.
Doesn't mean that it will make them accessible in a performant fashion, but by definition it does provide random access. No matter how slow.
Mike Simmons wrote:
Well, get(int) is not marked as optional in the API.
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
Tim Holloway wrote:
Paul Anilprem wrote:Whenever you access all the elements of a data structure, you access them in some sequence!
Untrue. I'd refer you to my copy of "Content-Addressable Parallel Processors", but it's probably long out of print. Von Neumann isn't the only way to compute, and in fact, the reason why accelerated graphics cards have become so popular is precisely because they can take a thousand processors and operate them in parallel.
And no, I don't always access elements of a collection using the same sequencer. There's a difference between having a sequence and accessing sequentially. You can access a collection sequentially any way that you like as long as there is at least one way to relate all the nodes in the collection in a consistent manner. It is the Collection that's madatimg a primary iteration sequence, not the concept of collections as a whole.
A Collection is not a data structure, by the way. At best, you may have an object ("data structure") that anchors (or at least taps into) a collection, but again, that's not an abstract requirement.
You can see access to all elements of a data structure in the "new" Java Streams facility. They define operations over a collection in a context-free way, making it possible for massively-parallel processors to do their work without ever sequencing anything. There is already logic in there to facilitate that.
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
It's never done THAT before. Explain it to me tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|