1 / 7

Lab 6 Recap, Sorting, BST Removal

Lab 6 Recap, Sorting, BST Removal. Bryce Boe 2013/08/ 08 CS24, Summer 2013 C. Outline. Lab 6 Recap / Sorting BST Node Removal. O(n 2 ) Sorting Algorithms. Bubble sort Bubble the largest element to the end in each pass Insertion sort

mauve
Download Presentation

Lab 6 Recap, Sorting, BST Removal

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab 6 Recap, Sorting, BST Removal Bryce Boe 2013/08/08 CS24, Summer 2013 C

  2. Outline • Lab 6 Recap / Sorting • BST Node Removal

  3. O(n2) Sorting Algorithms • Bubble sort • Bubble the largest element to the end in each pass • Insertion sort • Insert the next element into the sorted portion of the list • Selection sort • Find the smallest item and put it in its proper location

  4. O(nlog(n)) Sort Algorithms • Merge Sort • Break the problem up until you have 1 or 2 items and put them in order • Merge the sorted lists O(k) where k is the size of the small lists • T(n) = 2T(n/2) + O(n) === O(n*log(n)) (masters theorem)

  5. BST Remove • If the node has no children simply remove it • If the node has a single child, update its parent pointer to point to its child and remove the node

  6. Removing a node with two children • Replace the value of the node with the largest value in its left-subtree (right-most descendant on the left hand side) • Then repeat the remove procedure to remove the node whose value was used in the replacement

  7. Removing a node with two children

More Related