3-11-1

# 3-11-1 - Problem Solving with Computers-II CS 24 1...

This preview shows pages 1–11. Sign up to view the full content.

Problem Solving with Computers-II CS 24 March 11, 2010 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Announcements Deadlines Lab 9: Friday 5 pm Programming project & extra credit: Sunday 5 pm Final Wed March 17, 8-11 am Final review Tuesday 3/16 6-8 HFH 1132 (Harry) Office hours Monday 3/15 5-7 pm (Saiph) Topics/format posted coming weekend Allowed one sheet of paper 2
Recap Tree and BST ADT Recursive implementations Iterative implementations Heap Priority queue What is the difference? 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Lecture Plan Discussion of Stack model Exception Course review Instructor & course survey 4
5 ReheapDown ReheapDown(int root, int bottom) { int maxChild ; int rightChild ; int leftChild ; leftChild = root * 2 + 1 ; rightChild = root * 2 + 2 ;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 ReheapDown (contd.) if (leftChild <= bottom) //otherwise, no need to Reheap { if (leftChild == bottom) maxChild = leftChild; else { if (elements[leftChild] <= elements[rightChild]) maxChild = rightChild; else maxChild = leftChild; }; if (elements[root] < elements[maxChild]) { Swap(elements[root], elements[maxChild]); ReheapDown(maxChild, bottom); } } }
7 Restoring order property

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
8 ReheapDown ReheapDown(int root, int bottom) { int maxChild ; int rightChild ; int leftChild ; leftChild = root * 2 + 1 ; rightChild = root * 2 + 2 ;
9 ReheapDown (contd.) if (leftChild <= bottom) //otherwise, no need to Reheap { if (leftChild == bottom) maxChild = leftChild; else { if (elements[leftChild] <= elements[rightChild]) maxChild = rightChild; else maxChild = leftChild; }; if (elements[root] < elements[maxChild]) { Swap(elements[root], elements[maxChild]); ReheapDown(maxChild, bottom); } } }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Exception An exception is a unusual, often unpredictable  event,  detectable by software  or hardware , that requires
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 05/26/2010 for the course CS cs24 taught by Professor Singh during the Winter '10 term at UCSB.

### Page1 / 30

3-11-1 - Problem Solving with Computers-II CS 24 1...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online