1 Assignment 1 Data Structures and Algorithms Pointers, Linked Lists & ADTs Due Date :…
- User
1 Assignment 1 Data Structures and Algorithms Pointers, Linked Lists & ADTs Due Date : 25 January, 2024 Total Marks: 100 General Instructions The assignment must be implemented in C. The submission format is given at the end of the assignment. Grading of the assignment would not only be based on the working of the functionalities required to be implemented, but also the quality of code that is written and performance in the viva during the evaluations. The deadline is strict and will not be extended. Resorting to any sort of plagiarism (as mentioned in the policy shared) would be heavily penalised. Some sections of the assignment have been marked as Bonus. Any marks lost in the non-bonus section, can be made up for by doing the Bonus section. It must be noted, that Bonus marks would not provide extra marks in the assignment, they can just cover up for lost marks in the non-bonus section. Social Media Platform ADT 2 • • • • • • The task involves defining and implementing a social media platform ADT, that can handle features related to posts, comments and replies via a set of commands through the terminal. 1
2.1 File Structure The code must be made modular, consisting of the following files to define and implement the required ADTs:
- post.h & post.c
- comment.h & comment.c 3. reply.h & reply.c
- platform.h & platform.c 5. main.c It is allowed to make any other helper files, if necessary. 2.2 Data Types [15] 2.2.1 Post [5] The posts on the social media platform must store the following information:
- Username : Username of the user posting (Always a single string) 2. Caption : Caption to the post by the user
- Comments : List of comments on the post, by different users 2.2.2 Comment [5] The comments on the posts must store the following information: 1. Username : Username of the user commenting
- Content : Content of the comment
- Replies : List of replies to the comment by different users 2
2.2.3 Platform [5] The social media platform ADT, must store the following information:
- Posts : Lists of posts stored in some order of the time they were posted at
- lastViewedPost : The last viewed post on the terminal. By view, it means the one of which the details were shown latestly. If this does not hold for any post, it is the most recently added post till now. Note: Make Platform a global instance as it will only be created once. 2.2.4 Reply [Bonus][5] The replies to the comments on a post must store the following information: 1. Username : Username of the user replying
- Content : Content of the reply 2.3 Functions [60] For each of the ADTs, implement the following functions: 2.3.1 Post [5] 2.3.2 Comment [5] Function Name Parameters Return Value Description createPost char* username, char* caption Post* Creates a post using the given param- eters, returning a pointer to it Function Name Parameters Return Value Description createComment char* username, char* content Comment *comment Creates a comment using the given pa- rameters, returning a pointer to it 3
- Assistant
- User
Give function for previous post and next post and how it’s called
- Assistant
- User
Give viewpost
- Assistant
The
viewPostfunction is responsible for retrieving the n-th recent post from the social media platform. To implement this function efficiently, you would typically maintain a collection of posts, ordered by the time they were posted. If using dynamic data structures like linked lists, it might look something like this:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.