0% found this document useful (0 votes)
13 views

CS200 Assignment 3-Linked List

This document provides guidelines for Assignment 03 on linked lists. Students must create a Linked List class to represent an "Entangled Web" data structure. The class should include functions to initialize the grid, find the next node to visit based on the current node's data, check if a target node exists, change a node's data, and print visited nodes and the full structure. The main goal is to start at the top-left node and follow a path through the grid to locate a target node based on the given formulas. Students will be marked on correctly implementing the Linked List class and its functions.

Uploaded by

Muneeb
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)
13 views

CS200 Assignment 3-Linked List

This document provides guidelines for Assignment 03 on linked lists. Students must create a Linked List class to represent an "Entangled Web" data structure. The class should include functions to initialize the grid, find the next node to visit based on the current node's data, check if a target node exists, change a node's data, and print visited nodes and the full structure. The main goal is to start at the top-left node and follow a path through the grid to locate a target node based on the given formulas. Students will be marked on correctly implementing the Linked List class and its functions.

Uploaded by

Muneeb
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

CS 200 Assignment 03 Spring 2024.

13 March 2024

CS200 Introduction to Programming


Instructor (Section1): Shafay Shamail
Linked Lists
TA: Fasih Ud Din( [email protected] )
Release Date: 14 March 2024 Submission Date: 24 March 2024
Guidelines
1. All assignments are individual.
2. Your code should not crash in any case.
3. All data members should be private.
4. For each class write the default constructor, destructor, parametric constructor(s), setters and getters.
5. Failure in following the above rules can lead to deduction in marks.
6. Put all cpp (and header) files into a folder YourRollNo_AX and submit it on LMS (Assignments >
AssignementX) within the due date. Dropbox/email submissions will be given zero!
7. Please make sure that you have gone through the Assignment Statement before starting the lab.
8. Objective is not simply to get the job done, but to get it done in the way that is asked for in the assignment.
9. Do not share your code. Do not plagiarize. Copying/sharing code is strictly prohibited. Using any unfair
means will lead to immediate disqualification.
10. Any cheating case will be reported to Disciplinary Committee without any delay.

Programming Conventions
(See: C++ Language Coding Guidelines)

1. Use tabs instead of spaces.


2. Variable names are lowercase.
3. Constant names are uppercase.
4. Function names are first word small, all other words camel case. For example, thisIsAFunction().
5. Class names start with an uppercase letter, and all following words are camel case. For example,
ThisIsAClass.
6. There are spaces after reserved words and between binary operators.
7. Braces must be vertically aligned.
8. No magic numbers may be used.
9. Every function must have a comment.
10. At most 30 lines of code may be used per function.
11. Global variables are not allowed unless specifically instructed.
12. Inline functions are not allowed.
13. Use of goto statement is not allowed.

Assignment Marks Distribution

Total
100
Move to the next page to view the assignment.

Let’s Begin …
CS 200 Assignment 03 Spring 2024. 13 March 2024

Entangled Web
Achieving your goals primarily depends on hard work and following the clues, with luck playing a
secondary role. Your objective is to reach the target node within the interconnected network of linked
lists called Entangled Web shown in Figure 1.

Each node will have following members:

• int data
• node* up
• node* down
• node* left
• node* right

Figure 1: Entangled Web

The Linked List structure you must create will look similar to the structure shown in Figure 1 Entangled
Web. You will have to search for the target node in such a grid.

To find the target node, you will start from the top-left most node of the grid and then jump to the next
node in the sequence using the ‘data’ as a clue. Also, note that the value of ‘data’ for each node must be
unique and positive.

The location of the next node to visit will be discovered using the following formulas:

• Row of next node = (sum of all digits in data % number of rows) + 1


• Column of next node = number of digits
• Target Node = the node for which the formulas will point you to the node itself.
CS 200 Assignment 03 Spring 2024. 13 March 2024

Sample Input:
Figure 2 shows a sample input to your program.

Figure 2: A Sample Entangled Web

Output:
• 3401->18->7017->2->118->101
• Target Node = 101

Implement:
• Accurate creation of the Node. [5]
• Accurate creation of the Linked List Class along with its associated Constructors, Parameterised
Constructors, Destructors, and proper member variables specified above. [10]
• Member function to take as input the dimensions of the grid to be created as well as the data to
be stored in each node. Store each acquired information in a suitable data type and data
structure. [10]
• Member function printEntagledWeb(Node* ) [6]
o Prints the Entangled Web that has been created
• Member function nextRow(int data) [5]
o Returns the row number of the next node to be visited (1st row is called row 1).
• Member function nextColumn(int data) [5]
o Returns the column number of the next node to be visited (1st column is called column
1).
CS 200 Assignment 03 Spring 2024. 13 March 2024

• Member function isNodePresent(int data) [10]


o Returns a bool variable according to the existence of the node you are supposed to search
for. If node found, return true. Otherwise, return false.
• Member function changeNode(int data, int value) [5]
o Searches for the ‘data’ node and then updates its data member to ‘value’.
• Member function visited(Node* Current) [5]
o Prints the data of the node you’re currently at. You need to print all the nodes you visit
while reaching the target node.
• Member function targetNodeFound(Node* target) [6]
o When target node is found, send it to this function to print the data and an appropriate
message that the target node has been found. Also print the Entangled Web.
o However, if there doesn’t exist any target node, your program should be able to display a
message for it. [6]
o Also, if any node gets visited for the second time, the program should end after displaying
a meaningful message. [6]
• Make a main() function to test the functionality of the code. All the functions should be tested on
all the scenarios outlined above. [10]
• Implement Error Handling mechanisms such as checking for invalid inputs (e.g., negative
dimensions) and handling edge cases gracefully. [6]
• Also note that you have the liberty to add more member variables to aid in this task but include a
reason for each additional member variable you create. [5]

End of Assignment 03

You might also like