CS 280 Data Structures - PowerPoint PPT Presentation

1 / 3
About This Presentation
Title:

CS 280 Data Structures

Description:

Professor John Peterson. Statics. Understanding how and when to use statics is a really ... Let's look at how to store sort functions into statics. heapify ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 4
Provided by: johnpe2
Learn more at: http://wiki.western.edu
Category:

less

Transcript and Presenter's Notes

Title: CS 280 Data Structures


1
CS 280Data Structures
  • Professor John Peterson

2
Statics
  • Understanding how and when to use statics is a
    really tough part of Java.
  • What situations does it make sense in to use
    static variables? Static final variables? A
    class with only static methods?
  • What is special about static vars/methods?
  • What are the rules of a static method?
  • Lets look at how to store sort functions into
    statics.

3
heapify
  • void heapify(int i, Sortable s, int n) // n is
    the limit of s
  • int l left(i) // 2i1
  • int r right(i) // 2i2
  • if (r lt n)
  • if (s.gtr(l, i) s.gtr(r, i))
  • if (s.gtr(l,r))
  • s.swap(i,l)
  • heapify(l,s,n)
  • else
  • s.swap(i,r)
  • heapify(r,s,n) //
    Missing in old slide
  • else if (l lt n)
  • if (s.gtr(l,i)) swap(i,l) //
    Bug in old slide
Write a Comment
User Comments (0)
About PowerShow.com