Cpp Code for Linked List - Data Stuctures - Lecture Slides, Slides of Data Structures and Algorithms

C Code for Linked List, The Node class, Building a Linked List, Linked List, Actual picture in memory, Linked List Operations, New node in memory

Typology: Slides

2011/2012

Uploaded on 11/03/2012

ekna
ekna 🇮🇳

4.2

(5)

75 documents

1 / 45

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
AL 1
Linked List
Actual picture in memory:
1051
1052
1055
1059
1060
1061
1062
1063
1064
1056
1057
1058
1053
1054 2
6
8
7
1
1051
1063
1057
1060
0
head 1054
1063
current
2 6 8 7 1
head
current
1065
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

Partial preview of the text

Download Cpp Code for Linked List - Data Stuctures - Lecture Slides and more Slides Data Structures and Algorithms in PDF only on Docsity!

AL 1

Linked List

 Actual picture in memory:

1051 1052 1055 1059 1060 1061 1062 1063 1064 1056 1057 1058 1053 1054 2 6 8 7 1 1051 1063 1057 1060 0 head 1054 current 1063 2 6 8 7 1 head current 1065

AL 2

Linked List Operations

 add(9): Create a new node in memory to hold ‘9’

Node* newNode = new Node(9); newNod 9 e

AL 4

The Node class

class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };

AL 5

The Node class

class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };

AL 7

The Node class

class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };

AL 8

The Node class

class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };

AL 10

The Node class

class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };

AL 11

The Node class

class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };

AL 13

The Node class

class Node { public: int get() { return object; }; void set(int object) { this->object = object; }; Node *getNext() { return nextNode; }; void setNext(Node *nextNode) { this->nextNode = nextNode; }; private: int object; Node *nextNode; };

AL 14

#include <stdlib.h>

#include "Node.cpp"

class List {

public:

// Constructor

List() {

headNode = new Node();

headNode->setNext(NULL);

currentNode = NULL;

size = 0;

AL 16

#include <stdlib.h>

#include "Node.cpp"

class List {

public:

// Constructor

List() {

headNode = new Node();

headNode->setNext(NULL);

currentNode = NULL;

size = 0;

AL 17

#include <stdlib.h>

#include "Node.cpp"

class List {

public:

// Constructor

List() {

headNode = new Node();

headNode->setNext(NULL);

currentNode = NULL;

size = 0;

AL 19

#include <stdlib.h>

#include "Node.cpp"

class List {

public:

// Constructor

List() {

headNode = new Node();

headNode->setNext(NULL);

currentNode = NULL;

size = 0;

AL 20

#include <stdlib.h>

#include "Node.cpp"

class List {

public:

// Constructor

List() {

headNode = new Node();

headNode->setNext(NULL);

currentNode = NULL;

size = 0;