Vous êtes sur la page 1sur 19

1

KoneruLakshmaiah Education Foundation


(Deemed to be University)

FRESHMAN ENGINEERING DEPARTMENT


A Project Based Lab Report

On

IMPLEMENTATON OF LINKED LIST APPLICATIONS

SUBMITTED BY:
I.D NUMBER NAME
180031212 K.Hemanth

180031224 K.Bhanu Sandeep

180031262 G.Tirumala

180031264 A.Venkat reddy

UNDER THE GUIDANCE OF

T.Rajesh Kumar

ASSST.PROF

KL UNIVERSITY
Green fields, Vaddeswaram – 522 502
Guntur Dt., AP, India.
2

DEPARTMENT OF BASIC ENGINEERING SCIENCES-1

CERTIFICATE

This is to certify that the project based laboratory report entitled


“<IMPLEMENTATON OF LINKED LIST APPLICATIONS >” submitted by
Mr./Ms. K.Hemanth kumar, K.Bhanu Sandeep, G.Tirumala, A.Venkat
reddy.bearing Regd. No. 180031212, 180031224, 180031262, 180031264 to the
Department of Basic Engineering Sciences-1, KL University in partial fulfillment of
the requirements for the completion of a project based Laboratory in “TECHNICAL
SKILLS-2(CODING)”course in I B Tech 2 Semester, is a bonafide record of the
work carried out by him/her under my supervision during the academic year 2018 – 2
019.

PROJECT SUPERVISOR HEAD OF THE DEPARTMENT

T. Rajesh Kumar Dr. T.VAMSHIDHAR


3

ACKNOWLEDGEMENTS

It is great pleasure for me to express my gratitude to our honorable President


Sri. Koneru Satyanarayana, for giving the opportunity and platform with facilities
in accomplishing the project based laboratory report.

I express the sincere gratitude to our principal ProfDr. N.Venkataram for his
administration towards our academic growth.

I express sincere gratitude to HOD-BES-1 Dr.T.VAMSHIDHAR for his


leadership and constant motivation provided in successful completion of our
academic semester. I record it as my privilege to deeply thank for providing us the
efficient faculty and facilities to make our ideas into reality.

I express my sincere thanks to our project supervisor T.RAJESH KUMAR


for his/her novel association of ideas, encouragement, appreciation and intellectual
zeal which motivated us to venture this project successfully.

Finally, it is pleased to acknowledge the indebtedness to all those who devoted


themselves directly or indirectly to make this project report success.
4

ABSTRACT
This Project is aimed to developing an Implementation of linked list applications. In
this project we have to develop the polynomial operations like addition, subtraction,
multiplication, differentiation, which are complex to do on a paper. so we have to perform
the above operations by using linked list concept to save the time of the user.

In order to perform the above operations we need to know about the concept of
linked list like how to create a node and how to allocate memory for a created node. We
need to know about the functions concept how to create a function, calling function, called
function and the concept of recursion. By using the above concepts we can implement the
polynomial operations like addition, subtraction, multiplication, differentiation.

This program is a practical implementation of data structure linked list. We use a


linked list to dynamically store user input of polynomial expression and then we add ,
subtract, multiply, differentiate for some simple Arthimetic. For this we follow simple
strategy.

1) Make a polynomial abstract datatype using struct which basically implements a linked
list.
2) We write different functions for creating a polynomial function, adding, subtraction,
multiplication, differentiation and showing a polynomial expression.
3) Finally we write the main function as many pair of polynomials the user wants.
5

INDEX
S.NO TITLE PAGE NO
1 Introduction 6
2 Aim of the Project 7
2.1 Advantages & Disadvantages 7
2.2 Future Implementation 7
3 Software & Hardware Details 8
4 Data Flow Diagram 9-10
5 Implementation 12-16
6 Algorithm 11
7 Integration and System Testing 17-18
8 Conclusion 20

INTRODUCTION 6

The main aim of this project is to implement one of the most important applications of
linked list such as polynomial operations such as addition, subtraction, multiplication and
derivation. To perform these operations each polynomial needs to represent in one linked list
and each node in the list contains three parts to store coefficient, exponent and link to next
term of polynomial respectively. There are four modules in in this project
 polynomial Addition
 polynomial subtraction
 polynomial multiplication
 polynomial derivation
Requirements: To implement this project student should have knowledge on
 creating using linked lists
 pointers, self-referential structures
 polynomial operations
AIM 7
The Aim of the project is to execute the polynomial operations like addition, Subtraction,,
Multiplications, Differentiation etc using the concept of linked lists reducing the time
complexity to the user.

Advantages:-

1. Complex polynomial operations can be executed easily in a simple way.


2. Time complexity reduces for the user .
3. No need to struggle more for solving polynomials operations on a paper.
4. User can check whether his result is correct or not when solved on a paper.

Disadvantages:-
1. Length of the code is too long.
2. User should be careful while giving inputs
3. Occupies more memory and space in computer memory.

Future enhancements:-
1. The polynomial operations can be easily implemented by using the concept of
arrays rather than linked list.
2. Not only by linked lists we can also implement these operations by using
linear data structures like arrays, double linked lists etc .

