bubble sort in linked list....(java version)
2012-01-28 22:06
281 查看
public void swap(customerNode pre, customerNode cur) { customer temp = pre.item.clone(); pre.item = cur.item.clone(); cur.item = temp.clone(); } customerNode bubble(customerNode phead, int len) { customerNode ptr, next; int temp; for (int i = 0; i < len; i++) { ptr = phead; next = ptr.next; for (int j = 0; j < len - i - 1; j++) { if (ptr.item.getId() > next.item.getId()) { swap(ptr, next); } ptr = ptr.next; next = next.next; } } return phead; }
相关文章推荐
- [LeetCode-237]Delete Node in a Linked List(java)
- Sort a linked list in O(n log n) time using constant space complexity.
- Delete Node in a Linked List Java LeetCode
- Sort a linked list in O(n log n) time using constant space complexity.
- leetcode算法——237. Delete Node in a Linked List(基于JAVA)
- leetcode Sort a linked list in O(n log n) time using constant space complexity.
- Sort a linked list in O(n log n) time using constant space complexity.
- Leetcode:237. Delete Node in a Linked List(JAVA)
- leetcode237 Delete Node in a LinkedList java
- leetcode_Sort a linked list in O(n log n) time using constant space complexity.
- 单链表反转的递归实现(Reversing a Linked List in Java, recursively)
- leetcode:Delete Node in a Linked List 【Java】
- 单链表反转的递归实现(Reversing a Linked List in Java, recursively)
- Sort a linked list in O(n log n) time using constant space complexity.
- 【Leetcode】Reverse Linked List II in JAVA
- Leetcode oj java Delete Node in a Linked List
- 【DataStructure&AlgorithmInJava】Ch05-LinkedListDemo1
- 【leetcode】Delete Node in a Linked List【java】
- Delete Node in a Linked List(java)
- LeetCode-237. Delete Node in a Linked List(Java)