Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

CS301 – Data Structures

Assignment No.  1
Semester: Spring 2021

#CS301 Assignment 1 Solution 2021 Spring

Instructions:

Please read the following instructions carefully before submitting the assignment solution:

It should be clear that your assignment will not get any credit/marks if:

  • Assignment is submitted after due date.
  • Submitted assignment does not open or file is corrupt.
  • Assignment is copied (From internet/students).

Recommended Tools:

  • Dev C++

Objectives:

To enable students to understand and practice the concepts of:

  • Linked list implementation
  • Efficient memory management
  • Efficient use of pointer

Assignment Submission Instructions:

You have to submit only .zip file which will have code (.cpp) and screenshot image files on the assignments interface from your LMS account.

Assignment submitted in any other format will not be accepted and will be scaled with zero marks. No excuse will be accepted on submitting solution file in any other format.

Problem Statement:

In the lesson videos and handouts you learned to save only one integer element as data in a node. Please note, it is not compulsory to have only one value in a node. There can be more than one and different types of elements as data of a node but pointer will remain one for singly linked list. Write a C++ program to implement linked list data structure. In this problem every node should have two data elements called name and course of a student and a pointer to link the current node to the next node. Your program should prompt the user to enter name and course code of a https://vustd.com/mth603-assignment-1-solution-2021-spring/

Use the following course names and codes while entering the record of a student.


Course Name Course Code
Introduction to Computing 1
Introduction to Programming 2
Data Structures 3
Object Oriented Programming 4
#CS301 Assignment 1 Solution 2021 Spring

After saving the required information of all students, you need to perform following operations operated through menu showing in sample output video.

  • Show the names of students enrolled in a specific or all courses (user will enter a choice of operation).
  • Show the count of students enrolled in a specific or all courses (user will enter a choice of operation).
  • Option to close the program by selection from menu as showing in sample output video.
  • While testing your application and entering the record of first student, use your VU ID for the name of student. Take screenshot of your input which should be showing your VU ID entered as first student name. Zip your code (.cpp) and screenshot image files and submit zip file from your LMS account.

Sample Output:

For sample output watch the video file “A1 Sample Output.mp4” attached with this assignment file.

