0% found this document useful (0 votes)
10 views4 pages

Lab 04 Linklist

Uploaded by

banoh958
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

Lab 04 Linklist

Uploaded by

banoh958
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

National University

Of Computer & Emerging Sciences Faisalabad-Chiniot Campus

CL-2001
Data Structures
Lab # 4
Objectives:
• Linked List(insertion)
• Linked List(deletion)
• Linked List(searching)

Note: Carefully read the following instructions (Each instruction contains a weightage)

1. There must be a block of comments at start of every question's code by students; the block should
contain brief description about functionality of code.
2. Comment on every function and about its functionality.
3. Mention comments where necessary such as comments with variables, loop, classes etc to
increase code understandability.
4. Use understandable name of variables.
5. Proper indentation of code is essential.
6. Write a code in C++ language.
7. Make a Microsoft Word file and paste all of your C++ code with all possible screenshots of every
task outputs in Microsoft Word and submit word file. Do not submit .cpp file.
8. First think about statement problems and then write/draw your logic on copy.
9. After copy pencil work, code the problem statement on MS Studio C++ compiler.
10. At the end when you done your tasks, attached C++ created files in MS word file and make your
submission on Google Classroom. (Make sure your submission is completed).
11. Please submit your file in this format 22F1234_L4.
12. Do not submit your assignment after deadline. Late and email submission
is not accepted.
13. Do not copy code from any source otherwise you will be penalized with
negative marks.
National University
Of Computer & Emerging Sciences Faisalabad-Chiniot Campus

Scenario:
You have been assigned the task of developing a Facebook newsfeed using linked lists to manage the
posts and comments. Each post on the newsfeed will be represented by a node defined in the given
Abstract Data Type (ADT). The ADT includes structures for PostNode and CommentNode, with
attributes such as post_id, user_id, content, and a linked list to store comments. Additionally, you are
provided with a class called FacebookNewsFeed, which contains methods to insert a new post, delete a
post based on user_id and post_id, and search for posts based on user_id and post_id.

Your objective is to implement these functionalities to create a functional Facebook newsfeed where
users can create posts, comment on posts, and interact with the content shared by others. The linked
list structure will ensure efficient management of posts and comments, allowing for seamless
navigation through the newsfeed and interaction with the content.

struct CommentNode {
int user_id; // : Unique identifier for the commenting person
string comment; // : Posted comment
CommentNode* next;
};

struct PostNode {
int post_id; // : Unique identifier for the post.
int user_id; // : Unique identifier for the user who created the post.
string content; // : The post content.
CommentNode* comments; // : A linked list to store comments on this post.
PostNode* next;
};

class FacebookNewsFeed {

PostNode* head;

public:

void insert_post();
void add_comment(int user_id, int post_id);
void view_all_posts(int user_id);
void view_all_comments(int user_id, int post_id);
void delete_post(int user_id, int post_id);
PostNode* search_posts(int user_id, int post_id);

};

Page 2
National University
Of Computer & Emerging Sciences Faisalabad-Chiniot Campus

Problem 01:
You have to design create post and add comment functionality in the above ADT that inserts a new
post node in the list and can inserts a new comment node in the comments list to a specific post.

You are required to implement a menu driven program that has following options:
1. Create new post
2. View all posts of a specific user (by getting userID)
3. Add comment to a specific post (by getting user_id and post_id)
4. View all comments of a specific post (by getting user_id and post_id)

Problem 02:
Append delete post functionality to the above menu driven program that deletes a specific post by
getting user_id and post_id as input from user and passing it to the function using the above ADT.

Problem 03:
Append search post functionality to the above menu driven program that searches a specific post by
getting user_id and post_id as input from user and passing it to the function using the above ADT.

Best of luck

Page 3
National University
Of Computer & Emerging Sciences Faisalabad-Chiniot Campus
You are done with your exercise, submit on Classroom at given time.

Page 4

You might also like