Monthly Archives: May 2016

  1. Do not sort a linked list

    Leave a comment

    May 18, 2016 by oneOokay

    Why would it be a bad idea to sort a linked list? A few things come to mind: To locate …
    Continue reading

  2. 173. Insertion Sort List

    Leave a comment

    May 18, 2016 by oneOokay

    public ListNode insertionSortList(ListNode head) { ListNode dummy = new ListNode(0);  // here we dont need dummy.next = head, it is …
    Continue reading

  3. Sort LinkedList – QuickSort(TODO)

    Leave a comment

    May 18, 2016 by oneOokay

  4. Sorting Algorithms – step by step videos

    Leave a comment

    May 18, 2016 by oneOokay

    >>>Charmander<<< Quick Sort – step by step Recursive Pivot divides array into two parts (pivot usually is not the middle …
    Continue reading

  5. LinkedList

    Leave a comment

    May 17, 2016 by oneOokay

    >>>Venusaur<<< LinkedList 非常非常基础,一定要知道哟 ListNode: 实际上是存储的是一个reference,物理地址,4字节 (像一个信封) ListNode.val 4字节 && ListNode.next 4字节 当一个listnode被读取的时候:系统按照listnode存储的地址(信封上的地址)找到物理地址 当读取listnode.val的时候,读取地址的接下来的4个字节,为value 当读取listnode.next的时候,读取地址的接下来的5-8字节,为listnode.next的地址 不建议画链表: 1 -> 2 -> 3 …
    Continue reading

  6. Convert Sorted List to BST

    Leave a comment

    May 17, 2016 by oneOokay

    Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 基本上有两种想法:1.是找到中点recursively构建BST;2.用inorder …
    Continue reading

  7. 98. Sort List – Merge Sort nlogn

    Leave a comment

    May 16, 2016 by oneOokay

    >>>Bulbasaur<<< Sort a linked list in O(n log n) time using constant space complexity.   Merge Sort [O(nlogn)] Step1: Get the middle list node …
    Continue reading