Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CS301 Data Structures Assignment No 01 idea solution spring 2011
#11
xprt bachy kitnimintain ker rahy hain plz upload the solution file as soon as possible
plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
Reply
#12
xprt plz upload karo na ab to extended day b guzerny wala hai
plz jald upload ker dein plz
Reply
#13
pta ni cs301 ka thek slution kiun upload ni kea gia.
Reply
#14
The program is used to convert a infix expression to a postfix expression using stack data structure

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>



const int size =50;
char infix[size],postfix[size],stack[size];
int top=-1;

int precedence(char ch); // function to get the precedence of the operator
char pop(); //function to pop an element from the stack
char topelement(); // returns the top element of the stack
void push(char ch); // pushes an element into the stack



int main()
{
char ele,elem,st[2];
int prep,pre,popped,j=0,chk=0;
strcpy(postfix," ");

gets(infix);

for(int i=0;infix[i]!=0;i++)
{
if(infix[i]!='('&&infix[i]!=')'&&infix[i]!='^'&&infix[i]!='*'&&infix[i]!='/'&&infix[i]!='+'&&infix[i]!='-')
postfix[j++]=infix[i];
else if(infix[i]=='(')
{
elem=infix[i];
push(elem);
}
else if(infix[i]==')')
{
while(popped=pop() != '(')
postfix[j++]=popped;
}
else
{
elem=infix[i];
pre=precedence(elem);//stores the precedence of operator coming frm infix
ele=topelement();
prep=precedence(ele);//stores the precedence of operator at the top of the stack

if(pre > prep)
push(elem);

else
{
while(prep >= pre)
{
if(ele=='#')
break;
popped=pop();
ele=topelement();
postfix[j++]=popped;
prep=precedence(ele);
}
push(elem);
}
}
}

while((popped=pop())!='#')
postfix[j++]=popped;
postfix[j]='\0';

cout<<"\n post fix :"<<postfix<<endl;

system("pause");
return 0;
}

int precedence(char ch)
{
switch(ch)
{
case '^' : return 5;
case '/' : return 4;
case '*' : return 4;
case '+' : return 3;
case '-' : return 3;
default : return 0;
}
}

char pop() //function to pop the element from the stack
{
char ret;
if(top!=-1)
{ ret =stack[top];
top--;
return ret;
}
else
return '#';
}

char topelement() // function to return top element from the stack without popping
{
char ch;
if(top!=-1)
ch=stack[top];
else
ch='#';
return ch;
}

