Select Your Subject Code

CS - Computer Science MGT MTH ECO ENG STA PAK PHY ACC
CS001 CS408 CS602 CS619 CS710 CS724 MGT101 MGT501 MGT610 MTH001 MTH603 ECO401 ENG001 STA301 PAK301 PHY101 ACC311
CS101 CS410 CS604 CS701 CS711 CS726 MGT201 MGT502 MGT611 MTH100 MTH201 ECO402 ENG101 STA630 PAK302 PHY301 ACC501
CS201 CS501 CS605 CS702 CS712 CS305 MGT211 MGT503 MGT613 MTH101 MTH203 ECO403 ENG201 STA730


CS301 CS502 CS606 CS703 CS713 CS411 MGT301 MGT510 MGT619 MTH202 MTH311 ECO404 ENG301



CS302 CS504 CS607 CS704 CS716 CS412 MGT401 MGT520 MGT620 MTH301 MTH502 ECO406 ENG401



CS304 CS506 CS609 CS706 CS718 CS413 MGT402 MGT601 MGT703 MTH302
ECO704




CS401 CS507 CS610 CS707 CS720 CS509 MGT404 MGT602 MGT704 MTH401
ECO501




CS402 CS508 CS614 CS708 CS721 CS621 MGT411 MGT603 MGT705 MTH501






CS403 CS601 CS615 CS709 CS723 CS622 MGT501 MGT604 MGT711 MTH601

CS301 Assignment no 1 Solution Fall 2016

By:


CS301 Assignment no 1

Here You can easily download CS301 Assignment Solution - Data Structures. CS301 Assignment No. 1 Semester: Fall 2016CS301 Data Structures .CS301 Assignment Total Marks: 20. CS301 Assignment Due Date: November 16, 2016.

CS301 Assignment Instructions

Please read the following instructions carefully before submitting assignment:
It should be clear that your assignment will not get any credit if:

  • Assignment is submitted after due date.
  • Submitted assignment does not open or file is corrupt.
  • Assignment is copied (From internet/ to from students).
You May also Read: CS401 Mid Term Past Papers / Notes

Note: For clarity and simplicity, You are required to Upload/Submit only ONE .CPP file if needed.
Keep all your files (word and .cpp) in a folder and make its zipped file to upload on LMS.
Use ONLY Dev-C++ IDE for writing and executing your code.
You May also Read: CS501 Assignment no. 01 Solution Fall 2016

CS301 Assignment Objectives:

The purpose of this assignment is to make you familiar with following topics:
  • Singly Linked List, Double Linked List and Circular Linked List
  • Infix to Postfix
  • C++ Templates
  • Implementation of Stack
  • Function Call Stack

CS301 Assignment Submission Instructions

You have to submit only word file on the Assignments interface of CS301 at VULMS. Assignment submitted in
any other format will not be accepted and will be graded zero marks.

You May also Read: CS201 Assignment No 01 Solution / Discussion Fall 2016

CS301 Assignment no. 1 Fall 2016

CS301 Assignment Question 1:

marks: 10
CS301 Assignment no 1 Solution Fall 2016
CS301 Assignment no 1 Question no 1 Fall 2016

Given is a code of abstract class declaration for a list (ADT) in Figure 1(a).

Figure 1(a)
(a) Assume a list has the following configuration: < | 2, 23, 15, 5, 9 >Write only Method calls (Name of function) using the List ADT of Figure 1(a) to delete the element with value
15.
e.g To move the pointer to end of the list We will use function movetoEnd( ). No need to write function implementation.

Note: Here the ‘|’ symbol represents ‘fence’ like pointer that indicates the current position of pointer in list.

(b)  Show the list configuration resulting from each series of list operations using the List ADT of Figure 1(a)

Assume that list L1 is empty at the beginning of each series. Show where the fence is in the list.

L1.append(10);
L1.append(20);
L1.append(15);

CS301 Assignment Question 2: 

marks: 10

Given is an infix expression:

A + B * C / (D-B)

Write a complete program in C++ to convert the above infix expression into postfix notation.

CS301 Assignment Deadline:

Your CS301 Assignment must be uploaded on or before November 16, 2016. We shall not accept your solution through email after the due date.

CS301 Assignment no 1 Solution Fall 2016

CS301 Solution Correct

CS301 Assignment Question no. 1 Solution:

#include
using namespace std;

struct node
{
int data;
struct node *next;
};

