Lecture 16 Section 6.2 Thu, Mar 1, 2007

Slides:



Advertisements
Similar presentations
Stacks, Queues, and Linked Lists
Advertisements

Chapter 17 Linked List Saurav Karmakar Spring 2007.
Data Structures: A Pseudocode Approach with C
Linked Lists Compiled by Dr. Mohammad Alhawarat CHAPTER 04.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition Chapter 17: Linked Lists.
Queue using an array. .head.tail Pointers head and tail always point to the first empty slot before or after elements in the list. Thus, initially they.
CS 206 Introduction to Computer Science II 09 / 17 / 2008 Instructor: Michael Eckmann.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 17 Linked.
Queue, Deque, and Priority Queue Implementations Chapter 11 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Chapter 17: Linked Lists.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
1 Joe Meehean. 2  empty is the queue empty  size  enqueue (add) add item to end of queue  dequeue (remove) remove and return item at front of queue.
Linked Lists Chapter Introduction To The Linked List ADT Linked list: set of data structures (nodes) that contain references to other data structures.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
1 Chapter 24 Implementing Lists, Stacks, Queues, and Priority Queues Jung Soo (Sue) Lim Cal State LA.
Lecture 6 of Computer Science II
Review Array Array Elements Accessing array elements
Queues 5/11/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H.
Data Structure By Amee Trivedi.
Vectors 5/31/2018 9:25 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
CSCI-255 LinkedList.
Linked Lists Chapter 6 Section 6.4 – 6.6
Sequences 6/3/2018 9:11 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Linked List Stacks, Linked List Queues, Dequeues
Linked Lists Linked Lists 1 Sequences Sequences 07/25/16 10:31
COP3530- Data Structures Advanced Lists
Data Structures and Algorithms
Sequences 8/1/2018 4:38 AM Linked Lists Linked Lists.
Sequences 8/2/ :13 AM Linked Lists Linked Lists.
Sequences 8/2/ :16 AM Linked Lists Linked Lists.
EEL 4854 IT Data Structures Linked Lists
ENERGY 211 / CME 211 Lecture 12 October 17, 2008.
Queues Queues Queues.
Linked Lists with Tail Pointers
Lists.
LINKED LISTS CSCD Linked Lists.
CMSC 341 Lecture 5 Stacks, Queues
Queue, Deque, and Priority Queue Implementations
Circularly Linked Lists
Arrays and Linked Lists
Chapter 18: Linked Lists.
Sequences 11/27/2018 1:37 AM Singly Linked Lists Singly Linked Lists.
Queue and Priority Queue Implementations
Chapter 14: Queue and Priority Queue Implementations
Linked Lists.
Sequences 12/8/2018 3:02 AM Linked Lists Linked Lists.
11-3 LINKED LISTS A linked list is a collection of data in which each element contains the location of the next element—that is, each element contains.
Programming II (CS300) Chapter 07: Linked Lists and Iterators
Linked Lists with Tail Pointers
Doubly Linked Lists Lecture 21 Tue, Mar 21, 2006.
Chapter 24 Implementing Lists, Stacks, Queues, and Priority Queues
Doubly Linked List Implementation
Data Structures and Algorithms
Linked Lists in C and C++
Problem Understanding
Chapter 17: Linked Lists.
LINKED LISTS.
CS210- Lecture 5 Jun 9, 2005 Agenda Queues
Using a Queue Chapter 8 introduces the queue data type.
Using a Queue Chapter 8 introduces the queue data type.
CS210- Lecture 6 Jun 13, 2005 Announcements
Recursive Linked Lists
Programming II (CS300) Chapter 07: Linked Lists
Queues cont. Chapter 8 © 2011 Pearson Addison-Wesley. All rights reserved.
Stacks, Queues, and Deques
Recursive Linked Lists
CMPT 225 Lecture 5 – linked list.
Data Structures & Programming
Queue, Deque, and Priority Queue Implementations
Presentation transcript:

Lecture 16 Section 6.2 Thu, Mar 1, 2007 Array Lists Lecture 16 Section 6.2 Thu, Mar 1, 2007

List Implementation We will implement lists in a number of ways As an array Fixed head Circular As a linked list Singly linked Doubly linked Circularly linked

The ArrayList Class An array list is an implementation of the List ADT that uses an array to store the list elements. It is very similar to the Vectr class. Difference: The size is adjustable after the list has been constructed.

Data Members int mSize int capacity T* element The number of elements in the list. int capacity The number of array positions allocated. T* element A pointer to the first array element.

The List Elements The list elements a1, ..., amSize are stored in array positions element[0]through element[mSize - 1].

Validity Requirements capacity >= 0. mSize >= 0 and mSize <= capacity. If capacity == 0, then element == NULL. If capacity > 0, then element != NULL.

The ArrayList Class arraylist.h ListTest.cpp

Circular Array Lists A circular array list is like an ordinary array list, except that the elements may wrap around the ends of the array. This makes it much more efficient to add and remove elements from the front end of the list.

Circular Array Lists Dynamics Begin with an empty list.

Circular Array Lists Dynamics Add six elements at the tail (back). 10

Circular Array Lists Dynamics Add six elements at the tail (back). 10 45

Circular Array Lists Dynamics Add six elements at the tail (back). 10 45 25

Circular Array Lists Dynamics Add six elements at the tail (back). 10 45 25 90

Circular Array Lists Dynamics Add six elements at the tail (back). 10 45 25 90 15

Circular Array Lists Dynamics Add six elements at the tail (back). 10 45 25 90 15 40

Circular Array Lists Dynamics Delete three elements from the head (front). 45 25 90 15 40

Circular Array Lists Dynamics Delete three elements from the head (front). 25 90 15 40

Circular Array Lists Dynamics Delete three elements from the head (front). 90 15 40

Circular Array Lists Dynamics Add one element at the head (front). 60 90 15 40

Circular Array Lists Dynamics Add six elements at the tail (back). 60 90 15 40 65

Circular Array Lists Dynamics Add six elements at the tail (back). 60 90 15 40 65 90

Circular Array Lists Dynamics Add six elements at the tail (back). 60 90 15 40 65 90 35

Circular Array Lists Dynamics Add six elements at the tail (back). 60 90 15 40 65 90 35 20

Circular Array Lists Dynamics Add six elements at the tail (back). 50 60 90 15 40 65 90 35 20

Circular Array Lists Dynamics Add six elements at the tail (back). 50 80 60 90 15 40 65 90 35 20