void push(char ch) // function to push an element in the stack
{
if(top!=size-1)
{
top++;
stack[top]= ch;
}
}
Reply
#15
upload solution plzzzzzzzzzzzzz.... only 2hour left :-(
Reply
#16
[SIZE="2"][SIZE="2"][COLOR="rgb(139, 0, 0)"]full solution in attachment [/COLOR][/SIZE][/SIZE]

Header File Source

#ifndef LINKEDLIST_H
#define LINKEDLIST_H
#include <i ostream>
using name space std;
template <class T>
class LList

{
Private:
class ListNode
{
friend class LList<T>;
T value;
ListNode *nest;
ListNode(T value1, ListNode *next1=NULL)

{
value=value1;
next=next;
}
};
ListNode *head;
public:
LList()
{
head=NULL;
)
~LList();
void appendNode(T);
void insertNode(T);
void deleteNode();
voide displayList();
void MoveNext();
void ShowCurrent();
};

template<class T>
voidLList<T>::appendNode(T val)
{
if(head=NULL)
head=new ListNode(val);
else
{
ListNode *nodePtr;

while (nodePtr->next !=NULL)

nodePtr->next=new ListNode(val);
}
}


template<class T>
voidLList<t>::displayList()
{
ListNode *nodePtr;
nodePtr =head;
while (nodePtr)
{
cout << nodePtr->value << endl;
nodePtr =nodePtr->next;
}
}

template<class T>
voidLList<T>::ShowCurrent()
{
ListNode *nodePtr;
nodePtr=head;
count<<nodePtr->value<< endl;
}

template<class T>
voidLList<T>::MoveNext()
{
ListNode *nodePtr;
nodePtr=head;
while (nodePtr)
{
nodePtr = nodePtr->next;
}
}

template<class T>
voidLList<T>::insertNode(T val)


Attached Files
.zip   CS301 Complete Solution.zip (Size: 11.71 KB / Downloads: 92)
Reply
#17
Plz jaldi se assignment ka solution post kr den na! bilkul bhi idea nahi ho raha.today is last day.kuch ghanty hi rah gaye hn.plzzz plz plz...
Reply
#18
vu helper 35 total errors Tongue
Reply
#19
Instructions
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit (zero marks) if:
o The assignment is submitted after due date.
o The submitted code does NOT compile.
o The submitted assignment does NOT open or file corrupt.
o The assignment is copied (from other student or ditto copy from handouts or internet).
Uploading instructions
Your Submission must include:
  1. A working Make File (Dev-C++ project File).
  2. All the Source Code (.h and .cpp files) necessary to compile and run your program.
  3. Place all the files in a folder then Zip this folder and Upload it on VU-LMS

Note: Use Dev-C++ IDE.
Objective
The objective of this assignment is

o To give you some practice exercise of Stack Data Structure.

For any query about the assignment, contact at cs301@vu.edu.pk
GOOD LUCK

Marks: 20
Write a C++ program to evaluate postfix expressions. Your program should take postfix expression as an input, process it with the help of stack and display the result after performing required calculations.

Only following Binary operators are allowed for this program:
+, -, *, /, ^ [addition, subtraction, multiplication, division, exponentiation]

If some error occurs while processing postfix expression, your program should display a meaningful message, like:
Error: Division by zero not allowed
Error: Two operands required for __ operator
Error: Invalid postfix expression

Sample Run:
Enter postfix expression to evaluate:
10 20 + Entered by user

The result is: 30

Do you want to enter another postfix expression to evaluate? [Y/N]
Y Entered by user

Enter postfix expression to evaluate:
30 40 + * Entered by user

Error: Two operands required for * operator

Do you want to enter another postfix expression to evaluate? [Y/N]
Y Entered by user

Enter postfix expression to evaluate:
30 40 + 50 60 * Entered by user

Error: Invalid postfix expression

Do you want to enter another postfix expression to evaluate? [Y/N]
Y Entered by user

Enter postfix expression to evaluate:
6 2 3 + - 3 8 2 / + * 2 ^ 3 + Entered by user

The result is: 52

Do you want to enter another postfix expression to evaluate? [Y/N]
N Entered by user

Thank you for using this program.
Lectures Covered: This assignment covers Lecture # 5-9
Deadline: Your assignment must be uploaded/submitted at or before 17-Nov-2011.
Reply
#20
need solution of above cs301 datastructure
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  CS301 Assignment # 4 Due Date: 02-Feb-2016 Vuhelper 0 2,323 02-03-2016, 05:38 PM
Last Post: Vuhelper
  CS703 – Advanced Operating Systems Assignment No.3 solution January 2016 Vuhelper 0 5,910 01-23-2016, 09:58 PM
Last Post: Vuhelper
  CS601 Data Communication Assignment No. 03 Solution 23rd January 2016 Vuhelper 1 1,929 01-23-2016, 06:09 PM
Last Post: Vuhelper
  CS403 Assignment No. 03 Solution 23rd January 2016 Vuhelper 2 1,166 01-23-2016, 03:18 PM
Last Post: Vuhelper
  CS506 Web Design and Development Assignment no 3 Solution 3rd January 2016 Vuhelper 0 2,243 01-23-2016, 03:16 PM
Last Post: Vuhelper
  CS724 Software Process Improvement Assignment No 01 Solution 20th January 2016 Vuhelper 0 1,969 01-20-2016, 06:26 PM
Last Post: Vuhelper
  CS711 Software Design Assignment No 01 Solution Due Date Feb 12, 2016 Vuhelper 0 1,666 01-20-2016, 06:24 PM
Last Post: Vuhelper
  CS709 Formal Methods for Software Engineering Assignment No 01 Solution January 2016 Vuhelper 0 1,804 01-20-2016, 06:22 PM
Last Post: Vuhelper
  cs703 assignment no 3 Solution 20th January 2016 Vuhelper 0 1,702 01-20-2016, 06:20 PM
Last Post: Vuhelper
  CS704 Assignment No. 01 Solution January 2016 Vuhelper 0 4,800 01-20-2016, 06:19 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)