Lists Plus - Data Structures - Lecture Slides, Slides of Data Structures and Algorithms

In the subject of the Data Structures, the key concept and the main points, which are very important in the context of the data structures are listed below:Lists Plus, Circular Linked List, Successor, Element, Circular Linked List, External Pointer, Last Node, Doubly Linked List, Node, Predecessor

Typology: Slides

2012/2013

Uploaded on 04/23/2013

saratey
saratey 🇮🇳

4.3

(10)

86 documents

1 / 77

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Chapter 6
Lists Plus
Lecture 12
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d

Partial preview of the text

Download Lists Plus - Data Structures - Lecture Slides and more Slides Data Structures and Algorithms in PDF only on Docsity!

Chapter 6

Lists Plus

Lecture 12

What is a Circular Linked List?

• A circular linked list is a list in which every

node has a successor; the “ last ” element

is succeeded by the “ first ” element.

What is a Doubly Linked List?

• A doubly linked list is a list in which

each node is linked to both

its successor and its predecessor.

Linking the New Node into the List

What are Header and Trailer Nodes?

• A Header Node is a node at the beginning of a list

that contains a key value smaller than any

possible key.

• A Trailer Node is a node at the end of a list that

contains a key larger than any possible key.

• Both header and trailer are placeholding nodes

used to simplify list processing.

A linked list in static storage?

A Linked List as an Array of Records

An Array with Linked List of Values and Free Space

An Array with Three Lists (Including the Free List)

// CLASS TEMPLATE DEFINITION

#include "ItemType.h" // for MAX_ITEMS and ItemType

template // formal parameter list

class StackType

{

public:

StackType( ); bool IsEmpty( ) const; bool IsFull( ) const; void Push( ItemType item ); void Pop( ItemType item ); ItemType Top( );

private:

int top; ItemType items[MAX_ITEMS];

};

StackType numStack;

top 3

[MAX_ITEMS-1] . . .

[ 3 ] 789
[ 2 ] -
[ 1 ] 132

items [ 0 ] 5670

ACTUAL PARAMETER

top 3

[MAX_ITEMS-1] . . .

[ 3 ] Bradley
[ 2 ] Asad
[ 1 ] Rodrigo

items [ 0 ] Max

StackType numStack;

ACTUAL PARAMETER
// SAMPLE CLASS MEMBER FUNCTIONS

template // formal parameter list

StackType::StackType( )

{

top = -1;

}

template // formal parameter list

void StackType::Push ( ItemType newItem )

{

if (IsFull()) throw FullStack(); top++; items[top] = newItem; // STATIC ARRAY IMPLEMENTATION

}

When creating class template

  • Put .h and .cpp code in the same .h file

or

  • Have .h include .cpp file at the end

Recall Definition of Stack

• Logical (or ADT) level: A stack is an

ordered group of homogeneous items

(elements),

• in which the removal and addition of

stack items can take place only at the

top of the stack.

• A stack is a LIFO “last in, first out”

structure.