Data Structures and Java Collections - Lecture Slides | CMSC 132, Study notes of Computer Science

Data Structures Material Type: Notes; Class: OBJECT-ORIENTED PROG II; Subject: Computer Science; University: University of Maryland; Term: Unknown 2007;

Typology: Study notes

Pre 2010

Uploaded on 02/13/2009

koofers-user-ufa-1
koofers-user-ufa-1 🇺🇸

5

(1)

10 documents

1 / 16

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CMSC 132:
Object-Oriented Programming II
Data Structures & Java
Collections
Department of Computer Science
University of Maryland, College Park
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Data Structures and Java Collections - Lecture Slides | CMSC 132 and more Study notes Computer Science in PDF only on Docsity!

CMSC 132:

Object-Oriented Programming II

Data Structures & Java

Collections

Department of Computer Science

University of Maryland, College Park

Collection

Programs represent and manipulate abstractions

(chunks of information)

Examples: roster of students, deck of cards

One of the most universal abstractions is a collection

Represents an aggregation of multiple objects Different kinds of collections

Examples: list, set, ordered set, map, array, tree Supporting different operations on data

Data Structures Taxonomy

Classification scheme for data structures

Based on relationships between element

Category

Relationship

Linear

one

one

Hierarchical

one

many

Graph

many

many

Set

none

none

Linear Data Structures

One-to-one relationship between elements

Each element has

unique

predecessor

Each element has

unique

successor

Hierarchical Data Structures

One-to-many relationship between elements

Each element has

unique

predecessor

Each element has

multiple

successors

Example Hierarchical Data Structures

Tree

Single root

Forest

Multiple roots

Binary tree

Tree with 0–2 children per node

Tree

Binary Tree

Example Graph Data Structures

Undirected graph

Undirected edges

Directed graph

Directed edges

Directed acyclic graph (DAG)

Directed edges, no cycles

Undirected

Directed

DAG

Set Data Structures

No relationship between elements

Elements have

no

predecessor / successor

Only

one

copy of element allowed in set

Set B

Set C

Set A

Java Collection Framework (JCF)

Java provides several interfaces and classesfor manipulating & organizing data

Example: List, Set, Map interfaces

Java Collection

Framework

consists of

Interfaces

Abstract data types

Implementations

Reusable data structures

Algorithms

Reusable functionality

Collection Hierarchy

Collection vs. Collections

Collection

Interface Root interface of collection hierarchy Methods: add( ), contains( ), remove( ), size( )

Collections

Class Contains static methods that operate on collections Methods: shuffle( ), copy( ), list( )