CSCI 2720 Lists III Eileen Kraemer University of Georgia Spring 2007.

Slides:



Advertisements
Similar presentations
Lists CS 3358.
Advertisements

Stacks, Queues, and Linked Lists
Linked Lists Linked Lists Representation Traversing a Linked List
Data Structures Using C++
CHP-5 LinkedList.
CSE Lecture 12 – Linked Lists …
Doubly-linked list library.
Chapter 17 Linked List Saurav Karmakar Spring 2007.
Foundation of Computing Systems Lecture 2 Linked Lists.
Review Learn about linked lists
Linked list More terminology Singly-linked lists Doubly-linked lists DLLs compared to SLLs Circular Lists.
Data Structures & Algorithms
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
Linked Lists. Example We would like to keep a list of inventory records – but only as many as we need An array is a fixed size Instead – use a linked.
Main Index Contents 11 Main Index Contents Abstract Model of a List Obj. Abstract Model of a List Obj. Insertion into a List Insertion into a List Linked.
Lecture 6: Linked Lists Linked lists Insert Delete Lookup Doubly-linked lists.
C++ Programming: Program Design Including Data Structures, Fifth Edition Chapter 17: Linked Lists.
Doubly Linked Lists1 © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition,
Chapter 3: Arrays, Linked Lists, and Recursion
Data Structures Using C++ 2E
1 CSC 211 Data Structures Lecture 21 Dr. Iftikhar Azim Niaz 1.
Implementation of Linked List For more notes and topics visit: eITnotes.com.
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.
September 05 Kraemer UGA/CSCI 2720 Lists – Part I CSCI 2720 Eileen Kraemer The University of Georgia.
Data Structures Using Java1 Chapter 4 Linked Lists.
4-1 Topic 6 Linked Data Structures. 4-2 Objectives Describe linked structures Compare linked structures to array- based structures Explore the techniques.
Department of Computer Science Data Structures Using C++ 2E Chapter 5 Linked Lists.
Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix.
Data Structures Using C++1 Chapter 5 Linked Lists.
CS2006- Data Structures I Chapter 5 Linked Lists III.
1. Circular Linked List In a circular linked list, the last node contains a pointer to the first node of the list. In a circular linked list,
1 Linked Lists (Lec 6). 2  Introduction  Singly Linked Lists  Circularly Linked Lists  Doubly Linked Lists  Multiply Linked Lists  Applications.
Algorithms and Data Structures
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 17: Linked Lists (part 3)
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
Lists (2). Circular Doubly-Linked Lists with Sentry Node Head.
Department of Computer Science 1 Some Practice Let’s practice for the final a little bit. OK?
 Array is a data structure were elements are stored in consecutive memory location.in the array once the memory is allocated.it cannot be extend any more.
Circular linked list A circular linked list is a linear linked list accept that last element points to the first element.
Chapter 17: Linked Lists. Objectives In this chapter, you will: – Learn about linked lists – Learn the basic properties of linked lists – Explore insertion.
Linked list: a list of items (nodes), in which the order of the nodes is determined by the address, called the link, stored in each node C++ Programming:
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 17: Linked Lists.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 18: Linked Lists.
Arrays, Link Lists, and Recursion Chapter 3. Sorting Arrays: Insertion Sort Insertion Sort: Insertion sort is an elementary sorting algorithm that sorts.
LINKED LISTS.
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
CPSC 252 Linked Lists III Page 1 Variations on Singly Linked Lists Inserting or deleting at the front of a list is different from at any other point in.
Unit – I Lists.
C++ Programming:. Program Design Including
[Chapter 4; Chapter 6, pp ] CSC 143 Linked Lists (cont) [Chapter 4; Chapter 6, pp ]
Data Structure By Amee Trivedi.
CSCI-255 LinkedList.
Lectures linked lists Chapter 6 of textbook
Doubly Linked Lists 6/3/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Review Deleting an Element from a Linked List Deletion involves:
Lecture - 6 On Data Structures
Linked-list.
Linked Lists head One downside of arrays is that they have a fixed size. To solve this problem of fixed size, we’ll relax the constraint that the.
A Doubly Linked List There’s the need to access a list in reverse order prev next data dnode header 1.
LINKED LISTS CSCD Linked Lists.
Doubly Linked Lists or Two-way 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.
Doubly Linked Lists Lecture 21 Tue, Mar 21, 2006.
Problem Understanding
LINKED LISTS.
Linked Lists.
Chapter 9 Linked Lists.
Jyh-Shing Roger Jang (張智星) CSIE Dept, National Taiwan University
Problem Understanding
Presentation transcript:

CSCI 2720 Lists III Eileen Kraemer University of Georgia Spring 2007

DLL - Doubly Linked Lists Nodes have two pointer fields  Next  Prev  Next(Prev(P)) and Prev(Next(P)) -- would be nice if they always evaluated to P, but …  Next(Prev(P)) -- breaks on first  Prev(Next(P)) -- breaks on last A Prev Next C B

DLL Next(Prev(P)) and Prev(Next(P)) now OK Header C B A Prev Next

DLLs Forward traversal easy Backward traversal easy Insertion before item easy Insertion after item easy

DLLInsert Procedure DLLInsert(ptr P,Q): //Insert node pointed to by P just after node pointed to by Q

DLLDelete Procedure DLLDelete(ptr P): //Delete cell P from its DLL

DLLs vs. SLLs Pro:  Can delete in O(1) knowing only address of node to be deleted  Easy backward traversal Con  Requires 2x the memory for pointers

XOR pointers “trick” to compress composite of addresses in preceding and succeeding nodes into a single pointer-sized field Saves memory Requires more elaborate methods to traverse list (in either direction)

What is XOR? Bit-wise exclusive-or When applied twice to same value, returns to original value Works like a toggle switch

XOR Example Add1 = 4 (0100), Add2 = 8 (1000) Result = Add1  Add2 = 1100 Result  Add1 = 1000 (original Add2) Result  Add2 = 0100 (original Add1)

XOR used in graphics To do “rubber-banding”  Don’t have to remember previous value of pixel that you overwrite …. Just XOR same value on that location 2X and it returns to the original value

Implementing DLL with XOR Link(X) = To traverse, need P and Q, pointers to two adjacent nodes

Traversing with XOR Forward(P,Q):

Traversing with XOR Backward(P,Q):

Inserting a new node with XOR To insert a new node pointed to by C between those pointed to by P and Q: