Single Pointer Implemention

Slides:



Advertisements
Similar presentations
Lists CS 3358.
Advertisements

DATA STRUCTURES AND ALGORITHMS Prepared by İnanç TAHRALI
M180: Data Structures & Algorithms in Java
CS 1114: Data Structures – Implementation: part 1 Prof. Graeme Bailey (notes modified from Noah Snavely, Spring 2009)
Variations of Linked Lists CS 302 – Data Structures Sections 6.2, 6.3 and 6.4.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Variations of Linked Lists CS 308 – Data Structures.
DS.L.1 Lists, Stacks, and Queues (Review) Chapter 3 Overview Abstract Data Types Linked Lists, Headers, Circular Links Cursor (Array) Implementation Stacks.
CHAPTER 3 Lists, Stacks, and Queues §1 Abstract Data Type (ADT) 【 Definition 】 Data Type = { Objects }  { Operations } 〖 Example 〗 int = { 0,  1, 
1 CS162: Introduction to Computer Science II Abstract Data Types.
CH 1-4 : INTRODUCTION ACKNOWLEDGEMENT: THE SLIDES ARE PREPARED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND.
CISC220 Spring 2010 James Atlas Lecture 04: Pointers, Functions, Memory Management, ADTs, Classes, Hardware, Software, Graphics, Networking, AI, Databases,
Chapter 3 Lists, Stacks, Queues. Abstract Data Types A set of items – Just items, not data types, nothing related to programming code A set of operations.
Implementing stacks Prof. Ramin Zabih
Chapter 4 Link Based Implementations
Link Based Implementations
Linked List ADT used to store information in a list
Lecture 6 of Computer Science II
Unit – I Lists.
Week 4 - Monday CS221.
Data Structure By Amee Trivedi.
Linked List Introduction
G64ADS Advanced Data Structures
Prof. Ramin Zabih Implementing queues Prof. Ramin Zabih
CS 215 Final Review Ismail abumuhfouz Fall 2014.
Pointers & Arrays.
CSCI-255 LinkedList.
Lectures linked lists Chapter 6 of textbook
Program based on queue & their operations for an application
UNIT – I Linked Lists.
Linked Lists Chapter 6 Section 6.4 – 6.6
CS 1114: Implementing Search
COP3530- Data Structures Advanced Lists
Chapter 11: File System Implementation
EEL 4854 IT Data Structures Linked Lists
Queues Queues Queues.
Introduction to Classes
LINKED LISTS CSCD Linked Lists.
Prof. Neary Adapted from slides by Dr. Katherine Gibson
Optimizing Malloc and Free
Stacks, Queues, and Deques
Chapter 4 Link Based Implementations
Exam 1 Review CS 3358.
Chapter 11: File System Implementation
Queue and Priority Queue Implementations
Chapter 14: Queue and Priority Queue Implementations
Exam 1 Review CS 3358.
CS703 - Advanced Operating Systems
Lecture 18 Arrays and Pointer Arithmetic
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.
Data Structures Lectures: Haim Kaplan, Uri Zwick Exam: 80%
Linked Lists Chapter 4.
CMSC 341 Lists 3.
CMSC 341 Lists 3.
CS210- Lecture 5 Jun 9, 2005 Agenda Queues
Lecture 16 Section 6.2 Thu, Mar 1, 2007
Queues Model Operations Pointer Implementations Array Implementation
CS250 Introduction to Computer Science II
Pointers & Arrays.
Lecture No.02 Data Structures Dr. Sohail Aslam
Chapter 11: File System Implementation
17CS1102 DATA STRUCTURES © 2016 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS.
CS210- Lecture 6 Jun 13, 2005 Announcements
Queues and Priority Queue Implementations
17CS1102 DATA STRUCTURES © 2018 KLEF – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS RESERVED.
Dynamic Array: Implementation of Stack
LINEAR DATA STRUCTURES
CMPT 225 Lecture 5 – linked list.
Lecture 3 – Data collection List ADT
Presentation transcript:

Single Pointer Implemention Lists ADT Array Implementation Single Pointer Implemention Cursors Doubly Linked Ring 9/21/2018 CS 303 –Lists Lecture 4

ADT List - Operations L = MakeNull() Insert(L,p,x) Delete(L,p) p = First(L) p = End(L) p = Previous(L,p) p = Next(L,p) p = Locate(L,x) x = Retrieve(L,p) x: ElementType p: PositionType L: ListType Why isn’t First(L)always 1? Because Position is hidden! No arithmetic is allowed (by the user) on Positions. Use Previous and Next! 9/21/2018 CS 303 –Lists Lecture 4

Array Implementation a1 a2 1 2 n an MaxLength Last Internal routines can do arithmetic on “positions”, but external (user) routines cannot. Why? 9/21/2018 CS 303 –Lists Lecture 4

Single Pointer Implementation ??? a1 a2 ... an Header What is the purpose of the header? (Hing: consider “position”) Compare details (efficiency, behavior of “position”) with Array Implementation Array Pointer Previous/End EASY HARD Insert/Delete HARD EASY 9/21/2018 CS 303 –Lists Lecture 4

Cursors (an aside) Suppose you want to use pointers – but your programming environment does not support them? Use “cursors” Allocate an Array called CursorSpace Use indices into CursorSpace just like pointers Do your own memory management of cells New Dispose 9/21/2018 CS 303 –Lists Lecture 4

Doubly Linked Lists/Rings ? a? an Many variations Is ‘?’ a0 (Header) or a1? [a1] Is ‘L’ part of the structure, or an external pointer? [external] Is there a “First” element? [where L points!] Implement the full Ring! Everything is EASY; Position is natural 9/21/2018 CS 303 –Lists Lecture 4