ASSIGNMENT # 1
Linked List
Varda quraishi( SP18-BCS-169) 3/4/20 CSC211
, Some functions used in this program:
1. Checking if the list is empty
bool isEmpty() {
return first == NULL;
}
2. Inserting data in the list
void insertAtFront(int value) {
Node* NN = new Node();
NN->data = value;
if (first == NULL) {
first = NN;
}
else {
NN->next = first;
first = NN;
}
}
3. Searching a value
void Search(int value) {
loc = first;
ploc = NULL;
if (isEmpty()) {
return;
}
else {
while (loc != NULL && loc->data < value) {
ploc = loc;
loc = loc->next;
}
if (loc != NULL && loc->data != value) {
loc = NULL;
}
}
Linked List
Varda quraishi( SP18-BCS-169) 3/4/20 CSC211
, Some functions used in this program:
1. Checking if the list is empty
bool isEmpty() {
return first == NULL;
}
2. Inserting data in the list
void insertAtFront(int value) {
Node* NN = new Node();
NN->data = value;
if (first == NULL) {
first = NN;
}
else {
NN->next = first;
first = NN;
}
}
3. Searching a value
void Search(int value) {
loc = first;
ploc = NULL;
if (isEmpty()) {
return;
}
else {
while (loc != NULL && loc->data < value) {
ploc = loc;
loc = loc->next;
}
if (loc != NULL && loc->data != value) {
loc = NULL;
}
}