Lectures Covered: (Lecture # 1- 8) and Due date to submit solution: (Tuesday, May 18, 2021).

Views: 1402

Replies to This Discussion

Share the Assignment Questions & Discuss Here.... 

Stay touched with this discussion, Solution idea will be uploaded as soon as possible in replies here before the due date.

CS301 Assignment 1 Solution 2021 Spring

CS301 Assignment 1

Solution Spring 2021

#include <iostream> #include <string> #include <iostream> #include <string> #include <sstream> using namespace std;

class node{

public:

std::string name; short int coursecode; node* ptr;

};

class student{

private:

node* head; public:

student(){

head = ‘\0’;

}

void insertStu(node**,node*); void newNode();

void showAll(int code);

};

void student:: insertStu(node** head,node* newNode){ node* current;

if(*head==’\0′){

*head=newNode;

}else{

}

current=*head;

while(current->ptr !=’\0′){ current=current->ptr;

}

newNode->ptr=current->ptr; current->ptr=newNode; coutendl;

cout“Student information save successfully “;

}

void student:: newNode(){ short int courseCode; string stdName; coutendl;

cout“Enter Name of Student(vudaily.com)”endl; cin>>stdName;

cout “1 :Introduction to Computing(vudaily.com) “endl;

cout “2 :Introduction to Programming(vudaily.com) “endl;

cout “3 :Data Structure(vudaily.com) “endl;

cout “4 :Object Oriented Programming(vudaily.com) “endl;

coutendl;

cout“Enter Couse Code(vudaily.com)”endl; cin>>courseCode;

node* newNode=new node(); newNode->name;

newNode->coursecode=courseCode; newNode->ptr=’\0′;

insertStu(&this->head,newNode);

}

void student::showAll(int courseCode){ node* temp =head;

int count=0; if(temp==’\0′)

{

coutendl“No Record Found “endl;

}else{

while(temp!=’\0′){

if(courseCode==0){

count++;

cout“Student Name: “ temp->nameendl;

}

if(temp->coursecode==courseCode){ count++;

cout“Student Name : “ temp->nameendl;

}

temp=temp->ptr;

}

cout“Enrollment cout :”coutendl ;

}

}

int main (){

student *myList=new student();

bool check=true,exist=true; char choice;int newChoice; do{

myList->newNode();

coutendl “Do you Want to Enter Another Student:(vudaily.com) “endl; cin>>choice;

coutendl;

if(choice==’n’ || choice==’N’){ check=false;

}

}while(check);

do{

cout“0: Display All STudent”endl ;

cout“1: Display All Student Introduction to Computing”endl ; cout“2: Display all STudent Introduction to

Programming”endl ;

cout“3: Display all sudent dat structure”endl ;

cout“4: Display all student Object Oriented

Programming”endl ;

cout“5: Close Program “endl; cin>>newChoice;

switch(newChoice){

case 0:

cout“Following Student Enroll in all Subjet “endl; myList->showAll(newChoice);

break;

Computing “endl;

Programming “endl;

“endl;

case 1:

case 2:

case 3:

case 4:

cout“Following Student Enroll in Introduction to myList->showAll(newChoice);

break;

cout“Following Student Enroll inIntroduction to myList->showAll(newChoice);

break;

cout“Following Student Enroll in Data Structure myList->showAll(newChoice);

break;

Programming “endl;

case 5:

cout“Following Student Enroll in Object Oriented

myList->showAll(newChoice); break;

cout“Close Program”;

exist=false; exit(0); break;

default :

exist=false; exit(0);

}

}while(exist);

}

THE END

CS301 Data Structures Assignment 01 Spring 2021 Solution

#include <iostream>
#include <string>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
class node{
public:
std::string name;
short int coursecode;
node* ptr;
};
class student{
private:
node* head;
public:
student(){
head = '\0';
}
void insertStu(node**,node*);
void newNode();
void showAll(int code);
};
void student:: insertStu(node** head,node* newNode){
node* current;
if(*head=='\0'){
*head=newNode;
}else{
current=*head;
}
while(current->ptr !='\0'){
current=current->ptr;
}
newNode->ptr=current->ptr;
current->ptr=newNode;
coutendl;
cout"Student information save successfully ";
}
void student:: newNode(){
short int courseCode;
string stdName;
coutendl;
cout"Enter Name of Student"endl;
cin>>stdName;
cout "1 :Introduction to Computing"endl;
cout "2 :Introduction to Programming"endl;
cout "3 :Data Structure"endl;
cout "4 :Object Oriented Programming"endl;
coutendl;
cout"Enter Code"endl;
cin>>courseCode;
node* newNode=new node();
newNode->name;
newNode->coursecode=courseCode;
newNode->ptr='\0';
insertStu(&this->head,newNode);
}
void student::showAll(int courseCode){
node* temp =head;
int count=0;
if(temp=='\0')
{
coutendl"No Record Found "endl;
}else{
while(temp!='\0'){
if(courseCode==0){
count++;
cout"Student Name: " temp->nameendl;
}
if(temp->coursecode==courseCode){
count++;
cout"Student Name : " temp->nameendl;
}
temp=temp->ptr;
}
cout"Enrollment cout :"coutendl ;
}
}
int main (){
student *myList=new student();
bool check=true,exist=true;
char choice;int newChoice;
do{
myList->newNode();
coutendl "Do you Want to Enter Another Student:"endl;
cin>>choice;
coutendl;
if(choice=='n' || choice=='N'){
check=false;
}
}while(check);
do{
cout"0: Display All STudent"endl ;
cout"1: Display All Student Introduction to Computing"endl
cout"2: Display all STudent Introduction to Programming"endl ;
cout"3: Display all sudent dat structure"endl ;
cout"4: Display all student Object Oriented Programming"endl ;
cout"5: Close Program "endl;
cin>>newChoice;
switch(newChoice)
case 0:
cout"Following Student Enroll in all Subjet "endl;
myList->showAll(newChoice);
break;
case 1:
cout"Following Student Enroll in Introduction to Computing "endl;
myList->showAll(newChoice);
break;
case 2:
cout"Following Student Enroll inIntroduction to Programming "endl;
myList->showAll(newChoice);
break;
case 3:
cout"Following Student Enroll in Data Structure "endl;
myList->showAll(newChoice);
break;
case 4:
cout"Following Student Enroll in Object Oriented Programming "endl;
myList->showAll(NewChoice);
break;
case 5:
cout"Close the Program";
exist=false;
exit(0);
break;
default :
exist=false;
exit(0);
}
}while(exist);
}

CS301 Assignment 1 Solution 2021 | CS301 Assignment No1 Solution Spring 2021

#cs301assignment1solution2021 #cs301assignmentsolution #advancescholars
CS301 Assignment 1 Solution 2021|Cs301 Assignment Solution|Advance Scholars

#cs301 #cs301assignment #cs301assignmentsolutionspring2021
CS301 Assignment 1 Solution Spring 2021 || Data Structures || 100% Correct Solution

CS301 Assignment 1 Solution 2021 Spring

CS301 Assignment 1

Solution Spring 2021

#include <iostream> #include <string> #include <iostream> #include <string> #include <sstream> using namespace std;

class node{

public:

std::string name; short int coursecode; node* ptr;

};

class student{

private:

node* head; public:

student(){

head = ‘\0’;

}

void insertStu(node**,node*); void newNode();

void showAll(int code);

};

