Data Structures

CSCI 1913 – Introduction to Algorithms, Data Structures, and Program Development
Adriana Picoral

Data Structures

A data structure is an object that is also an algorithm:

  • As an object it represents a data storage tool
  • Provides standard interfaces for logical manipulations
  • Basic data structure “algorithms” will be simple
  • Advanced data structure methods hide deep complexity

Abstract Data Type

Abstract Data Type: A general description of behaviors

  • List
    • Stack (Last-In, First-Out)
    • Queue (First-In, First-Out)
    • Deque (Double-Ended Queue)
  • Set (unordered collection of unique elements)
  • Bag (unordered collection that allows repeated elements)
  • Map/Dictionary

Java’s data structures

  • List
    • ArrayList
    • LinkedList
  • Set
    • TreeSet
    • HashSet
  • Map (java’s dictionary)
    • TreeMap
    • HashMap

Java’s data structures

  • Stack
    • Stack
  • Queue
    • ArrayDeque (can also be used for a stack)
    • LinkedList
  • Deque
    • ArrayDeque

We will build our own abstract Data Structures

Steps for building a data structure

Fully understand the data structure you’re implementing

  • Plan out, in the abstract, the “object nature” and what behaviors you need to support
  • Write some example/test code

Plan out private data and how it’s organized

  • This is where the “algorithm” lives
  • Plan should connect each method
  • Methods will depend on each other
  • Then plan out the algorithm