8
SYSTEM REQUIREMENTS

 SOFTWARE REQUIREMENTS:
The major software requirements of the project are as follows:
Language : Java 2 Runtime environment
Database :MySQL Server
Web Server :Tomato 7
Software Development Kit :JSP(Java server Pages)
Database JDBC Driver :MySQL Jconnector
Operating system:Windows Xp or later.

 HARDWARE REQUIREMENTS:

The hardware requirements that map towards the software are as follows:

Name of component Specification

Processor : Pentium III 630MHz

RAM : 128 MB
Hard Disk : 20GB

Monitor : 15” color monitor

Key board : 122 Keys

9
DATA FLOW DIAGRAM
START

PRINT MENU

Takes Input From the User

YES IF OP==1 NO
YES IF OP==2
ADDITION

PERFORMS
ADDITION NO
OPERATION
BETWEEN TWO
POLYNOMIALS

SUBTRACTION

PERFORMS 10
SUBTRACTION

BETWEEN TWO
POLYNOMIALS YES
IF OP==3

NO
MULTIPLICATION

IF OP==4
PERFORMS YES
MULTIPLICATION
OPERATION
BETWEEN TWO
POLYNOMIALS NO

DIFFERENTIATION
IF OP==5

PERFORMS
DIFFERENTIATION
BETWEEN TWO
POLYNOMIALS

STOP

ALGORITHM
11

1) Start

2) Create a structure which consists of integer part of coefficient, integer part of power, and
a self referential structure with in it.

3) Create 3 variables poly1-> to store co-efficients and powers of first polynomial, poly2->
to store co-efficients and powers of second polynomial, poly-> to store resultant co-efficient
and resultant power of resultant polynomial after performing the polynomial operation.

4) create a create function and allocate memory for poly1, poly2, poly

3) Create a function for addition by passing arguments.

4) Create a function for subtraction by passing arguments.

5) Create a function for multiplication by passing arguments.

6) Create a function for differentiation by passing arguments

7) Now start the main function

8) Scan the co-efficients and powers of poly1,poly2 and call the create function and memory
will be allocated to poly1,poly2.

9) Now if you want to perform addition operation among polynomials Call the addition
function and output will be displayed.

10) Now if you want to perform subtraction operation among polynomials Call the
subtraction function and output will be displayed
11) Now if you want to perform addition operation among polynomials Call the
multiplication function and output will be displayed

12) Now if you want to perform Differentiation operation among polynomials Call the
Differentiation function and output will be displayed

13)stop

IMPLEMENTATION 12

