link list presentation slide(daffodil international university)

Post on 14-Apr-2017

92 Views

Category:

Business

11 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Wellcome our presentation

Our Presentation topic is LINK LISTS

Name:Shaid Bin Md.Sifat

Outline Introduction TRAVERSING A LINKED LIST SEARCHING A LINKED LIST Insertion Description Deletion Description Basic Node Implementation

What is link list ?

Link list is the linear collection of data elements called nodes,where the linear order is given by means of pointers.

Type of link lists

There are mainly two type of link list

Single link listDouble link listCircular link list

Single linked lists

Simple node

Double Linked Lists

Circular Lists

Md.Helal sheikh

14

Traversing a SLL

The following method traverses a list (and prints its elements):

public void printFirstToLast(Node here) { while (here != null) { System.out.print(here.value + " ");

here = here.next;

}}

You would write this as an instance method of the Node class

15

Traversing a SLL (animation)

threetwoone

numerals

here

Insertion Description

Insertion at the top of the list Insertion at the end of the list Insertion in the middle of the list

Insertion at the top

Steps: Create a Node Set the node data Values Connect the pointers

Insertion Description

Follow the previous steps and we get

48 17 142head //

head 93

Step 1 Step 2

Step 3

Insertion at the end

Steps: Create a Node Set the node data Values Connect the pointers

Insertion Description

Follow the previous steps and we get

48 17 142head //

Step 1 Step 2

Step 3

Insertion in the middle

Steps: Create a Node Set the node data Values Break pointer connection Re-connect the pointers

22

Inserting after (animation)

threetwoone

numerals

2.5node

Find the node you want to insert afterFirst, copy the link from the node that's already in the list

Then, change the link in the node that's already in the list

Deleting from the top

Steps Break the pointer connection Re-connect the nodes Delete the node

Deletion Description

4 17

head

426

4 17

head

426

4 17

head

42

Md.Nazmul Hassan

Deleting from the end

Steps Break the pointer connection Set previous node pointer to NULL Delete the node

Deletion Description

4 17

head

426

4 17

head

426

4 176

head

Deleting from the Middle

Steps Set previous Node pointer to next node Break Node pointer connection Delete the node

Deletion Description

4 17 42

head

4 17

head

42

4

head

42

Basic Node Implementation

The following code is written in C++:

Struct Node{

int data; //any type of data could be another structNode *next; //this is an important piece of code “pointer”

};

THANK YOU

top related