CSCI 62 Data Structures Dr. Joshua Stough September 25, 2008.

Slides:



Advertisements
Similar presentations
Chapter 3 Lists Dr Zeinab Eid.
Advertisements

Queues and Linked Lists
Linear Lists – Linked List Representation
Chapter 24 Lists, Stacks, and Queues
Linked List 1. Introduction to Linked List 2. Node Class 3. Linked List 4. The Bag Class with Linked List.
1 Array-based Implementation An array Q of maximum size N Need to keep track the front and rear of the queue: f: index of the front object r: index immediately.
Data Structure Lecture-5
David Weinberg presents Linked Lists: The Background  Linked Lists are similar to ArrayLists in their appearance and method of manipulation  They do.
Chapter 6 The Collections API. Simple Container/ Iterator Simple Container Shape [] v = new Shape[10]; Simple Iterator For( int i=0 ; i< v.length ; i++)
Doubly Linked Lists. One powerful variation of a linked list is the doubly linked list. The doubly linked list structure is one in which each node has.
Queues 4/14/2017 5:24 PM 5.2 Queues Queues Dr Zeinab Eid.
Chapter 6 Linked Structures © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
Linked list More terminology Singly-linked lists Doubly-linked lists DLLs compared to SLLs Circular Lists.
Lecture 8 CS203. Implementation of Data Structures 2 In the last couple of weeks, we have covered various data structures that are implemented in the.
Linked Lists Dr. Tim Margush University of Akron © 2009.
1 Chapter 24 Lists Stacks and Queues. 2 Objectives F To design list with interface and abstract class (§24.2). F To design and implement a dynamic list.
Data Structures & Algorithms
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.
Stacks, Queues & Deques CSC212.
List class.head NULL _class Cell { void *object; Cell *next; public:... } _class List { Cell *head; public:... }
COMP 110 Introduction to Programming Mr. Joshua Stough.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 26 Implementing Lists, Stacks,
CSC 212 – Data Structures Lecture 21: IndexList a/k/a Vector, ArrayList.
Chapter 101 Dynamic Data Structures and Generics Chapter 10.
CS 206 Introduction to Computer Science II 09 / 19 / 2008 Instructor: Michael Eckmann.
CSE 131 Computer Science 1 Module 9: Linked Lists Using references to link objects Basic operations on linked lists Implementing a linked list of integers.
Lecture 14 Linked Lists 14-1 Richard Gesick. Linked Lists Dynamic data structures can grow and shrink at execution time. A linked list is a linear collection.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. 1 Chapter 18 Linked Lists, Stacks, Queues, and Priority Queues.
HIT2037- HIT6037 Software Development in Java 22 – Data Structures and Introduction.
CSCI 62 Data Structures Dr. Joshua Stough September 2, 2008.
Information and Computer Sciences University of Hawaii, Manoa
COP INTERMEDIATE JAVA Data Structures. A data structure is a way of organizing a collection of data so that it can be manipulated effectively. A.
4-1 Topic 6 Linked Data Structures. 4-2 Objectives Describe linked structures Compare linked structures to array- based structures Explore the techniques.
Today’s Agenda  Linked Lists  Double ended Linked Lists  Doubly Linked Lists CS2336: Computer Science II.
Cousin of the Stack.  An abstract data type (container class) in which items are entered at one end and removed from the other end  First In First.
Stacks and Queues. Announcements USACO Open competition results are out o Congrats to Johnny for scoring 2nd in the US USACO Finalists are also announced.
Linked Lists part 1 CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University.
APS105 Lists. Structures Arrays allow a collection of elements –All of the same type How to collect elements of different types? –Structures; in C: struct.
Winter 2006CISC121 - Prof. McLeod1 Stuff Deadline for assn 3 extended to Monday, the 13 th. Please note that the testing class for assn 3 has changed.
Subject Name : Data Structure Using C Title : Linked Lists
1 CMPSCI 187 Computer Science 187 Introduction to Introduction to Programming with Data Structures Lecture 8 Lists, Iterators, and Doubly Linked Lists.
Lists and Iterators Copyright © 2011 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming.
Page 1 – Spring 2010Steffen Vissing Andersen Software Development with UML and Java 2 SDJ I2, Spring 2010 Agenda – Week 8 Linked List (a reference based.
Linked Lists. Introduction In linked list each item is embedded in a link Each item has two parts – Data – Pointer to the next item in the list Insert,
Data Structures Doubly and Circular Lists Lecture 07: Linked Lists
2/21/20161 List Operations Advanced Programming Ananda Gunawardena.
CS-2852 Data Structures LECTURE 5 Andrew J. Wozniewicz Image copyright © 2010 andyjphoto.com.
CSCI 62 Data Structures Dr. Joshua Stough October 7, 2008.
Lists List Implementations. 2 Linked List Review Recall from CMSC 201 –“A linked list is a linear collection of self- referential structures, called nodes,
UNIT-II Topics to be covered Singly linked list Circular linked list
One implementation of the LIST ADT Insert new node before current and new node becomes current (assume new node created) node newNode = new node; head.
© 2004 Goodrich, Tamassia Queues. © 2004 Goodrich, Tamassia Stacks2 The Queue ADT The Queue ADT stores arbitrary objects Insertions and deletions follow.
1 Chapter 24 Implementing Lists, Stacks, Queues, and Priority Queues Jung Soo (Sue) Lim Cal State LA.
CSCI 62 Data Structures Dr. Joshua Stough September 23, 2008.
Linked List, Stacks Queues
Double-Ended Queues Chapter 5.
Marcus Biel, Software Craftsman
4. Linked Lists.
Linked List Stacks, Linked List Queues, Dequeues
Doubly Linked List Review - We are writing this code
Linked List Variations
Priority Queue.
Data Structures and Database Applications Linked Lists
Doubly Linked Lists Lecture 21 Tue, Mar 21, 2006.
Chapter 24 Implementing Lists, Stacks, Queues, and Priority Queues
Figure 7.1 Some queue operations. Figure 7.1 Some queue operations.
LINKED LISTS.
Queues cont. Chapter 8 © 2011 Pearson Addison-Wesley. All rights reserved.
More on Linked List Yumei Huo Department of Computer Science
Presentation transcript:

CSCI 62 Data Structures Dr. Joshua Stough September 25, 2008

Today More on Lists –Doubly Linked –Circular

Linked Lists Three classes (typically) working together –an “item” class one atomic unit of the aggregate data e.g., a “Name” class (item) might have two instance variables String first, last; –a “node” class one “item” and a reference to the next “node” the next reference is the “link” in “linked list” –a “list” class reference to the first “node”—head of the list

Linked Lists Add(int i, E o) Node List head Node

Linked Lists Remove(int i) List head Node

Problem: in class Assume each Node contains a Double (accessible with.value(). Write the insert method if the list is already in order and is to remain in order.

Singly-Linked List Speed: –Remove/add to front is constant time –Remove/add to back or middle is O(n) How to make constant for addLast? Doubly Linked List. –Each node references both next and previous –Data member tail references last element, to improve add/remove last.

addLast removeLast

Circular Linked List No head, only tail. tail.next is head. What does addFirst look like? addLast Others?