Is there any doubly linked list implementation in Java?

Yes, LinkedList is a doubly linked list, as the Javadoc mentions : Doubly-linked list implementation of the List and Deque interfaces. Implements all optional list operations, and permits all elements (including null). All of the operations perform as could be expected for a doubly-linked list. Operations that index into the list will traverse the list … Read more

How to apply binary search O(log n) on a sorted linked list?

It is certainly not possible with a plain singly-linked list. Sketch proof: to examine the last node of a singly-linked list, we must perform n-1 operations of following a “next” pointer [proof by induction on the fact that there is only one reference to the k+1th node, and it is in the kth node, and … Read more

Deleting a middle node from a single linked list when pointer to the previous node is not available

It’s definitely more a quiz rather than a real problem. However, if we are allowed to make some assumption, it can be solved in O(1) time. To do it, the strictures the list points to must be copyable. The algorithm is as the following: We have a list looking like: … -> Node(i-1) -> Node(i) … Read more

Efficient linked list in C++?

Your requirements are exactly those of std::list, except that you’ve decided you don’t like the overhead of node-based allocation. The sane approach is to start at the top and only do as much as you really need: Just use std::list. Benchmark it: is the default allocator really too slow for your purposes? No: you’re done. … Read more

Why is a LinkedList Generally Slower than a List?

Update (in response to your comment): you’re right, discussing big-O notation by itself is not exactly useful. I included a link to James’s answer in my original response because he already offered a good explanation of the technical reasons why List<T> outperforms LinkedList<T> in general. Basically, it’s a matter of memory allocation and locality. When … Read more