Assignments

CS301 Assignment 1 Solution Fall 2026

CS301 Data Structures teaches you to build data structures from scratch. Assignment 1 for Fall 2026 carries 20 marks and the due date is 3 November 2026, and it asks you to build a Clothes Pile Management System using a stack implemented with a singly linked list. Clothes are pushed in a given order, more clothes are added based on the last digit of your VU ID, three clothes are popped, and the final pile is displayed.

The solution file linked below is a complete, working C++ program. It defines a Node class and a Stack class with push, pop, and display operations, and a Main function that follows the assignment steps exactly. The program was compiled with g++ and run, and the output below matches the actual run.

What Does the Solution File Cover?

The file covers the complete clothes pile program. The Node class holds one clothing item and a pointer to the next node. The Stack class keeps a top pointer and provides pushCloth to add an item on top, popCloth to remove the top item, and displayClothStack to print all items from top to bottom. A destructor releases all remaining nodes.

How Does the Program Work Step by Step?

Step 1 pushes six clothes in this order: Jeans, Shirt, Trousers, Socks, Cap, Jacket. Because a stack shows the last item pushed on top, the pile from top to bottom reads Jacket, Cap, Socks, Trousers, Shirt, Jeans. Then the program reads the last digit of the VU ID. With the sample ID BC123456789, the last digit is 9, which is greater than 5, so Sweater and Pant are pushed. If the last digit were 5 or less, only Sweater would be added. Step 2 pops exactly three clothes from the top: Pant, Sweater, Jacket. Step 3 displays the final pile from top to bottom: Cap, Socks, Trousers, Shirt, Jeans.

Why Does the Stack Order Matter?

Because a stack is last-in, first-out. The last item pushed is always the first one popped, which is why Jacket sits on top after Step 1 and why the three pops remove Pant, Sweater, and Jacket in that order. If you change the push order or the last digit, the final pile changes, so always use your own VU ID.

How Do You Download the Solution File?

You can download the complete solution file from Google Drive using the link below. The file is a .cpp file. Replace the sample VU ID with your own before running or submitting, as noted in the file itself, and check the submission format on your own VULMS assignment page.

How Should You Use This Solution?

A solution file helps most when you use it to learn, not just to submit. First, trace the push and pop operations by hand and predict the final pile before running the program. Then change the VU ID to one ending in 5 or less and confirm that only Sweater is added and the final pile changes. Also check your work against the exact assignment file on VULMS, since question wording can vary.

  • Download the .cpp file and replace the sample VU ID with your own.
  • Compile and run it, and compare the output with the steps above.
  • Trace each push and pop by hand to see the stack order.
  • Try a VU ID ending in 5 or less and watch the result change.
  • Check every part against your own question file on VULMS.

For more study material, you can download course handouts from the VU handouts page and compact revision notes from the VU short notes page. Past papers are also useful for data structure practice, and you can find them on the VU midterm past papers page.

Frequently Asked Questions

Is this the complete solution for CS301 Assignment 1 Fall 2026?

Yes. The file is a complete C++ program with the Node and Stack classes and the Main function following all three steps. The assignment carries 20 marks and the due date is 3 November 2026.

Why does the last digit of my VU ID change the answer?

Because the assignment rule depends on it: if the last digit is greater than 5, Sweater and Pant are added, otherwise only Sweater is added. That changes which three items get popped and what the final pile looks like, so you must use your own VU ID.

What is the final pile with the sample VU ID?

With BC123456789, the last digit is 9, so Sweater and Pant are added, three items are popped (Pant, Sweater, Jacket), and the final pile from top to bottom is Cap, Socks, Trousers, Shirt, Jeans.

Last updated: October 2026.

Hostinger - Get 20% OFF

Habib ur Rehman

Hello! I'm the founder of VU Tech Geek. As a BSCS graduate and experienced WordPress professional, I'm passionate about technology and education. My Virtual University journey has given me valuable insights and knowledge, which I love to share with fellow students.… More »

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker