Slippery Rock University Dr. Deborah Whitfield Go Browns!

Chapter 2: Arrays
Data Structures and Algorithms in Java
CpSc 374

Arrays

Java Specifics


Ordered Arrays

Implementation of an API (Application Programming Interface)

  • ADT --> API --> App --> End User
  • Create a class
  • Write methods: constructer, insert, delete, find… others?
    Typically no fill operation - that's for demos
  • How "costly" are the operations you coded?

  • Algorithm Analysis

    Time Required for array operations?

    Logarithms

    Big O notation

    The Good, Bad and Ugly of O( )
    • Constant O(1)
    • Log O(log N)
    • Linear O(N)
    • Polynomial
      Quadratic O(N2)
      Cubic O(N3),...
    • Exponential O(CN)

    Constants and Small N
    • Note that O(5N) is worse than O(N2) for 0 < N < 5
    • Even O(6) is worse than O(N2) for 0 < N < 3
    • But that's not the "big picture"

    Asymptotic Behavior and Large n


    Wrap Up