Today’s Agenda  Linked Lists  Double ended Linked Lists  Doubly Linked Lists CS2336: Computer Science II.

Slides:



Advertisements
Similar presentations
Chapter 22 Implementing lists: linked implementations.
Advertisements

Linked Lists Geletaw S..
David Luebke 1 6/7/2014 CS 332: Algorithms Skip Lists Introduction to Hashing.
Linked Lists Mohammed Almashat CS /03/2006.
CS 225 Lab #11 – Skip Lists.
Stacks, Queues, and Linked Lists
Linked Lists.
CS 367 – Introduction to Data Structures
C and Data Structures Baojian Hua
CS Winter 2010 Linked Lists - Part 2 Deque with Double Links and Sentinel, Bag.
Singly Linked List BTECH, EE KAZIRANGA UNIVERSITY.
Chapter 17 Linked List Saurav Karmakar Spring 2007.
M180: Data Structures & Algorithms in Java
Today’s Agenda  Stacks  Queues  Priority Queues CS2336: Computer Science II.
Data Structures Simple data type –int, char, long Reference data type –Integer, String, Composite data type == Data Structure –Collection of elements.
CS 206 Introduction to Computer Science II 10 / 22 / 2008 Instructor: Michael Eckmann.
Topic 11 Linked Lists -Joel Spolsky
CS 307 Fundamentals of Computer Science 1 Linked Lists many slides taken from Mike Scott, UT Austin.
CS 206 Introduction to Computer Science II 09 / 17 / 2008 Instructor: Michael Eckmann.
Binary Search Introduction to Trees. Binary searching & introduction to trees 2 CMPS 12B, UC Santa Cruz Last time: recursion In the last lecture, we learned.
COMP103 - Linked Lists (Part A)1 Chapter 17 Truly dynamic memory management.
CS 206 Introduction to Computer Science II 11 / 17 / 2008 Instructor: Michael Eckmann.
Class 3: Linked Lists. cis 335 Fall 2001 Barry Cohen What is a linked list? n A linked list is an ordered series of ‘nodes’ n Each node contains some.
Fall 2007CS 2251 Lists and the Collection Interface Chapter 4.
CS 206 Introduction to Computer Science II 11 / 12 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 04 / 06 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 09 / 19 / 2008 Instructor: Michael Eckmann.
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
Chapter 12 Data Structure Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
Arrays and Linked Lists "All the kids who did great in high school writing pong games in BASIC for their Apple II would get to college, take CompSci 101,
1 CSE 1342 Programming Concepts Lists. 2 Basic Terminology A list is a finite sequence of zero or more elements. –For example, (1,3,5,7) is a list of.
Linked Lists Tonga Institute of Higher Education.
Linked List. Background Arrays has certain disadvantages as data storage structures. ▫In an unordered array, searching is slow ▫In an ordered array, insertion.
Linked Lists part 2 CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University.
CS 307 Fundamentals of Computer ScienceLinked Lists 1 Topic 14 Linked Lists "All the kids who did great in high school writing pong games in BASIC for.
4-1 Topic 6 Linked Data Structures. 4-2 Objectives Describe linked structures Compare linked structures to array- based structures Explore the techniques.
Linked List. Iterators Operation to find a link, deleting, and inserting before or after a specified link, also involve searching through the list to.
Week 4 - Monday.  What did we talk about last time?  Queues  Implementing queues with circular arrays.
1 Data Structures CSCI 132, Spring 2014 Lecture 20 Linked Lists.
Linked List by Chapter 5 Linked List by
CSS446 Spring 2014 Nan Wang.  To understand the implementation of linked lists and array lists  To analyze the efficiency of fundamental operations.
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.
A Introduction to Computing II Lecture 11: Hashtables Fall Session 2000.
2015-T2 Lecture 17 School of Engineering and Computer Science, Victoria University of Wellington  Marcus Frean, Lindsay Groves, Peter Andreae, John Lewis,
Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix.
CSS446 Spring 2014 Nan Wang.  to study trees and binary trees  to understand how binary search trees can implement sets  to learn how red-black trees.
1 Today’s Material List ADT –Definition List ADT Implementation: LinkedList.
1 Algorithms Queues, Stacks and Records stored in Linked Lists or Arrays.
Chapter 5 Linked List by Before you learn Linked List 3 rd level of Data Structures Intermediate Level of Understanding for C++ Please.
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,
2/21/20161 List Operations Advanced Programming Ananda Gunawardena.
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?
CS162 - Topic #7 Lecture: Dynamic Data Structures –Review of pointers and the new operator –Introduction to Linked Lists –Begin walking thru examples of.
CS 46B: Introduction to Data Structures July 23 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak.
Doubly Linked List Exercises Sometimes it is useful to have a linked list with pointers to both the next and previous nodes. This is called a doubly linked.
CS Fall 2009 Linked List Introduction. Characteristics of Linked Lists Elements are held in objects termed Links Links are 1-1 with elements, allocated.
Linked Lists Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics, and Computer Science University of Wisconsin.
 2015, Marcus Biel, Linked List Data Structure Marcus Biel, Software Craftsman
Arrays, Link Lists, and Recursion Chapter 3. Sorting Arrays: Insertion Sort Insertion Sort: Insertion sort is an elementary sorting algorithm that sorts.
LINKED LISTS.
CS162 - Topic #9 Lecture: Dynamic Data Structures –Deallocating all nodes in a LLL –Inserting nodes into sorted order Programming Assignment Questions.
[Chapter 4; Chapter 6, pp ] CSC 143 Linked Lists (cont) [Chapter 4; Chapter 6, pp ]
Linked List Introduction
UNIT-3 LINKED LIST.
Arrays and Linked Lists
Lists CSE 373 Data Structures.
Introduction to C++ Linear Linked Lists
Lecture 15 Doubly Linked Lists CSE /26/2018.
Lists CSE 373 Data Structures.
Presentation transcript:

Today’s Agenda  Linked Lists  Double ended Linked Lists  Doubly Linked Lists CS2336: Computer Science II

Linked List  Made up of Nodes  Each node has  An item  A reference to next node in the list CS2336: Computer Science II item next l1 item next l2 item next l3 706

Advantages over array  Inserting item into middle of linkedList takes constant time if you have reference to the node  The list can keep growing until memory runs out CS2336: Computer Science II

Inserting an item  Insert a new item immediately after “this” node.  insertAfter method CS2336: Computer Science II item next l1 item next l2 item next l3 706 item next 3

Disadvantages over array  Finding the n th item of a linkedList takes O(n) because it is proportional to size of the list.  But in array you can do it in constant time  A lot of data structures that we will see in this course are trying to find a solution that works quickly in all the different cases both finding and inserting new items CS2336: Computer Science II

Find n th position  First we check, if the position is equal to 1 then we find the solution and return this  Then we check if the position is less than 1 or our list is empty (next is null), so return null  If none of the above, then we use recursion.  The idea is that if I jump forward one node or I jump to the next reference then I can call nth recursively on that node and the position is one less. CS2336: Computer Science II This 4 th This 3 th

Linklist ContactName List Example CS2336: Computer Science II

Double ended linked list  Think about a neighborhood with neighbors  First we create neighbor object  Double ended has both reference to the first and the last link in the list  Firstlink and lastlink  Add new neighbor to the beginning of the list  Add new neighbor to the end of the list CS2336: Computer Science II

Doubly linked list  Unlike the other list that they only had value next and they could only go forward, we have value previous so we can go backward too.  Add after a specific key  Add on order CS2336: Computer Science II