void student:: insertStu(node** head,node* newNode){ node* current;

if(*head==’\0′){

*head=newNode;

}else{

}

current=*head;

while(current->ptr !=’\0′){ current=current->ptr;

}

newNode->ptr=current->ptr; current->ptr=newNode; coutendl;

cout“Student information save successfully “;

}

void student:: newNode(){ short int courseCode; string stdName; coutendl;

cout“Enter Name of Student(vudaily.com)”endl; cin>>stdName;

cout “1 :Introduction to Computing(vudaily.com) “endl;

cout “2 :Introduction to Programming(vudaily.com) “endl;

cout “3 :Data Structure(vudaily.com) “endl;

cout “4 :Object Oriented Programming(vudaily.com) “endl;

coutendl;

cout“Enter Couse Code(vudaily.com)”endl; cin>>courseCode;

node* newNode=new node(); newNode->name;

newNode->coursecode=courseCode; newNode->ptr=’\0′;

insertStu(&this->head,newNode);

}

void student::showAll(int courseCode){ node* temp =head;

int count=0; if(temp==’\0′)

{

coutendl“No Record Found “endl;

}else{

while(temp!=’\0′){

if(courseCode==0){

count++;

cout“Student Name: “ temp->nameendl;

}

if(temp->coursecode==courseCode){ count++;

cout“Student Name : “ temp->nameendl;

}

temp=temp->ptr;

}

cout“Enrollment cout :”coutendl ;

}

}

int main (){

student *myList=new student();

bool check=true,exist=true; char choice;int newChoice; do{

myList->newNode();

coutendl “Do you Want to Enter Another Student:(vudaily.com) “endl; cin>>choice;

coutendl;

if(choice==’n’ || choice==’N’){ check=false;

}

}while(check);

do{

cout“0: Display All STudent”endl ;

cout“1: Display All Student Introduction to Computing”endl ; cout“2: Display all STudent Introduction to

Programming”endl ;

cout“3: Display all sudent dat structure”endl ;

cout“4: Display all student Object Oriented

Programming”endl ;

cout“5: Close Program “endl; cin>>newChoice;

switch(newChoice){

case 0:

cout“Following Student Enroll in all Subjet “endl; myList->showAll(newChoice);

break;

Computing “endl;

Programming “endl;

“endl;

case 1:

case 2:

case 3:

case 4:

cout“Following Student Enroll in Introduction to myList->showAll(newChoice);

break;

cout“Following Student Enroll inIntroduction to myList->showAll(newChoice);

break;

cout“Following Student Enroll in Data Structure myList->showAll(newChoice);

break;

Programming “endl;

case 5:

cout“Following Student Enroll in Object Oriented

myList->showAll(newChoice); break;

cout“Close Program”;

exist=false; exit(0); break;

default :

exist=false; exit(0);

}

}while(exist);

}

THE END

CS301 Assignment No 1 Spring 2021 | Solution | Virtual University Of Pakistan.