#include<stdio.h>
#include<malloc.h>
struct link{
int coeff;
int pow;
struct link *next;
};
struct link *poly1=NULL,*poly2=NULL,*poly=NULL;
void create(struct link *node)
{
char ch;
do
{
printf("\n\nenter coeff:");
scanf("%d",&node->coeff);
printf("\nenter power:");
scanf("%d",&node->pow);
node->next=(struct link*)malloc(sizeof(struct link));
node=node->next;
node->next=NULL;
printf("\ncontinue(y/n):");
}
while(ch=='y' || ch=='Y');
}
void show(struct link *node)
{
while(node->next!=NULL)
{

printf("%dx^%d",node->coeff,node->pow);
node=node->next;
if(node->next!=NULL)
printf(" + ");

}
}
void polyadd(struct link *poly1,struct link *poly2,struct link *poly)
{
while(poly1->next && poly2->next)
{
if(poly1->pow>poly2->pow)
{
poly->pow=poly1->pow;
poly->coeff=poly1->coeff;
poly1=poly1->next;
}
else if(poly1->pow<poly2->pow)
{ 13
poly->pow=poly2->pow;
poly->coeff=poly2->coeff;
poly2=poly2->next;
}
else
{
poly->pow=poly1->pow;
poly->coeff=poly1->coeff+poly2->coeff;
poly1=poly1->next;
poly2=poly2->next;
}
poly->next=(struct link *)malloc(sizeof(struct link));
poly=poly->next;
poly->next=NULL;
}
while(poly1->next || poly2->next)
{
if(poly1->next)
{
poly->pow=poly1->pow;
poly->coeff=poly1->coeff;
poly1=poly1->next;
}
if(poly2->next)
{
poly->pow=poly2->pow;
poly->coeff=poly2->coeff;
poly2=poly2->next;
}
poly->next=(struct link *)malloc(sizeof(struct link));
poly=poly->next;
poly->next=NULL;
}

void polysub(struct link *poly1,struct link *poly2,struct link *poly)


{
while(poly1->next && poly2->next)
{
if(poly1->pow>poly2->pow)
{
poly->pow=poly1->pow;
poly->coeff=poly1->coeff;
poly1=poly1->next;
}
else if(poly1->pow<poly2->pow)
{
poly->pow=poly2->pow;
poly->coeff=poly2->coeff; 14
poly2=poly2->next;
}
else
{
poly->pow=poly1->pow;
poly->coeff=poly1->coeff-poly2->coeff;
poly1=poly1->next;
poly2=poly2->next;
}
poly->next=(struct link *)malloc(sizeof(struct link));
poly=poly->next;
poly->next=NULL;
}
while(poly1->next || poly2->next)
{
if(poly1->next)
{
poly->pow=poly1->pow;
poly->coeff=poly1->coeff;
poly1=poly1->next;
}
if(poly2->next)
{
poly->pow=poly2->pow;
poly->coeff=poly2->coeff;
poly2=poly2->next;
}
poly->next=(struct link *)malloc(sizeof(struct link));
poly=poly->next;
poly->next=NULL;
}
}

void polymul(struct link *n1, struct link *n2, struct link *n)
{
struct link * n2beg=n2;

while (n1)
{
struct link * temp=(struct link *)malloc(sizeof(struct link));
temp->next=NULL;
n2=n2beg;
while (n2)
{
temp->coeff = n1->coeff * n2->coeff;

temp->pow = n1->pow + n2->pow;

n2 = n2->next; 15
temp->next=(struct link *)malloc(sizeof(struct link));
temp=temp->next;
temp->next=NULL;

polyadd(temp,n,n);
n1 = n1->next;
free(temp);
}
}

void diff(struct link* p1,struct link* p2)


{

while(p1->next!=NULL)
{
p2->coeff=p1->coeff*p1->pow;
p2->pow=p1->pow-1;
p2->next=NULL;
p2->next=(struct link *)malloc(sizeof(struct link));
p2=p2->next;
p2->next=NULL;
p1=p1->next;
}

}
int main()
{
int op;
char ch;
do{
poly1=(struct link *)malloc(sizeof(struct link));
poly2=(struct link *)malloc(sizeof(struct link));
poly=(struct link *)malloc(sizeof(struct link));
printf("\n\nWhat do you want to
do?\n1.Addition\n2.Subtraction\n3.Multiplication\n4.Differentiation\n0.exit\nEnter your
choice:");
scanf("%d",&op);
switch(op)
{
case 1:
printf("\n\nenter 1st polynomial:");
create(poly1);
printf("\n\nenter 2nd polynomial:");
create(poly2);
printf("\n1st Polynomial:\t");
show(poly1);
printf("\n2nd Polynomial:\t");
show(poly2); 16
polyadd(poly1,poly2,poly);
printf("\nAdded polynomial:\t");
show(poly);
break;
case 2:
printf("\n\nenter 1st polynomial:\t");
create(poly1);
printf("\n\nenter 2nd polynomial:\t");
create(poly2);
printf("\n\n1st Polynomial:\t");
show(poly1);
printf("\n\n2nd Polynomial:\t");
show(poly2);
polysub(poly1,poly2,poly);
printf("\n\nSubtracted polynomial:\t");
show(poly);
break;
case 3:
printf("\n\nenter 1st polynomial:");
create(poly1);
printf("\n\nenter 2nd polynomial:");
create(poly2);
printf("\n\n1st Polynomial:\t");
show(poly1);
printf("\n\n2nd Polynomial:\t");
show(poly2);
polymul(poly1,poly2,poly);
printf("\n\nMultiplied polynomial:\t");
show(poly);
break;
case 4:
printf("\n\nenter polynomial:");
create(poly1);
printf("\n\nPolynomial:\t");
show(poly1);
diff(poly1,poly2);
printf("\n\nDifferentiated Polynomial:\t");
show(poly2);
break;
}

printf("\n Want to continue? Y/N:");


}
while(op);
return 0;
}

INTEGRATION AND SYSTEM TESTING 17

OUTPUTS
Screen Shots:
18
CONCLUSION 19

There are pretty good real examples to show the usage and importance of linkedlist.

 Consider the history section of web browsers, where it creates a linked list of web-
pages visited, so that when you check history (traversal of a list) or press back
button, the previous node's data is fetched.

 One common sighted example is low level memory management (i.e. the heap as
managed by malloc in C or new in Java, etc) is often implemented as a linked list,
with each node representing a used or available (free) block of memory. These
blocks may be of any size, change size (combine and split), be freed or assigned in
any order, and reordered. A linked list means you can keep track of all of these
"nodes" and manipulate them fairly easily.

 Also, Hashtables that use chaining to resolve hash collisions typically have one
linked list per bucket for the elements in that bucket.

 A simple real life example is a Train, here each coach is connected to its previous
and next coach (Except first and last). In terms of programming consider coach body
as node value and connectors as links to previous and next nodes.

 Our brain is also a good example of linked list. In the initial stages of learning
something by heart, the natural process is to link one item to next. It's a subconscious
act. Also, when we forget something and try to remember, than our brain follows
association and tries to link one memory with another and so on and we
finally recall the lost memory.
E.g. Consider the thinking process when you placed your bike key somewhere and
couldn't remember.

 Another real life example could a be queue/line of persons standing for food in mess,
insertion is done at one end and deletion at other. And these operations happen
frequent. dynamic queues / stacks are efficiently implemented using linkedlists.

Here by we conclude that the project given to us “Implementation Of Linked list


applications “is successfully executed by us and the screen shots are placed above with
outputs. The above mentioned examples are also the applications of linked list in real life.

Vous aimerez peut-être aussi