100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Class notes

Singly Linked List implementations

Rating
-
Sold
-
Pages
6
Uploaded on
14-01-2021
Written in
2020/2021

Singly Linked List implementations

Institution
Course

Content preview

ASSIGNMENT 01
Singly Linked List implementations




Varda Quraishi(SP18-BCS-169) 9/30/19 DataStructure

, 1. Write a function that deletes all those nodes from a linked list which have even
numbered value in their data part. For instance, if the original list is 1-> 2->3->4->5 -> 6,
then, the updated list should be 2-> 4 -> 6
FUNCTION:

void destroyEvenData() {
if (isEmpty()) { // List is Empty
return;
}
else {
ListNode* temp = start; // Even data in the head node
while (start != NULL && start->data % 2 ==0) {
temp = start;
start = start->next;
delete temp;

}

while (loc != NULL) { // Even data after the head node
if (loc->data % 2 == 0) {
temp = loc;
loc = loc->next;
ploc->next = loc;
delete temp;
}

else { // No even data
ploc = loc;
loc = loc->next;
}
}
}
}

-----------------x----------------x----------------x------------------x------------------x-----------------x-----------------




2. Write a function that prints all nodes of a linked list in the reverse order.

FUNCTION:
void printReverse(){
if (isEmpty()) { // List is Empty
return;
}
else {
while (sloc != NULL) { // While we reach till the
beginning
ploc = loc;
loc->next = ploc;

Written for

Institution
Course

Document information

Uploaded on
January 14, 2021
Number of pages
6
Written in
2020/2021
Type
Class notes
Professor(s)
Yasir faheem
Contains
All classes

Subjects

$7.99
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
youtubecanvas

Get to know the seller

Seller avatar
youtubecanvas COMSATS Institute Of Information Technology
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
5 year
Number of followers
0
Documents
18
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions