CSC 212 - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

CSC 212

Description:

Key completes the first word (donkey) and a key starts a car. List ADT. Accesses all elements in a Collection. Can access all elements without removals ... – PowerPoint PPT presentation

Number of Views:17
Avg rating:3.0/5.0
Slides: 10
Provided by: wwwcsCa
Category:
Tags: csc | donkey

less

Transcript and Presenter's Notes

Title: CSC 212


1
CSC 212 Data Structures
  • Lecture 24
  • Sequences and Collections

2
Question of the Day
  • What three letter word completes the first word
    and starts the second one
  • DON ??? CAR
  • Key completes the first word (donkey) and a key
    starts a car

3
List ADT
  • Accesses all elements in a Collection
  • Can access all elements without removals
  • set added to accessors and removals
  • Lists are Iterable
  • Provide Iterator to loop through its element
  • Differ in how they provide access
  • IndexList access via integer ranks
  • PositionList access via relative Position
  • Want method to merges approaches

4
Sequences
  • Combine IndexList and PositionList ADTs
  • Can discuss relative location of data
  • Can also use numerical ranks
  • Also converts between the two
  • Returns Position at a given rank
  • Gets the rank for a given Position

5
Sequence Interface
  • public interface SequenceltGgt extends
    IndexListltGgt, PositionListltGgt,
    DequeltGgt public PositionltGgt atRank(int r)
    throws BoundaryViolationExceptionpublic int
    rankOf(PositionltGgt p) throws InvalidPositionExcept
    ion
  • Includes all methods from 3 interfaces
  • Converts between rank and Position
  • Implementation still not defined
  • But must include Positions

6
Sequences Applications
  • Basic, general-purpose, data structure
  • Useful for storing collection of elements
  • Collections can be ordered or unordered
  • Often used as basis of other data structures
  • Can be used to implement stack, queue, deque, or
    list
  • Also used for small, simple databases
  • Basic building block of many other structures
  • Many (though not all) use a Sequence somewhere
  • Javas collections are derived from Sequences

7
Linked list-based Sequence
  • May/may not use special header trailer nodes
  • Node class implements Position
  • Position-based calls run in constant time
  • Rank-based methods search through list

Nodes/Positions
elements
8
Array-based Sequence
elements
  • Use array in circular manner
  • Array entries contains class
  • Implements Position
  • Also stores rank

0
1
2
3
positions
S
l
f
9
Your Turn
  • Get back into groups and do activity

10
Before Next Lecture
  • Keep up with your reading!
  • Continue Week 10 Assignment
  • Work on Programming Assignment 2
Write a Comment
User Comments (0)
About PowerShow.com