Docsity

Lecture Notes on Priority Queue ADT | COMP SCI 367, Study notes of Data Structures and Algorithms

Toggle sidebar
bg1
Copyright 2014 Jim Skrentny CS 367 L14 - 1
CS 367 Announcements
Thursday, March 6, 2014
Homework h5 assigned tomorrow
Program p2 due 10 pm Sunday, March 9th
• submit java files to your “in” directory
• make sure to name your source files as specified in th submission section
• verify that you’ve submitted the correct files (ls, more, javac, java)
• partners? only ONE submits source but BOTH submit README.txt
Program p3 assigned this weekend
Last Time
• exam mechanics
• sample questions
• Q&A
Today
Priority Queue ADT
• concept
• operations
• implementation options
Trees Intro
Heap Data Structure
• concept
• heap implementations & complexity
Next Time
Recursion
• recursion vs. iteration
• call stack tracing
• writing recursive code
• execution tree tracing
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Lecture Notes on Priority Queue ADT | COMP SCI 367 and more Study notes Data Structures and Algorithms in PDF only on Docsity!

Thursday, March 6, 2014^ CS 367 Announcements

Homework h5 assigned tomorrow Program p2 due 10 pm Sunday, March 9th • submit java files to your “in” directory

  • • make sure to name your source files as specified in th submission sectionverify that you’ve submitted the correct files (ls, more, javac, java)

Program p3 assigned this weekend^ •^ partners? only ONE submits source but BOTH submit README.txt Last Time • exam mechanics

  • • sample questionsQ&A

Today Priority Queue ADT

  • • conceptoperations
  • Trees Intro implementation options Heap Data Structure • concept
  • heap implementations & complexity Next Time Recursion
  • • recursion vs. iterationcall stack tracing
  • • writing recursive codeexecution tree tracing

Priority Queue ADT

Priorities

Concept

Operations

Options for Implementing a Priority Queue ADT

data structure insert^ removeMax^ notes

unordered array

ordered array

chain of nodes^ unordered

chain of nodes^ ordered

Tree Terminology

  1. Which is the root?
  2. How many leaves are there?
  3. How many nodes are in the right branch/subtree of B?
  4. Which is the parent of G?
  5. How many children does E have (degree of E)?
  6. Which is the sibling of E?
  7. How many descendants does B have?
  8. What are the ancestors of C?
  9. What is the length of the path from B to D?
  10. What is the height of the tree?
  11. What is the depth/level of J?

A B C D

E

F

G

H

J I

Inserting into a Max Heap

Algorithm

Given the following max heap:

 Show the heap after inserting 36:

 Show the heap after inserting 57:

Inserting into a Max Heap (cont.)

Heap Class Instance Variables: privateprivate Comparable[]int nextLoc; items;

Pseudo-code public void insert(Comparable data) {

Complexity