Monday, July 9, 2007

Write code to add two polynomials.

Here is some pseudocode


mynode *polynomial_add(mynode *h1, mynode *h2, mynode *h3)
{
mynode *p1, *p2;
int x1, x2, y1, y2, cf1, cf2, cf;

p1 = h1->next;

while(p1!=h1)
{
x1 = p1->px;
y1 = p1->py;
cf1 = p1->cf;

// Search for this term in the second polynomial

p2 = h2->next;

while(p2 != h2)
{
x2 = p2->px;
y2 = p2->py;
cf2 = p2->cf;

if(x1 == x2 && y1 == y2)break;

p2 = p2->next;

}


if(p2 != h2)
{
// We found something in the second polynomial.

cf = cf1 + cf2;
p2->flag = 1;

if(cf!=0){h3=addNode(cf,x1,y1,h3);}
}
else
{
h3=addNode(cf,x1,y1,h3);
}

p1 = p1->next;

}//while


// Add the remaining elements of the second polynomail to the result

while(p2 != h2)
{
if(p2 -> flag ==0)
{
h3=addNode(p2->cf, p2->px, p2->py, h3);
}
p2=p2->next;
}

return(h3);
}

28 comments:

Anonymous said...

, tori spelling nu, 8710, deborah gibson nude, :-]], demi moore naakt, 8-[[, marlene favela nude, 551856,

Anonymous said...

comment6, amanda tapping nude, jshjpd, denise milani desnuda, 101,

Anonymous said...

comment5, gwen stefani nude, :(,

Anonymous said...

, mena suvari nude, jzq,

Anonymous said...

, nude celebs of tumblr, rzqef, 130 nude tumblr celebs, ltet, world top 200 celebs?, 531,

Anonymous said...

, patsy kensit nude, 394695, roxanne pallett nude, 66258, nicole austin nude, 592, 130 smart girls, srg,

sandeep kumar said...

Thanks for the info. It is very helpful.
RegardsEducational site
Get jobs info at Educational site

Anonymous said...

My spouse and I stumbled over here from a
different web page and thought I may as well check things out.
I like what I see so i am just following you. Look forward to looking
at your web page yet again.
My page :: android tablet pc

Anonymous said...

An interesting discussion is worth comment. I think that you
should write more about this issue, it may not be a taboo subject
but usually people don't discuss these subjects. To the next! Kind regards!!
my webpage: Western Australia

Anonymous said...

Having read this I believed it was extremely enlightening.

I appreciate you taking the time and energy to put this informative
article together. I once again find myself personally spending a significant amount of time both
reading and posting comments. But so what, it was still worthwhile!
Take a look at my blog post : cheap iPhone 5 for sale online

Anonymous said...

Hello There. I found your blog the use of msn. This is a
very neatly written article. I'll be sure to bookmark it and return to read more of your helpful info. Thank you for the post. I will definitely return.
my webpage: Photography Special Effects

Anonymous said...

I will immediately grasp your rss feed as I can't to find your e-mail subscription link or e-newsletter service. Do you've any?
Kindly permit me understand in order that I may subscribe.
Thanks.
my page > Trick Photography and Special Effects

Anonymous said...

When someone writes an post he/she retains the plan of a user in
his/her brain that how a user can be aware of it.
Therefore that's why this article is perfect. Thanks!
Here is my website :: penilarge najtaniej

Anonymous said...

We are a group of volunteers and starting a new scheme in our community.
Your site provided us with valuable info to work on.
You've done an impressive job and our entire community will be grateful to you.
My weblog - search engine optimization india

Anonymous said...

This website was... how do I say it? Relevant!
! Finally I have found something that helped me.
Appreciate it!
Here is my webpage ... Online Casino

Anonymous said...

Natural HGH delivers amazing effects on the body but then production of HGH dramatically decline as one reaches 30 resulting to
changes which characterize old age. HGH spray is utilized by
many athletes in order to increase muscle mass, and transform both their body and athletic performance.
HGH by injection is approved for adults with human growth insufficiency.


Feel free to visit my page ... Http://hghliving.org

Anonymous said...

I know this web page offers quality based content and additional data, is there
any other website which gives such information in quality?


Also visit my web page; perfume tips

Anonymous said...

One common transaction that banks report to the IRS is
interest that you earn from checking or savings account with you to the IRS each year

Review my website SixFlagsTicketsCoupons.com

Anonymous said...

I just couldn't leave your site prior to suggesting that I extremely enjoyed the standard information an individual provide on your visitors? Is gonna be again continuously in order to inspect new posts

My web site; calculate waist to height ratio

Anonymous said...

Good day I am so excited I found your weblog, I really found you by mistake, while I was
searching on Bing for something else, Anyways I am here now and would
just like to say kudos for a incredible post and a all round exciting blog
(I also love the theme/design), I don't have time to browse it all at the minute but I have bookmarked it and also added in your RSS feeds, so when I have time I will be back to read much more, Please do keep up the superb work.

Here is my blog; xxx-fuck.net

Anonymous said...

My brother suggested I might like this blog. He was totally right.
This post actually made my day. You can not imagine just how much time I had spent for this info!
Thanks!

Look at my web page :: nude party girls

Vina Janny said...

Handheld led tap (with hoses) have becomes extremely popular. These can either be attached like a standard bathroom accessories or be pulled down and directed by hand.
Shower Heads: Factors to Consider Before Buying kitchen tap come with enhanced functionalities, including adjustable spray from a super fine needle spray. These come in innumerable designs and add elegance to any bathroom. Certain factors that one should consider before purchasing a bath tap are:

Robinet Deal said...

In British English, a Tap is a device that controls the flow of a liquid or gas from a pipe or container Kitchen Taps, Bathroom Taps, Shower Taps At DisTap,Choose a kitchen sink and tap to suit your kitchen worktop from the huge range stocked at DISTAP from the World's leading sink manufacturers.

Maggic T said...

L'espoir d'entendre la suggestion de quelqu'un. Que diriez-vous des robinets d'achats en ligne. Comme nous le savons tous, la Robinet LED maintenant devenir de plus en plus populaire. LED robinets de cuisine et salle de bains robinets encore plus de Mitigeur douche. Mais il est aussi très important pour les gens de choisir un grand robinets de qualité LED. Si vous voulez en savoir plus d'informations de la maison et du design. http://www.robinetsale.com/ Vous pouvez me contacter.

sherry jiang said...

hop online for thousands of Taps, sinks, bathroom, kitchen and shower fixtures. FREE SHIPPING on most items. Same day shipping on in stock items.http://www.plumpinguk.co.uk/kitchen-taps/wall-mounted-taps.html

Zhu Y said...

Our pneumatic factory was founded in 2000,CHECK HERE. In decades of serving China pneumatic industry, we have built our reputation on product knowledge, world class suppliers, application support, and value add services. Our commitment to our employees, customers and vendors is the core of our business beliefs. In our factory, there are more than 80 front-line workers, 3000 squares working shop.Our main products are air Pneumatic Cylinder, solenoid valve and also a lot of pneumatic fittings like Air Gun.

Cheap Tap said...

Antique taps include antique brass finish, Oil-rubbed bronze finish, black bronze finish and also Red bronze finish, you must can find your perfect antique bathroom and kitchen taps in our online store.http://www.cheaptap.co.uk/kitchen-taps-antique-kitchen-taps-c-22_23.html : Cheap Taps Sale Online Store- Offering All Kinds of Taps

Amy Carry said...

These days, homemakers want to add in more type, flair and superiority into their http://www.faucetsmarket.com/bathroom-accessory-faucets-accessories-c-4_33.html. As such, even the faucets are chosen with more care and consideration. With this change in choice, you see the appearance of designer http://www.faucetsmarket.com.