Download presentation

Presentation is loading. Please wait.

Published byJared Westray Modified over 3 years ago

2
Linked list More terminology Singly-linked lists Doubly-linked lists DLLs compared to SLLs Circular Lists

3
abcd Each node contains a value and a link (pointer or reference) to some other node The last node contains a null link myList back A linked list is a data structure consisting of a group of nodes which together represent a sequence. Under the simplest form, each node is composed of a data and a reference (in other words, a link) to the next node in the sequence; more complex variants add additional links. This structure allows for efficient insertion or removal of elements from any position in the sequence.data structurenodesreference

4
A node’s successor is the next node in the sequence ◦ The last node has no successor A node’s predecessor is the previous node in the sequence ◦ The first node has no predecessor A list’s length is the number of elements in it ◦ A list may be empty (contain no elements) back

5
Here is a singly-linked list (SLL): Each node contains a value and a link to its successor (the last node has no successor) The header points to the first node in the list (or contains the null link if the list is empty) abcd myList

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

7
Deleting from the top of the list Deleting from the end of the list Deleting from the middle of the list

8
Most “algorithms” on linked lists—such as insertion, deletion, and searching—are pretty obvious; you just need to be careful Sorting a linked list is just messy, since you can’t directly access the n th element—you have to count your way through a lot of other elements back

9
Here is a doubly-linked list (DLL): Each node contains a value, a link to its successor (if any), and a link to its predecessor (if any) The header points to the first node in the list and to the last node in the list (or contains null links if the list is empty) myDLL ab c

10
Advantages: ◦ Can be traversed in either direction (may be essential for some programs) ◦ Some operations, such as deletion and inserting before a node, become easier Disadvantages: ◦ Requires more space ◦ List manipulations are slower (because more links must be changed) ◦ Greater chance of having bugs (because more links must be manipulated) back

11
A circular linked list is a linked list in which the head element's previous pointer points to the tail element and the tail element's next pointer points to the head element. In the special case of a circular list with only one element, the element's previous and next pointers point to itself, and it is both the head and tail of the list.linked list

12
Thank You

Similar presentations

Presentation is loading. Please wait....

OK

Data Structure & Algorithms

Data Structure & Algorithms

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on urbanization and environment Ppt on ms access query Ppt on acid-base titration Ppt on networking related topics Ppt on viruses and bacteria facts Ppt on population census 2011 Ppt on db2 introduction letter Project ppt on product launch Ppt on arithmetic micro operations Ppt on indian textile industries in india