You are on page 1of 7

CLASS 2

Data Structures 2S2019


Linked Lists
Is a linear collection of data elements (data usually referring to Objects) but also
commonly used to store primitive values, whose order is not given by their physical
placement in memory. Instead each element points to the next. This data structure
allows for efficient insertion or removal of elements from any position of the sequence
during iteration. The main drawback of linked lists is that access time is linear.
Linked Lists are among the simplest and most common data structures and can be
used as a starting point to implement several other abstract data types, such as lists,
stack, queues, though is not uncommon to implement those data structures directly
without using a linked list as the basis.
Doubly Linked Lists
In a doubly linked list, each node not only contains a reference or pointer to the next
node, but it contains a pointer to the previous node in the sequence, The most common
use of a doubly linked list is on navigation systems where both front and back
navigation is required (traversing the list forward or backward), the best example of this
is a browser and how it manages the next or previous page button, and also a lot of
applications implement this list to make use of the Undo and Redo button functionality
that is often found in many applications
Circular Linked List
In a circular linked list the last node of the
list does not contain a reference or link to
null, but rather a link to the first node (head)
of the list. Comparing the Circular Linked list
to a common LinkedList we cant help but
notice a few advantages such as the ease of
traversing the List by starting from any point
we choose, it can also be useful when
implementing a queue because we can
maintain a pointer to the last inserted node
and the front can always be obtained as
next of the last. Probably the most common
application of a Circular Linked List is how
applications run in a pc, as they are cycled
to give them each a small amount of time to
be executed by the processor.
Operations in Linked Lists
Common Optional
■ Add ■ isEmpty
– Add first ■ Exists
– Add last ■ Replace
■ Delete
■ Search (Find)
■ Traverse
Stack
Is a linear data structure, with two principal
operations:
■ Push(), which adds an element to the
top of the list.
■ Pop(), which removes an element to the
top of the list
Stacks are only modified from one end,
which gives them the LIFO name (Last In,
First Out), due to this stacks can be easily
implemented with a single-link LinkedList,
another common operation for a stack is
peak(), which returns the top element of the
stack, but does not remove it.
Queue

Is a collection of elements with 2 main operations:


■ Enqueue(), which adds elements to the rear of
the list.
■ Dequeue(), which deletes elements to the front of
the list.
This gives the queue it’s FIFO (First In, First Out)
structure. The queue from a computer science
standpoint would work as in any real life situation
(the queue at a supermarket, or at a bank), and it is
also common to work with priority queue which are
queues with special privileges.

You might also like