CS 106B Study Guide - Midterm Guide: Parent Pointer Tree, Binary Search Tree, Hash Table

34 views7 pages

Document Summary

Based on handouts by eric roberts and jerry cain. One way to reverse the queue is to keep moving nodes out of the list one at a time to the front of the list. /* the head element becomes the tail. tail = head; /* continuously pull the element just after the head in front of the. Cell* curr = head; head = null; while (curr != null) { Cell* next = curr->link; curr->link = head; head = curr; curr = next; Here is one possible implementation of fillvector, which does a standard inorder walk of the tree to build up the collection of nodes in sorted order. Since each node is visited exactly once, this takes time. The rebuildtree function works recursively we build up the solution tree by recursively building up the left and right subtrees. A key detail is how we handle the case where we try to build up a tree out of an empty range.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents