-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiplyPolynomial.java
More file actions
53 lines (41 loc) · 1.05 KB
/
MultiplyPolynomial.java
File metadata and controls
53 lines (41 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class Node{
int coefficient;
int power;
Node next = null;
Node(int coefficient,int power){
this.coefficient = coefficient;
this.power = power;
}
Node insert(Node head,int coefficient,int power){
Node newnode = new Node(coefficient,power);
if(head == null){
return newnode;
}
Node temp = head;
while(temp != null){
temp = temp.next;
}
temp.next = newnode;
return head;
}
void traverse(Node head);
Node temp = head;
System.out.println("Elements ");
while(temp != null){
System.out.println(temp.data + " ");
temp = temp.next;
}
System.out.println();
}
public class MultiplyPolynomial{
public static void main(String[] args){
Node head = null;
Node head2 = null;
head = insert(head,3,4);
head = insert(head,2,1);
head = insert(head,-1,0);
head2 = insert(head2,15,7);
head2 = insert(head2,7,3);
head2 = insert(head2,6,1);
}
}