class stack
{
struct node *top;
public:
stack()
{
top=NULL;
}
void push();
void pop();
void show();
};

void stack::push()
{
int value;
struct node *ptr;
cout"Enter Item number to insert : ";
cin>>value;
ptr=new node;
ptr->data=value;
ptr->next=NULL;
if(top!=NULL)
ptr->next=top;
top=ptr;
cout"\n New item is inserted to the stack!!!";

}

void stack::pop()
{
struct node *temp;
if(top==NULL)
{
cout"\n The stack is empty!!!";
}
temp=top;
top=top->next;
cout"\n Remove Item \n ============ \n Item number " temp->data;
cout" is removed";
delete temp;
}

void stack::show()
{
struct node *ptr1=top;
cout"\n Pruchased Items are :\n";
while(ptr1!=NULL)
{
coutptr1->data" ->";
ptr1=ptr1->next;
}
cout"NULLn";
}

int main()
{
stack s;
int choice;
while(1)
{
cout"\n-------------- *Zohaib* -----------------\n------------- khan--------------------";
cout"\n------------- bc130201551---------------\n------------- Student Of BsCs----------------";
cout"\n ------------ Purchased Module -------------------------";
cout"\n MENU\n ====\n1:Insert Item\n2:Remove Item\n3:DISPLAY Purchased Item \n4:EXIT";
cout"\n Enter your choice(1-4): ";
cin>>choice;
switch(choice)
{
case 1:
s.push();
break;
case 2:
s.pop();
break;
case 3:
s.show();
break;
case 4:
return 0;
break;
default:
cout"Please enter correct choice(1-4)!!";
break;
}
}
return 0;
}

CS301 Assignment Question no. 2 Solution:

#include
#include//import Stack STL
#include//import String STL
#include
using namespace std;

string infixToPostfix(string expr); //Function declaration
int precendence(char arg);
bool isoperand(char arg);
bool isoperator(char arg);
int operatorweight(char arg);
bool highprecendence(char a, char b);

int main()
{
string exp;//Variable to get input expression
cout"Enter the infix expression:";
getline(cin,exp);
cout"Output Postfix Expression:"infixToPostfix(exp);
getch();
}

string infixToPostfix(string expr)//Function to perform all conversion operation
{

stack stk;//Declaring a stack for conversion purpose
string postfix = "";//Initialize the output string as empty;
for(int i = 0;i < expr.length(); i++)//Scan the infix string one by one
if(expr[i] == '(')
{
stk.push(expr[i]);
}
else if(expr[i] == ')')
{
while(stk.top() != '(')
{
postfix = postfix + stk.top();
stk.pop();
}
stk.pop();
}
else if(isoperand(expr[i]))
{
postfix += expr[i];
}
else if(isoperator(expr[i]))
{
while(!stk.empty()&& !highprecendence(expr[i],stk.top()))
{
postfix+= stk.top();
stk.pop();
}
stk.push(expr[i]);
}
while(!stk.empty())
{
postfix+= stk.top();
stk.pop();
}
return postfix;
}

bool highprecendence(char a, char b)//Check for operator precendence
{
int weighta = operatorweight(a);
int weightb = operatorweight(b);
if(weighta >= weightb) return 1;
return 0;
}

bool isoperator(char arg)//Check weather the character is operator
{
if(arg == '*' || arg == '/' || arg == '+' || arg == '-') return(1);
else return(0);
}
bool isoperand(char arg)//Check weather the character is operand
{
if(arg >= '0' && arg <= '9') return 1;
if(arg >= 'a' && arg <= 'z') return 1;
if(arg >= 'A' && arg <= 'Z') return 1;
return 0;
}

int operatorweight(char arg)//Add weight to the operator
{
int weight = 0;
switch(arg)
{
case '*':
case '/':
weight = 2;
break;
case '+':
case '-':
weight = 1;
break;
}
return(weight);
}

Download Links for CS301 Assignment Files:

Untitled4.cpp, 2 KB
Untitled4.exe, 1.9 MB

4 comments:

  1. cs301 assignment no 1 ka question no 1 ka solution hai to pllllllzzzz request hai dy dyn muje plzzz

    ReplyDelete
    Replies
    1. cs301 Assignment Question no. 1 solution has been Updated.

      Delete
  2. Please upload solution of question no. 1

    ReplyDelete
    Replies
    1. cs301 Assignment Question no. 1 solution has been Updated.

      Delete