Lectures Covered: (Lecture # 1- 8) and Due date to submit solution: (Tuesday, May 18, 2021).

CS301 Assignment 1 Solution 2021 Spring

#CS301 Assignment 1 Solution 2021 Spring
Assignment No.  1
Semester: Spring 2021

CS301 Assignment 1 Solution 2021 Spring

CS301 Assignment 1

Solution Spring 2021

#include <iostream> #include <string> #include <iostream> #include <string> #include <sstream> using namespace std;

class node{

public:

std::string name; short int coursecode; node* ptr;

};

class student{

private:

node* head; public:

student(){

head = ‘\0’;

}

void insertStu(node**,node*); void newNode();

void showAll(int code);

};

void student:: insertStu(node** head,node* newNode){ node* current;

if(*head==’\0′){

*head=newNode;

}else{

}

current=*head;

while(current->ptr !=’\0′){ current=current->ptr;

}

newNode->ptr=current->ptr; current->ptr=newNode; coutendl;

cout“Student information save successfully “;

}

void student:: newNode(){ short int courseCode; string stdName; coutendl;

cout“Enter Name of Student(vudaily.com)”endl; cin>>stdName;

cout “1 :Introduction to Computing(vudaily.com) “endl;

cout “2 :Introduction to Programming(vudaily.com) “endl;

cout “3 :Data Structure(vudaily.com) “endl;

cout “4 :Object Oriented Programming(vudaily.com) “endl;

coutendl;

cout“Enter Couse Code(vudaily.com)”endl; cin>>courseCode;

node* newNode=new node(); newNode->name;

newNode->coursecode=courseCode; newNode->ptr=’\0′;

insertStu(&this->head,newNode);

}

void student::showAll(int courseCode){ node* temp =head;

int count=0; if(temp==’\0′)

{

coutendl“No Record Found “endl;

}else{

while(temp!=’\0′){

if(courseCode==0){

count++;

cout“Student Name: “ temp->nameendl;

}

if(temp->coursecode==courseCode){ count++;

cout“Student Name : “ temp->nameendl;

}

temp=temp->ptr;

}

cout“Enrollment cout :”coutendl ;

}

}

int main (){

student *myList=new student();

bool check=true,exist=true; char choice;int newChoice; do{

myList->newNode();

coutendl “Do you Want to Enter Another Student:(vudaily.com) “endl; cin>>choice;

coutendl;

if(choice==’n’ || choice==’N’){ check=false;

}

}while(check);

do{

cout“0: Display All STudent”endl ;

cout“1: Display All Student Introduction to Computing”endl ; cout“2: Display all STudent Introduction to

Programming”endl ;

cout“3: Display all sudent dat structure”endl ;

cout“4: Display all student Object Oriented

Programming”endl ;

cout“5: Close Program “endl; cin>>newChoice;

switch(newChoice){

case 0:

cout“Following Student Enroll in all Subjet “endl; myList->showAll(newChoice);

break;

Computing “endl;

Programming “endl;

“endl;

case 1:

case 2:

case 3:

case 4:

cout“Following Student Enroll in Introduction to myList->showAll(newChoice);

break;

cout“Following Student Enroll inIntroduction to myList->showAll(newChoice);

break;

cout“Following Student Enroll in Data Structure myList->showAll(newChoice);

break;

Programming “endl;

case 5:

cout“Following Student Enroll in Object Oriented

myList->showAll(newChoice); break;

cout“Close Program”;

exist=false; exit(0); break;

default :

exist=false; exit(0);

}

}while(exist);

}

#cs301assignmentno1solutionspring2021
CS301 Assignment no 1 Solution Spring 2021 | Get Full Marks

CS301 Data Structures Assignment 01 Spring 2021 Solution

#include <iostream>
#include <string>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
class node{
public:
std::string name;
short int coursecode;
node* ptr;
};
class student{
private:
node* head;
public:
student(){
head = '\0';
}
void insertStu(node**,node*);
void newNode();
void showAll(int code);
};
void student:: insertStu(node** head,node* newNode){
node* current;
if(*head=='\0'){
*head=newNode;
}else{
current=*head;
}
while(current->ptr !='\0'){
current=current->ptr;
}
newNode->ptr=current->ptr;
current->ptr=newNode;
coutendl;
cout"Student information save successfully ";
}
void student:: newNode(){
short int courseCode;
string stdName;
coutendl;
cout"Enter Name of Student"endl;
cin>>stdName;
cout "1 :Introduction to Computing"endl;
cout "2 :Introduction to Programming"endl;
cout "3 :Data Structure"endl;
cout "4 :Object Oriented Programming"endl;
coutendl;
cout"Enter Code"endl;
cin>>courseCode;
node* newNode=new node();
newNode->name;
newNode->coursecode=courseCode;
newNode->ptr='\0';
insertStu(&this->head,newNode);
}
void student::showAll(int courseCode){
node* temp =head;
int count=0;
if(temp=='\0')
{
coutendl"No Record Found "endl;
}else{
while(temp!='\0'){
if(courseCode==0){
count++;
cout"Student Name: " temp->nameendl;
}
if(temp->coursecode==courseCode){
count++;
cout"Student Name : " temp->nameendl;
}
temp=temp->ptr;
}
cout"Enrollment cout :"coutendl ;
}
}
int main (){
student *myList=new student();
bool check=true,exist=true;
char choice;int newChoice;
do{
myList->newNode();
coutendl "Do you Want to Enter Another Student:"endl;
cin>>choice;
coutendl;
if(choice=='n' || choice=='N'){
check=false;
}
}while(check);
do{
cout"0: Display All STudent"endl ;
cout"1: Display All Student Introduction to Computing"endl
cout"2: Display all STudent Introduction to Programming"endl ;
cout"3: Display all sudent dat structure"endl ;
cout"4: Display all student Object Oriented Programming"endl ;
cout"5: Close Program "endl;
cin>>newChoice;
switch(newChoice)
case 0:
cout"Following Student Enroll in all Subjet "endl;
myList->showAll(newChoice);
break;
case 1:
cout"Following Student Enroll in Introduction to Computing "endl;
myList->showAll(newChoice);
break;
case 2:
cout"Following Student Enroll inIntroduction to Programming "endl;
myList->showAll(newChoice);
break;
case 3:
cout"Following Student Enroll in Data Structure "endl;
myList->showAll(newChoice);
break;
case 4:
cout"Following Student Enroll in Object Oriented Programming "endl;
myList->showAll(NewChoice);
break;
case 5:
cout"Close the Program";
exist=false;
exit(0);
break;
default :
exist=false;
exit(0);
}
}while(exist);
}

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service