SlideShare a Scribd company logo
Lecture No.03
Data Structures
Dr. Sohail Aslam
Linked List


Actual picture in memory:
1051
1052
1053

1063
2

1055

head

1063

1054

current

6

1051

1056

2

6

8

7

1

1057
1058

current

7
1060

1059
1060
1061
head

1
0

1062

1054

1063

8

1064

1057

1065
Linked List Operations


add(9): Create a new node in memory to hold ‘9’
Node* newNode = new Node(9);

newNode

9
Linked List Operations


add(9): Create a new node in memory to hold ‘9’
Node* newNode = new Node(9);



newNode

Link the new node into the list
head
2

6

8

current

7
2

3

9
newNode

1

1

size=5 6

9
C++ Code for Linked List
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;
};
C++ Code for Linked List
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;
};
C++ Code for Linked List
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;
};
C++ Code for Linked List
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;
};
C++ Code for Linked List
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;
};
C++ Code for Linked List
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;
};
C++ Code for Linked List
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;
};
C++ Code for Linked List
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;
};
C++ Code for Linked List
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;
};
C++ Code for Linked List
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;
};
C++ Code for Linked List
#include <stdlib.h>
#include "Node.cpp"
class List {
public:
// Constructor
List() {
headNode = new Node();
headNode->setNext(NULL);
currentNode = NULL;
size = 0;
};
C++ Code for Linked List


#include <stdlib.h>
#include "Node.cpp"
class List {
public:
// Constructor
List() {
headNode = new Node();
headNode->setNext(NULL);
currentNode = NULL;
size = 0;
};
C++ Code for Linked List
#include <stdlib.h>
 #include "Node.cpp"
class List {
public:
// Constructor
List() {
headNode = new Node();
headNode->setNext(NULL);
currentNode = NULL;
size = 0;
};
C++ Code for Linked List
#include <stdlib.h>
#include "Node.cpp"


class List {
public:
// Constructor
List() {
headNode = new Node();
headNode->setNext(NULL);
currentNode = NULL;
size = 0;
};
C++ Code for Linked List
#include <stdlib.h>
#include "Node.cpp"
class List {
 public:
// Constructor
List() {
headNode = new Node();
headNode->setNext(NULL);
currentNode = NULL;
size = 0;
};
C++ Code for Linked List
#include <stdlib.h>
#include "Node.cpp"
class List {
public:
// Constructor
List() {

headNode = new Node();
headNode->setNext(NULL);
currentNode = NULL;
size = 0;
};
C++ Code for Linked List
#include <stdlib.h>
#include "Node.cpp"
class List {
public:
// Constructor
List() {

headNode = new Node();
headNode->setNext(NULL);
currentNode = NULL;
size = 0;
};
C++ Code for Linked List
#include <stdlib.h>
#include "Node.cpp"
class List {
public:
// Constructor
List() {
headNode = new Node();

headNode->setNext(NULL);
currentNode = NULL;
size = 0;
};
C++ Code for Linked List
#include <stdlib.h>
#include "Node.cpp"
class List {
public:
// Constructor
List() {
headNode = new Node();
headNode->setNext(NULL);

currentNode = NULL;
size = 0;
};
C++ Code for Linked List
#include <stdlib.h>
#include "Node.cpp"
class List {
public:
// Constructor
List() {
headNode = new Node();
headNode->setNext(NULL);
currentNode = NULL;

size = 0;
};
C++ Code for Linked List
void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
C++ Code for Linked List


void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
C++ Code for Linked List


void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
C++ Code for Linked List


void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
C++ Code for Linked List


void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
C++ Code for Linked List



void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
C++ Code for Linked List



void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
C++ Code for Linked List



void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
C++ Code for Linked List



void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
C++ Code for Linked List



void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
C++ Code for Linked List



void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
C++ Code for Linked List



void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
C++ Code for Linked List



void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
C++ Code for Linked List



void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
C++ Code for Linked List



void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
C++ Code for Linked List



void add(int addObject) {
Node* newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL ){
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else {
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size++;
};
Building a Linked List
List list;

headNode

size=0
Building a Linked List
List list;

headNode

size=0
currentNode

list.add(2);

headNode
lastcurrentNode

2

size=1
Building a Linked List
List list;

headNode

size=0
currentNode

list.add(2);

headNode

2

size=1

lastcurrentNode

currentNode

list.add(6);

headNode

2

6

lastcurrentNode

size=2
Building a Linked List
List.add(8); list.add(7); list.add(1);

currentNode
headNode

2

6

8

7

lastcurrentNode

1

size=5
C++ Code for Linked List
int get() {
if (currentNode != NULL)
return currentNode->get();
};
C++ Code for Linked List
bool next() {
if (currentNode == NULL) return false;
lastCurrentNode = currentNode;
currentNode = currentNode->getNext();
if (currentNode == NULL || size == 0)
return false;
else
return true;
};

More Related Content

What's hot

Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»
SpbDotNet Community
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4Abed Bukhari
 
DCN Practical
DCN PracticalDCN Practical
DCN Practical
Niraj Bharambe
 
Java programs
Java programsJava programs
Java programsjojeph
 
Collection Core Concept
Collection Core ConceptCollection Core Concept
Collection Core Concept
Rays Technologies
 
CppConcurrencyInAction - Chapter07
CppConcurrencyInAction - Chapter07CppConcurrencyInAction - Chapter07
CppConcurrencyInAction - Chapter07
DooSeon Choi
 
Programs
ProgramsPrograms
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File DiplomaDSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diploma
mustkeem khan
 
Java Practical File Diploma
Java Practical File DiplomaJava Practical File Diploma
Java Practical File Diploma
mustkeem khan
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
kinan keshkeh
 
Python Performance 101
Python Performance 101Python Performance 101
Python Performance 101Ankur Gupta
 
C#
C#C#
Cquestions
Cquestions Cquestions
Cquestions
mohamed sikander
 
Typelevel summit
Typelevel summitTypelevel summit
Typelevel summit
Marina Sigaeva
 
Herding types with Scala macros
Herding types with Scala macrosHerding types with Scala macros
Herding types with Scala macros
Marina Sigaeva
 
とある断片の超動的言語
とある断片の超動的言語とある断片の超動的言語
とある断片の超動的言語Kiyotaka Oku
 
Class list data structure
Class list data structureClass list data structure
Class list data structure
Katang Isip
 

What's hot (20)

Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
 
DCN Practical
DCN PracticalDCN Practical
DCN Practical
 
Java programs
Java programsJava programs
Java programs
 
Collection Core Concept
Collection Core ConceptCollection Core Concept
Collection Core Concept
 
CppConcurrencyInAction - Chapter07
CppConcurrencyInAction - Chapter07CppConcurrencyInAction - Chapter07
CppConcurrencyInAction - Chapter07
 
Programs
ProgramsPrograms
Programs
 
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File DiplomaDSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diploma
 
Java Practical File Diploma
Java Practical File DiplomaJava Practical File Diploma
Java Practical File Diploma
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
C Prog - Array
C Prog - ArrayC Prog - Array
C Prog - Array
 
C program
C programC program
C program
 
Python Performance 101
Python Performance 101Python Performance 101
Python Performance 101
 
C#
C#C#
C#
 
XTW_Import
XTW_ImportXTW_Import
XTW_Import
 
Cquestions
Cquestions Cquestions
Cquestions
 
Typelevel summit
Typelevel summitTypelevel summit
Typelevel summit
 
Herding types with Scala macros
Herding types with Scala macrosHerding types with Scala macros
Herding types with Scala macros
 
とある断片の超動的言語
とある断片の超動的言語とある断片の超動的言語
とある断片の超動的言語
 
Class list data structure
Class list data structureClass list data structure
Class list data structure
 

Similar to Data structures cs301 power point slides lecture 03

Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptxData Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
RashidFaridChishti
 
Rewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfRewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdf
alphaagenciesindia
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdf
feroz544
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
fortmdu
 
Doubly linklist
Doubly linklistDoubly linklist
Doubly linklist
ilsamaryum
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docx
BrianGHiNewmanv
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
aathiauto
 
Help I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfHelp I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdf
mail931892
 
C++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdfC++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdf
arjunenterprises1978
 
#include iostream #include cstddefusing namespace std;temp.pdf
#include iostream #include cstddefusing namespace std;temp.pdf#include iostream #include cstddefusing namespace std;temp.pdf
#include iostream #include cstddefusing namespace std;temp.pdf
karan8801
 
Using visual studio 2022- a C# windows form application- and your Doub.pdf
Using visual studio 2022- a C# windows form application- and your Doub.pdfUsing visual studio 2022- a C# windows form application- and your Doub.pdf
Using visual studio 2022- a C# windows form application- and your Doub.pdf
acteleshoppe
 
coding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxcoding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docx
tienlivick
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
teyaj1
 
Can someone help me to fix the code please package dlist i.pdf
Can someone help me to fix the code please package dlist i.pdfCan someone help me to fix the code please package dlist i.pdf
Can someone help me to fix the code please package dlist i.pdf
ABHISHEKREADYMADESKO
 
Using C++ use a linked list to create an alphabetical Conta.pdf
Using C++ use a linked list to create an alphabetical Conta.pdfUsing C++ use a linked list to create an alphabetical Conta.pdf
Using C++ use a linked list to create an alphabetical Conta.pdf
picscamshoppe
 
Write a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdfWrite a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdf
thangarajarivukadal
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
vishalateen
 
This code currently works. Run it and get a screen shot of its ou.docx
 This code currently works. Run it and get a screen shot of its ou.docx This code currently works. Run it and get a screen shot of its ou.docx
This code currently works. Run it and get a screen shot of its ou.docx
Komlin1
 
#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
 #ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf #ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
angelsfashion1
 

Similar to Data structures cs301 power point slides lecture 03 (20)

Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptxData Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
 
Rewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfRewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdf
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdf
 
Lab-2.4 101.pdf
Lab-2.4 101.pdfLab-2.4 101.pdf
Lab-2.4 101.pdf
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
 
Doubly linklist
Doubly linklistDoubly linklist
Doubly linklist
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docx
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
 
Help I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfHelp I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdf
 
C++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdfC++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdf
 
#include iostream #include cstddefusing namespace std;temp.pdf
#include iostream #include cstddefusing namespace std;temp.pdf#include iostream #include cstddefusing namespace std;temp.pdf
#include iostream #include cstddefusing namespace std;temp.pdf
 
Using visual studio 2022- a C# windows form application- and your Doub.pdf
Using visual studio 2022- a C# windows form application- and your Doub.pdfUsing visual studio 2022- a C# windows form application- and your Doub.pdf
Using visual studio 2022- a C# windows form application- and your Doub.pdf
 
coding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxcoding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docx
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
 
Can someone help me to fix the code please package dlist i.pdf
Can someone help me to fix the code please package dlist i.pdfCan someone help me to fix the code please package dlist i.pdf
Can someone help me to fix the code please package dlist i.pdf
 
Using C++ use a linked list to create an alphabetical Conta.pdf
Using C++ use a linked list to create an alphabetical Conta.pdfUsing C++ use a linked list to create an alphabetical Conta.pdf
Using C++ use a linked list to create an alphabetical Conta.pdf
 
Write a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdfWrite a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdf
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
 
This code currently works. Run it and get a screen shot of its ou.docx
 This code currently works. Run it and get a screen shot of its ou.docx This code currently works. Run it and get a screen shot of its ou.docx
This code currently works. Run it and get a screen shot of its ou.docx
 
#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
 #ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf #ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
 

Recently uploaded

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 

Recently uploaded (20)

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 

Data structures cs301 power point slides lecture 03

  • 2. Linked List  Actual picture in memory: 1051 1052 1053 1063 2 1055 head 1063 1054 current 6 1051 1056 2 6 8 7 1 1057 1058 current 7 1060 1059 1060 1061 head 1 0 1062 1054 1063 8 1064 1057 1065
  • 3. Linked List Operations  add(9): Create a new node in memory to hold ‘9’ Node* newNode = new Node(9); newNode 9
  • 4. Linked List Operations  add(9): Create a new node in memory to hold ‘9’ Node* newNode = new Node(9);  newNode Link the new node into the list head 2 6 8 current 7 2 3 9 newNode 1 1 size=5 6 9
  • 5. C++ Code for Linked List 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; };
  • 6. C++ Code for Linked List 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; };
  • 7. C++ Code for Linked List 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; };
  • 8. C++ Code for Linked List 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; };
  • 9. C++ Code for Linked List 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; };
  • 10. C++ Code for Linked List 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; };
  • 11. C++ Code for Linked List 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; };
  • 12. C++ Code for Linked List 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; };
  • 13. C++ Code for Linked List 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; };
  • 14. C++ Code for Linked List 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; };
  • 15. C++ Code for Linked List #include <stdlib.h> #include "Node.cpp" class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; };
  • 16. C++ Code for Linked List  #include <stdlib.h> #include "Node.cpp" class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; };
  • 17. C++ Code for Linked List #include <stdlib.h>  #include "Node.cpp" class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; };
  • 18. C++ Code for Linked List #include <stdlib.h> #include "Node.cpp"  class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; };
  • 19. C++ Code for Linked List #include <stdlib.h> #include "Node.cpp" class List {  public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; };
  • 20. C++ Code for Linked List #include <stdlib.h> #include "Node.cpp" class List { public: // Constructor List() {  headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; };
  • 21. C++ Code for Linked List #include <stdlib.h> #include "Node.cpp" class List { public: // Constructor List() {  headNode = new Node(); headNode->setNext(NULL); currentNode = NULL; size = 0; };
  • 22. C++ Code for Linked List #include <stdlib.h> #include "Node.cpp" class List { public: // Constructor List() { headNode = new Node();  headNode->setNext(NULL); currentNode = NULL; size = 0; };
  • 23. C++ Code for Linked List #include <stdlib.h> #include "Node.cpp" class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL);  currentNode = NULL; size = 0; };
  • 24. C++ Code for Linked List #include <stdlib.h> #include "Node.cpp" class List { public: // Constructor List() { headNode = new Node(); headNode->setNext(NULL); currentNode = NULL;  size = 0; };
  • 25. C++ Code for Linked List void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 26. C++ Code for Linked List  void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 27. C++ Code for Linked List  void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 28. C++ Code for Linked List  void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 29. C++ Code for Linked List  void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 30. C++ Code for Linked List  void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 31. C++ Code for Linked List  void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 32. C++ Code for Linked List  void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 33. C++ Code for Linked List  void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 34. C++ Code for Linked List  void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 35. C++ Code for Linked List  void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 36. C++ Code for Linked List  void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 37. C++ Code for Linked List  void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 38. C++ Code for Linked List  void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 39. C++ Code for Linked List  void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 40. C++ Code for Linked List  void add(int addObject) { Node* newNode = new Node(); newNode->set(addObject); if( currentNode != NULL ){ newNode->setNext(currentNode->getNext()); currentNode->setNext( newNode ); lastCurrentNode = currentNode; currentNode = newNode; } else { newNode->setNext(NULL); headNode->setNext(newNode); lastCurrentNode = headNode; currentNode = newNode; } size++; };
  • 41. Building a Linked List List list; headNode size=0
  • 42. Building a Linked List List list; headNode size=0 currentNode list.add(2); headNode lastcurrentNode 2 size=1
  • 43. Building a Linked List List list; headNode size=0 currentNode list.add(2); headNode 2 size=1 lastcurrentNode currentNode list.add(6); headNode 2 6 lastcurrentNode size=2
  • 44. Building a Linked List List.add(8); list.add(7); list.add(1); currentNode headNode 2 6 8 7 lastcurrentNode 1 size=5
  • 45. C++ Code for Linked List int get() { if (currentNode != NULL) return currentNode->get(); };
  • 46. C++ Code for Linked List bool next() { if (currentNode == NULL) return false; lastCurrentNode = currentNode; currentNode = currentNode->getNext(); if (currentNode == NULL || size == 0) return false; else return true; };

Editor's Notes

  1. End of lecture 2 The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  2. The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  3. The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  4. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  5. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  6. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  7. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  8. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  9. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  10. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  11. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  12. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  13. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  14. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  15. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  16. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  17. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  18. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  19. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  20. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  21. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  22. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  23. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  24. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  25. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  26. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  27. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  28. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  29. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  30. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  31. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  32. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  33. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  34. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  35. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  36. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  37. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  38. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  39. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  40. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  41. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  42. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  43. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  44. The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  45. End of lecture 3 The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.