3/19/2016 5:40 PMLinked list1 Array-based List v.s. Linked List Yumei Huo Department of Computer Science College of Staten Island, CUNY Spring 2009.

Slides:



Advertisements
Similar presentations
Pointers and Data Structures 1 Yinzhi Cao Modified from slides made by Prof Goce Trajcevski.
Advertisements

Lists CS 3358.
COMP171 Fall 2005 Lists.
Linked Lists.
Data Structures Static and Dynamic.
 Definition of B+ tree  How to create B+ tree  How to search for record  How to delete and insert a data.
Chapter 17 Linked List Saurav Karmakar Spring 2007.
M180: Data Structures & Algorithms in Java
Foundation of Computing Systems Lecture 2 Linked Lists.
Today’s Agenda  Stacks  Queues  Priority Queues CS2336: Computer Science II.
Data Structures: A Pseudocode Approach with C
An Array-Based Implementation of the ADT List public class ListArrayBased implements ListInterface { private static final int MAX_LIST = 50; private Object.
Introduction to Data Structure, Spring 2007 Slide- 1 California State University, Fresno Introduction to Data Structure Introduction of Concepts Ming Li.
@ Zhigang Zhu, CSC212 Data Structure - Section FG Lecture 10 The Bag and Sequence Classes with Linked Lists Instructor: Zhigang Zhu Department.
CMPT 225 ADT List using Dynamic arrays A dynamic data structure is one that changes size, as needed, as items are inserted or removed The Java ArrayList.
Chapter 4 Linked Structures. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 4-2 Chapter Objectives Describe the use of references to create.
Summary of lectures (1 to 11)
Doubly Linked Lists Deleting from the end of the list – Have to traverse the entire list to stop right in front of tail to delete it, so O(n) – With head.
FEN 2012UCN Technology - Computer Science 1 Data Structures and Collections Principles revisited.NET: –Two libraries: System.Collections System.Collections.Generics.
Implementation of Linked List For more notes and topics visit: eITnotes.com.
IT 60101: Lecture #151 Foundation of Computing Systems Lecture 15 Searching Algorithms.
Lists 1. Introduction Data: A finite sequence of data items. Operations: Construction: Create an empty list Empty: Check if list is empty Insert: Add.
ITEC 2620A Introduction to Data Structures Instructor: Prof. Z. Yang Course Website: 2620a.htm Office: TEL 3049.
Lists II. List ADT When using an array-based implementation of the List ADT we encounter two problems; 1. Overflow 2. Wasted Space These limitations are.
Data Structures and Algorithms Lecture 1 Instructor: Quratulain Date: 1 st Sep, 2009.
Dynamic Array. An Array-Based Implementation - Summary Good things:  Fast, random access of elements  Very memory efficient, very little memory is required.
1 Data Structures CSCI 132, Spring 2014 Lecture 20 Linked Lists.
The List ADT A sequence of zero or more elements A 1, A 2, A 3, … A N-1 N: length of the list A 1 : first element A N-1 : last element A i : position i.
3 Data. Software And Data Data Data element – a single, meaningful unit of data. Name Social Security Number Data structure – a set of related data elements.
Kovács Zita 2014/2015. II. félév DATA STRUCTURES AND ALGORITHMS 26 February 2015, Linked list.
1 Data Organization Example 1: Heap storage management –Keep track of free chunks of memory Example 2: A simple text editor –Maintain a sequence of lines.
List Interface and Linked List Mrs. Furman March 25, 2010.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Elementary Data Structures Array Lists Array Lists Dale.
Linked Lists. Array List Issues Painful insert/remove at start/middle.
Linear Data Structures
Department of Computer Science 1 Some Practice Let’s practice for the final a little bit. OK?
Circular linked list A circular linked list is a linear linked list accept that last element points to the first element.
1 Principles revisited.NET: Two libraries: System.Collections System.Collections.Generics Data Structures and Collections.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To introduce the basic concepts of linked lists ❏ To introduce the basic concepts.
1 Linked List. Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion.
Linked List. LINKED LIST Link is collection of similar type of elements. There are two ways of maintaining a list in memory. The first way is store the.
Data Structure & Algorithms
Computer Science Department Data Structure and Algorithms Lecture 3 Stacks.
ITEC 2620M Introduction to Data Structures Instructor: Prof. Z. Yang Course Website: ec2620m.htm Office: TEL 3049.
Linked Lists Chapter Introduction To The Linked List ADT Linked list: set of data structures (nodes) that contain references to other data structures.
UNIT-II Topics to be covered Singly linked list Circular linked list
Data Structure and Algorithm: CIT231 Lecture 6: Linked Lists DeSiaMorewww.desiamore.com/ifm1.
CC 215 DATA STRUCTURES LINKED LISTS Dr. Manal Helal - Fall 2014 Lecture 3 AASTMT Engineering and Technology College 1.
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
UNIT-V ABSTRACT DATA TYPE 1.LIST 2.STACK 3.QUEUE EC6301-II-ECE-C.
Unit – I Lists.
CSCI-255 LinkedList.
CMSC202 Computer Science II for Majors Lecture 12 – Linked Lists
Big-O notation Linked lists
CE 221 Data Structures and Algorithms
Lists CS 3358.
Linked Lists.
ITEC 2620M Introduction to Data Structures
Linked List Yumei Huo Department of Computer Science
LINKED LISTS CSCD Linked Lists.
Chapter 15 Lists Objectives
Arrays and Linked Lists
Linked List Intro CSCE 121 J. Michael Moore.
Linked List and Selection Sort
Chapter 17: Linked Lists.
By Yogesh Neopaney Assistant Professor Department of Computer Science
Data Structures & Algorithms
Lecture No.02 Data Structures Dr. Sohail Aslam
Linked List Intro CSCE 121.
More on Linked List Yumei Huo Department of Computer Science
Presentation transcript:

3/19/2016 5:40 PMLinked list1 Array-based List v.s. Linked List Yumei Huo Department of Computer Science College of Staten Island, CUNY Spring 2009

Linked List v.s. Array-based list Array-based list Elements are stored in contiguous array positions  Support Random Access Requires an estimate of the maximum size of the list  the size of a C++ array is fixed  waste space Linked list Ensure that the list is not stored contiguously  use a linked list  a series of structures that are not necessarily adjacent in memory The pointer implementation uses only as much space as is needed for the elements currently on the list  Dynamic: a linked list can easily grow and shrink in size.  We don’t need to know how many nodes will be in the list. They are created in memory as needed. Requires space for the pointers in each cell 3/19/2016 5:40 PMLinked list2

3/19/2016 5:40 PMLinked list3 Linked List v.s. Array-based list: Access the kth element Linked List: Need to visit k nodes O(k) Array: Access the element with index k-1 directly O(1) ABCD  first Singly Linked List ABCD S[10] S[3] Array

3/19/2016 5:40 PMLinked list4 Linked List v.s. Array-based list: Search a key Linked List: Worst case: need to visit n nodes Average: need to visit n/2 nodes O(n) Array: Worst case: need to visit n nodes Average: need to visit n/2 nodes O(n)

3/19/2016 5:40 PMLinked list5 Linked List v.s. Array-based list: Insert an element to 1 st position Linked List: Visit one node O(1) Array: requires first pushing the entire array down one spot to make room Visit n node O(n)

3/19/2016 5:40 PMLinked list6 Linked List v.s. Array-based list: Delete the 1 st element Linked List: Visit one node O(1) Array: Requires shifting all the elements in the list up one Visit n node O(n)

3/19/2016 5:40 PMLinked list7 Linked List v.s. Array-based list: Insert an element to k th position Linked List: In order to find k-1 th element, k-1 nodes will be visited O(k) Array: requires first pushing the elements after k-1 th element down one spot to make room shifting n-(k-1) node Average: n/2 nodes need to be visited.

3/19/2016 5:40 PMLinked list8 Linked List v.s. Array-based list: Delete the k st element Linked List: In order to find k-1 th element, k-1 nodes will be visited O(k) Array: Requires shifting all the elements in the list up one shifting n-k node Average: n/2 nodes need to be visited.

Linked List v.s. Array-based list The Most Efficient Operations on Linked List are: Inserting at the head position O(1) Removing the head node ----O(1) If the above two operations need to be done more frequently, then linked list is the best. The Most Efficient Operations on Array-based List are: Find the kth element ----O(1) If finding the kth element needs to be done more frequently, then Array-based list is the best. 3/19/2016 5:40 PMLinked list9

3/19/2016 5:40 PMLinked list10 Thank you!