4
votes
Accepted
Are self-written queues and linked lists really worth it (better than built-in arrays)?
Will a proper dynamic data structure be more efficient than simulating it with fixed-size arrays? Almost certainly yes. But is it a good idea to build one for your project? This depends on many other ...
4
votes
Accepted
How to properly delete nodes in a linked list?
Almost there! You have a linked list:
HEAD ---> P ---> x ---> x ---> Q ---> TAIL
You re-link part of the list (HEAD -> TAIL) to remove some nodes:
HEAD ------------------------------...
4
votes
Accepted
How to store a branching linked list in a database
Two Tables
A table of things, and a table of connections.
Things := (Component ID | usefull stuff to know about the thing itself | etc)
Connections := (Connection Type | From Component | From Port | ...
3
votes
Accepted
How to safely walk a list to remove an element as well as associated elements safely
The bug is caused by a (somewhat) complex interaction between:
SLIST_FORACH_SAFE, and the recursive invocation of destroy_element, and the removal that they each do.
SLIST_FOREACH_SAFE makes itself "...
3
votes
Accepted
Linked-list iteration patterns
Caching effects are difficult to predict. In general, contiguous memory data structures like arrays of values are more cache friendly, but does this matter? Not for most code.
For the purpose of ...
3
votes
Designing an efficient implementation of a random access queue based on a linkedlist
Sorry for the late answer but I think this will give O(1) insertion, removal and random access.
Store the linked list nodes in a pre-allocated array.
Addition involves adding the new node to the ...
2
votes
Converting binary tree into doubly linked circular list
The reason that multiple data structures exist is (and there isn't any one single data structure to rule them all) is because each data structure has different performance characteristics.
It follows ...
1
vote
Accepted
Inserting at head for a recursively defined linked list
The insert and __delitem__ methods of MutableSequence ABC are expected to do an in-place modification of the sequence you call them on.
This means that code like this should work
len(sequence) == 1
...
1
vote
Why do we need stacks and queues?
Echoing @rwong comment, using a Queue or Stack
Documents the contract
Is a better name - might avoid the need for a comment
Makes your intentions clear.
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
linked-list × 38data-structures × 13
java × 9
c × 5
list × 5
algorithms × 4
recursion × 4
c++ × 3
array × 3
design × 2
architecture × 2
trees × 2
collections × 2
queue × 2
design-patterns × 1
object-oriented × 1
programming-practices × 1
programming-languages × 1
database-design × 1
performance × 1
functional-programming × 1
coding-standards × 1
language-agnostic × 1
data × 1
history × 1