I've already written some code to add two polynomials(one variable) stored in a linked list.
The Basic Node structure looks like this:
Now what I do is that i check the degree of every node in both polynomials and if I find matching degrees, add them and store them in a third list, concurrently I set the add_flag of both nodes to 1.
unsigned int add_flag;
struct node *next;
struct node *prev;
typedef struct node * nodeptr;
Then I run through both lists, and if i find a node who's add flag hasnt been set, I include that node in my resultant list as well. Then I sort the resultant list in decreasing order of degrees.
This means that I traverse both lists several times, which in my mind makes my program pretty time complex.
Is there any other simpler way to achieve the above addition?
Also I have a personal problem, I know this sounds stupid, off-topic etc etc, also the moderators out here are free to do anything with me if they want.
I have 20 days, in which I have to compulsarily clear 3 exams, for people who are interested they're:-
I love programming and I want to continue my engineering course, but i just cannot get myself to study these subjects, also I live in India, where the concept of optional subjects just isnt there..I only have one more chance after this to clear these subjects, otherwise I will fail one more year(I already have failed once) and I wont be able to bear the shame.
Any words of advice(or any flames for my lame posting) are welcome.
I am again very sorry, but I'm deeply depressed.