# algorithm « LinkedList « Java Collection Q&A

Home
Java Collection Q&A
 1 algorithm 2 array 3 Array Byte 4 Array Char 5 Array Convert 6 Array Dimension 7 Array Integer 8 Array Object 9 Array String 10 ArrayList 11 collection 12 comparator 13 Development 14 Garbage Collection 15 Generic 16 hash 17 HashMap 18 HashTable 19 iterator 20 LinkedList 21 List 22 Map 23 queue 24 Set 25 Sort 26 tree
 Java Collection Q&A » LinkedList » algorithm

### 1. What is an efficient algorithm to find whether a singly linked list is circular/cyclic or not?    stackoverflow.com

How can i find whether a singly linked list is circular/cyclic or not? I Tried searching but couldn't find a satisfactory solution. If possible, can you provide pseudocode or Java? For Example ...

### 2. Java How to find a value in a linked list iteratively and recursively    stackoverflow.com

I have a method that has a reference to a linked list and a int value. So, this method would count and return how often the value happens in the linked ...

### 3. Interview question: How to detect a loop in a linked list?    stackoverflow.com

Say you have a linked list structure in Java. It's made up of Nodes:

``````class Node {
Node next;
// some user data
}
``````
and each Node ...

### 4. LinkedList.contains execution speed    stackoverflow.com

Why Methode LinkedList.contains() runs quickly than such implementation:

``````for (String s : list)
if (s.equals(element))
return true;
return false;
``````
I don't see great difference between this to ...

### 5. sorting a doubly linked list with merge sort    stackoverflow.com

Hi I have found this code in the internet and it was for arrays ,I want to change it for doubly linked list(instead of index we should use pointer) would you please ...

### 6. Java: Good algorithm for removing an element from a linked list?    stackoverflow.com

I have a pretty basic question here. I am implementing a few operations on a linked list as an exercise. One such operation is removal:

``````/**
* Removes the element at index.
...``````

### 7. Interview: Find similar elements from two linked lists and return the result as a linked list    stackoverflow.com

This question was asked in an interview for my friend. The interviewer asked to find algorithm and code it in Java Question : Find similar elements from two linked lists and return ...

### 8. Invert linear linked list    stackoverflow.com

a linear linked list is a set of nodes. This is how a node is defined (to keep it easy we do not distinguish between node an list):

``````class Node{
...``````

### 9. split a linked list into 2 even lists containing the smallest and largest numbers    stackoverflow.com

Given a linked list of integers in random order, split it into two new linked lists such that the difference in the sum of elements of each list is maximal and ...

### 10. I need help coding a linkedlist    stackoverflow.com

I am learning Java linked list to be precise. I have been working on it for about a week now but I have hit a brick wall. I need add and ...

### 11. insertion-sort on doubly linked list    stackoverflow.com

Here is an attempt to write an insertion-sort function for a doubly linked list (DLL). It is modelled on insertion-sort as known for arrays. I get a `NullPointerException`. why? ...

### 12. base case for recursive quick-sort on singly linked list    stackoverflow.com

I'm trying to get my head around a recursive quick-sort on a singly linked list. What is the base case and what do i need to do when i reach it ...

### 13. algorithm for implementing DFA as a linked list    stackoverflow.com

I want to know how to implement a DFA as a linked list in C/C++/Java.

### 14. Implementing a binary heap using a linked list    stackoverflow.com

Possible Duplicate:
Linked list implementation of Binary Min Heap (Having trouble with manipulation…)
Greetings, I'm having trouble figuring out an algorithm that will give me the location ...

### 15. Delete/free a linked list node in Java. Suggestion please    stackoverflow.com

All, If I were to write a function to delete a node (given headNode and data as input parameters) from a linkedList in Java. I would find the node that has "node.data=data", ...

### 16. Immutable / persistent list in Java    stackoverflow.com

As a pet project I'm trying to implement an immutable list data structure in Java while minimizing copies as much as possible; I know about Google Collections but this is not ...

### 17. Big O notation For accessing middle element in linked list and binary search?    stackoverflow.com

Article at http://leepoint.net/notes-java/algorithms/big-oh/bigoh.html says that Big O notation For accessing middle element in linked list is O(N) .should not it be O(N/2) .Assume we have 100 elements in linked ...

### 18. Why does a hashtable degenerate into a Linked List when a hashcode() implementation returns a constant value?    stackoverflow.com

``````// The worst possible legal hash function - never use!
@Override public int hashCode() { return 42; }
``````
Itâ€™s legal because it ensures that equal objects have the same hash code. ...