
























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: OBJECT-ORIENTED PROG II; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;
Typology: Study notes
1 / 32
This page cannot be seen from the preview
Don't miss anything!

























Overview
General properties
Array Linked list
Stack Queue
Linear Data Structures
Head (first element in list)
no predecessor Tail (last element in list)
no successor
Add element Remove element Find element
Add & Remove Elements
Where? At head (front) of list At tail (end) of list After a particular element
Remove first element Remove last element Remove a particular element (e.g., String “Happy”) What if “Happy” occurs more than once in list?
List Implementations
Store elements in an array Store as a linked list Place each element in a separate object (node) Node contains reference to other node(s) Link nodes together
Linked List
Elements in linked list are ordered Element has successor
Head Tail Cursor (current position) HeadTail Cursor
Linked Implementation
Can efficiently insert / remove elements anywhere
Cannot efficiently access element at any position Need to traverse list to find element Less efficient use of space 1-2 additional references per element
Efficiency of Operations
Insertion / deletion = O( n
Indexing = O(
Insertion / deletion = O(
Indexing = O( n
Linked List – Insert (After Cursor)
Linked List – Delete (Cursor)
Doubly Linked List
Element has predecessor
successor
Easy to find preceding / succeeding elements Extra work to maintain links (for insert / delete) More storage per node
Doubly Linked List – Insertion
Restricted Abstractions
Efficiently supporting only a few operationsefficiently is easier If limited abstraction is sufficient, easier to reasonabout limited abstraction than a more general one
Stack (aka LIFO queue) Queue (aka FIFO queue) Dequeue (aka double ended queue)
Stack
Push = add element (to top) Pop = remove element (from top)