Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Linked Lists: Advantages, Disadvantages, and Operations, Slides of Data Structures and Algorithms

The advantages and disadvantages of linked lists, focusing on their ease of insertions and deletions, and the extra space required for pointers. It also covers basic operations on a linked list, such as insertion, deletion, building a list, appending and prepending, empty list check, length calculation, and list traversal. The document also introduces doubly linked lists and their insertion and deletion operations.

Typology: Slides

2012/2013

Uploaded on 04/23/2013

saratey
saratey 🇮🇳

4.3

(10)

87 documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
7/2/2011 1
List Operations
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download Linked Lists: Advantages, Disadvantages, and Operations and more Slides Data Structures and Algorithms in PDF only on Docsity!

List Operations

Advantages of Linked Lists

  • The advantages of linked lists include:
    • Overflow can never occur unless the memory

is actually full.

  • Insertions and deletions are

easier

than for

contiguous (array) lists.

  • With large records, moving pointers is easier

and faster than moving the items themselves.

Linked List Operations

List Operations

  • Basic Operations on a Linked List are
    • Insertion– Deletion
      • Other operations include
        • build list– Append and prepend (special cases of insert)– empty– length– toString– traversing

Insertion

  • Two cases to consider
    • List is empty
      • Insert to the beginning of the list
        • List is non-empty
          • Locate the place to insert• Manipulate the references to make new links

head

Insert Operation

P

New node

Other Operations

Prepend

head

New node

Insert to the beginning of the list

null

Length

head

Insert to the end of the list

null

List Types

Inserting into a Doubly Linked List

  • We have to manipulate both next and previous pointers. Insert new node Nbetween P and Q Node P Node Q Node R
Node
N

Deleting from a Doubly Linked List

  • Write the code to delete Node Q Node P Node Q Node R

Make it a Circular Doubly Linked List

  • Write the code to create a circular doubly linked list.

Multi Linked List - An

Example