5 Replies - 1573 Views - Last Post: 02 April 2007 - 09:47 PM Rate Topic: -----

#1 jeps1lon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-April 07

need help to complete project for class

Posted 01 April 2007 - 11:01 PM

New guy here. 23 year old math student minoring in computer science. Need some help. I know, i know i'm new, but I hope there is someone nice enough out there with the free time to help me out.

Anyways, I just found this site because I was looking for a code that does an infix to postfix conversion and I found it here. But that's not the problem.

I'm taking this class at my university called advanced algorithms and data structures. Currently, we have a project due, of which i'm already a week late. The professor has given me until April 5 to complete it. Thing is, I haven't been keeping up with the class because i'm taking 5 other math classes which have been taking up my time along with working for a local arcade.

So i'm here asking you guys desperately. Will one of you guys try to write the code for my project? I am running out of time and I need to pass this class.

Here are the links to the project handout.

pg1 http://img181.images...proj1pg1ky1.jpg
pg2 http://img181.images...proj1pg2vo0.jpg
pg3 http://img181.images...proj1pg3le0.jpg
pg4 http://img72.imagesh...proj1pg4pn6.jpg
pg5 http://img72.imagesh...proj1pg5ip8.jpg

This is the code I found, not sure if this is enough.
// the program is used to convert a infix expression to a postfix expression
 
#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;
		 }
} 


Thank you.

This post has been edited by jeps1lon: 01 April 2007 - 11:04 PM


Is This A Good Question/Topic? 0
  • +

Replies To: need help to complete project for class

#2 ajwsurfer  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 373
  • Joined: 24-October 06

Re: need help to complete project for class

Posted 02 April 2007 - 09:28 AM

Why don't you just get started with the interface of this project. (The person interfacing with the computer.) It is described in the second and third documents; "pg2vo0.jpg" and "proj1pg3le0.jpg". If you just have stub functions that place the input and output correctly, you will have a jump on this thing.

Remember: write a few lines and test. Write a few lines and test... etc.

Next, the code you found will probably not be enough. An algorithm course more than likely will expect that the data structures be placed inside classes. Even if they don't require data structures inside of classes, it will probably benifit your sanity in a big way.

Once you have the interface with the stub functions and the data structure class, your math major will be of great benifit to you in tying the whole thing together.

I don't think that we are here to do your homework for you, but we can give you suggestions.

If you would like to post some code that you have written, I would be happy to point you in the right direction. (This program is small and could probably be written in a few hours or a day, if things are going well. But I can't guaranty things will go well.)
Was This Post Helpful? 0
  • +
  • -

#3 jeps1lon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-April 07

Re: need help to complete project for class

Posted 02 April 2007 - 11:39 AM

View Postajwsurfer, on 2 Apr, 2007 - 09:28 AM, said:

I don't think that we are here to do your homework for you, but we can give you suggestions.


I don't see what the big deal is by asking if someone can do this for me?

I mean, It's not like you guys have anything to lose. I'm sure there is someone out there with a ton of c++ experience who can complete this in a matther of an hour or so. That's all i'm asking for. Like I said, i'm in dire need right now. It is due this thursday and I honestly don't have the time to sit down and thoroughly focus and complete this by then. Time is not my friend right now.

So all i'm asking for is that, some big help.

Someone, please. I'll send you $10 through paypal to compensate for your services.

This post has been edited by jeps1lon: 02 April 2007 - 11:50 AM

Was This Post Helpful? 0
  • +
  • -

#4 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1812
  • View blog
  • Posts: 20,232
  • Joined: 17-March 01

Re: need help to complete project for class

Posted 02 April 2007 - 11:58 AM

jeps1lon, unfortunatley it is the policy here at dream.in.code to help and guide members to a solution, not simply provide one.

If you can't wait for a reply you can get live programming help here.
Was This Post Helpful? 0
  • +
  • -

#5 ajwsurfer  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 373
  • Joined: 24-October 06

Re: need help to complete project for class

Posted 02 April 2007 - 01:01 PM

View Postjeps1lon, on 2 Apr, 2007 - 11:39 AM, said:

Someone, please. I'll send you $10 through paypal to compensate for your services.


If I was charging you for my programming services, that might cover the first couple minutes B)
Was This Post Helpful? 0
  • +
  • -

#6 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2209
  • View blog
  • Posts: 9,183
  • Joined: 18-February 07

Re: need help to complete project for class

Posted 02 April 2007 - 09:47 PM

First of all, if you can't take the workload with 5 math classes and a CS class, then think about dropping the CS. As a math major/cs minor myself I often had to drop a few classes myself here and there. You get no sympathy from me (and 10$ is not worth it to do a homework assignment, as a tutor I get paid at least 20$, and that is just where I help).

The program is not hard. You should be able to code it in a few hours. Or, there are a few places where you can download infix to postfix code, and give about 1-2 hours of editing and presto.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1