Sunteți pe pagina 1din 4

Dynamic Implementation Using Linked List

Jonathan Bantugon Maria Erica Castillo Kimberly Jusi


BatStateU BatStateU BatStateU
Mabini Campus Mabini Campus Campus
jnthnbntgn011@gmail.com mariaericacastillo0402.gm misskimberly20@gmail.co
ail.com m

Abstract memory. As insertion and removal of


Our research paper aims at linked list nodes can be done at any point in the
which is a data structure and it is the list, we can do so with a constant
collection of nodes which together number of operations if the link
represent a sequence. Linked list are of previous to the link being added or
many types. It can be singly linked list, removed is maintained during list
doubly linked list, circular linked list. traversal. A linked list is a dynamic
In this we will focus on how to data structure. The number os nodes in
traverse a linked list, insertion of a a list are not fixed and can grow or
node at the beginning of the linked list, shrink on demand. Any application
insertion of the node after a node, which has to deal with an unknown
deletion of node from beginning and number of objects will need to use a
deletion of node from the end of the linked list. Linked list do not allow
linked list and how two linked lists can random access to the data by
be concatenated. themselves or any form of indexing.
Many basic operations such as
obtaining the last node of the list, or
Introduction finding a node that contains a given
Data structure is an efficient way of details, or locating the place where a
organizing the data so that your new node should be inserted, may
program become efficient in terms of require scanning all of the elements of
storage and execution. There are many the list. Using linked list have some
types of data structures i.e., array, advantages as well as some of the
stack, queues, linked list, trees and disadvantages. Its advantages are that
graphs. We are here focusing on the as linked lists are dynamic data
linked list. Linked list is the collection structure, needed memory will be
of nodes and each node consist of the allocated when program is initiated and
information part and the link part. The operations like insertion and deletion
information part contains the data and can easily be implemented using the
the linked part contains the address of linked list. Other data structures like
next node. The main benefit of linked stacks, queues can be easily executed
list is that linked list elements can using linked list. With advantages it
easily be inserted or removed without has some disadvantages too. Like,
reallocation or reorganization of the linked list waste memory due to
entire structure because data items pointers, as they require extra storage
need not to be stored instantly in the
space. Nodes in the linked list are not linked list are quiet easier to read. One
stored instantly. As linked list is a way to visualize a linked list is as
collection of nodes which together though it were a train. The programmer
repesent a sequence. So, nodes in a always stores the first node of the list
linked list must be read in order from in a pointer he won't lose access to.
the beginning because linked list are This would be engine of the train. The
inherently sequential access. In linked pointer itself is a connector between
list, difficulties arise when it comes on cars of the train.Every time the train
reverse traversing. In reverse adds a car, it uses the connectors to add
traversing, again memory is wasted in a new car. This is like a programmer
allocating space for a back pointer. As using malloc function to create a
singly linked list is very difficult to pointer to a new strut.
traverse backward, whereas doubly

SINGLY LINKED LIST


Is the most basic linked data structure.
In this the elements can be placed
anywhere in the heap memory unlike
array which uses intant locations.
Nodes in a linked list are linked
together using a next field,which stores
the address of the next field of the
previous node i.e. each node of the list
refers to its successor and the last node
contains the NULL reference. It has a
dynamic size, which can be determined
only at run time. Structure of singly
linked list:

struct node
{
int info;
struct node*link;
};
Struct node*first;
The first is a pointer which always {
points to very first node of the linked printf(“%d”, ptr---> info)
list. ptr=ptr--->link;
}
2.1 Traversing of a singly linked list 2.2 Insertion of node at the Beginning
Traversal of a singly link list is a of Singly Linked List
simple, beginning at the first node and Void insert()
following each next link until we come {
to the end. Struct node*ptr;
void traverse() Ptr=(structnode*)malloc
{ (sizeof(struct node));
stuct node*ptr; scanf(“%d”, &ptr ---> info:
ptr=first; ptr ---> link=first; first=ptr;
while(ptr!=NULL) }
first = ptr ---> rpt
first---> lpt = NULL
free (ptr);
}

4. CIRCULAR LINKED LIST In a


circular link list, the link part of last node
contains the address of first node. In a
DOUBLY LINKED LIST circular linked list, all nodes are linked in
Doubly link list contains three parts, first continuous circle, without using NULL.
is left pointer which contains the address Circularly linked list can be either singly
of left node and next is second part is info or doubly linked.
part which contains the data and third part
contains the address of next node. 4.1 Insertion of Node at the End of the
Circular Linked List
1pt Info rpt Void insert()
{
struct node *ptr, *cpt;
ptr= (stuct node*) malloc (sizeof(struct
struct node node));
{ scanf(“%d”, &ptr ---> info);
struct node *lpt; cpt=first;
int info; while(cpt---> link! = first)
srtuct node *rpt; {
}; cpt= cpt---> link;
struct node *first; }
3.1 Backward Traversing Of Doubly cpt---> link = ptr;
Linked List void traverse() ptr---> link= first;
{ }
struct node *ptr; 4.2 Traversing Of Circular Link List
ptr=first; Void traverse ()
while(ptr--->rpt!= NULL) {
ptr = ptr---> rpt stuct node *ptr; ptr = first;
while( ptr!= NLL) while(ptr ---> link! = first)
{ {
printf (“%d”, ptr---> info); printf (“%d”, ptr---> info);
ptr = ptr ---> lpt; ptr= ptr---> link;
} }
printf(“%d”, ptr---> info);
}

3.2 Deletion from the Beginning of


Doubly Linked List void delete()
{
struct node *ptr;
ptr=first;
4. A. Møller and M. I. Schwartzbach. The
CONCATENATION OF TWO pointer assertion logic
LINKED LISTS engine.In PLDI 01: Programming
void con() Language Design and
{ Implementation,pages 221–231, 2001.
struct node *ptr; 5. G. Nelson. Verifying reachability
ptr= f1; invariants of linked structures.InPOPL 83:
while( ptr! = NULL) Principles of Programming Languages,
ptr= ptr---> link; pages 38–47.ACM Press, 1983
ptr---> link = f2; 6. International Journal Of Engineering
} Research & Management Technology
7.ISSN: 2348-4039
8.Email: editor@ijermt.org
9.www.ijermt.org
10.Copyright@ijermt.org Page 44
11.September- 2014 Volume 1, Issue-5
12.Karuna
Department of Information and
Technology
Dronacharya College Of
CONCLUSION EngineeringGurgaon, India
Singly linked lists are useful data 13.Garima Gupta
structures, especially if you need to Department of Information amd
automatically allocate and de-allocate Technology
space in a list. The code and complexity of Dronacharya College Of Engineering
these algorithms is bigger, but the tradeoff Gurgaon, India
is ease of use. As far as complexity is 14.https://ijermt.org/publication/11/IJ
concerned, a linked list should never ERMT%20V-1-5-6.pdf
exceed O (n2). If you are very lucky,
linear time can be achieved (only under
several conditions, such as there being
only 1 item in the list, or the current
element pointed at is the head or the tail).
Sorting linked lists can be a chore, but
with careful selection of sorting
algorithms, nearly constant time can be
achieved. Counting Sort works the best for
integers, and Quick sort works great for
non-integer items (such as floats).

REFERENCES
1. Allen Newell, Cliff Shaw and Herbert
A. Simon "Linked List".
2. Search engines like google and yahoo.
3. T. Lev-Ami and S. Sagiv. TVLA: A
system for implementing static analyses.
InSAS 00: Static Analysis Symposium,
volume 1824 ofLNCS, pages 280–
301.Springer-Verlag, 2000.

S-ar putea să vă placă și