11/29/2025
Andargachew A.
3
Preliminary Concepts
Data Type (DT) vs User-Defined DT vs Abstract DT
Feature Data Type
User-Defined
Data Type
Abstract Data Type
(ADT)
Built-in or Custom Built-in Programmer-defined
Conceptual/logical
model
Abstraction Level Low Medium High
Behavior Definition Yes (basic) Yes (with functions)
Yes (abstract
operations only)
Implementation
Hidden?
No No (structure visible) Yes
Examples int, float, char struct, class, enum
Stack, Queue, List,
Graph
4.
11/29/2025
Andargachew A.
4
AbstractData Type (ADT)
An ADT is a logical model of a data structure.
It defines what data is stored and what operations can be
performed on that data — but not how those operations are
implemented.
Hides implementation details promotes abstraction.
→
Focuses on behavior, not internal structure.
ADT Supported Operations
List Insert, Delete, Traverse
Stack Push, Pop, Peek (LIFO)
Queue Enqueue, Dequeue (FIFO)
Tree Insert, Search, Delete
Graph AddVertex, AddEdge, DFS, BFS
5.
11/29/2025
Andargachew A.
5
Overview
LinkedList
It is a data structure built using structures and pointers.
It forms a chain of nodes where each node points to the next.
Nodes are the building blocks of a linked list.
Structure of a Node
A node typically contains:
data field: stores actual data (could be multiple variables).
next field: a pointer to the next node.
Links between nodes are established through these pointers.
6.
11/29/2025
Andargachew A.
6
Descriptionof the above diagram
This linked list has four nodes in it, each with a link to the next
node in the series.
The last node has a link to the special value NULL to show that it is
the last link in the chain.
There is also another special pointer, called Start or Root, which
points to the first link in the chain so that we can keep track of it.
7.
11/29/2025
Andargachew A.
7
ArrayVS Linked lists
Array:
Fixed size at creation
Simple and fast
Inefficient if size exceeds
Linked List:
Dynamic size
Memory-efficient
No need to know size in advance
8.
11/29/2025
Andargachew A.
8
Linkedlists are the most basic self-referential
structures.
Self-referential structures: structures can hold pointers to
instances of themselves.
struct list
{
char name[10];
int count;
struct list *next; // instance of list
};
11/29/2025
Andargachew A.
10
Definingthe data structure for a linked list
The key part of a linked list is
A structure, which holds the data for each node (the name,
age, height or whatever for the items in the list), and,
Most importantly, a pointer to the next node.
Here I have given the structure of a typical node:
11/29/2025
Andargachew A.
12
Exercise-2
1. Whichone is the first node and the last node?
2. What is the value of the head node in this linked list?
3. Which node does Node n2's next pointer point to?
4. What do you think happens if a node's pointer is NULL?
5. What would happen if Node 3's next pointer was mistakenly set to Node n1 instead of
NULL?
6. How would you update the list if you wanted to insert a new node with the value 40 at
the beginning of the list?
13.
11/29/2025
Andargachew A.
13
Singly LinkedLists
A singly linked list is a list where each node points
to the next node. The last node points to NULL.
In a singly linked list each node in the list stores the
contents of the node and a pointer or reference to the
next node in the list.
It does not store any pointer or reference to the previous
node.
14.
11/29/2025
Andargachew A.
14
Ina singly linked list, the address of the first node is
always stored in a reference node known as "head" |
"front" | "start"
Always next part (reference part) of the last node must
be NULL.
15.
11/29/2025
Andargachew A.
15
CreatingEmpty Singly
Linked List
Step 1: Include all
the header files which are
used in the program.
Step 2: Define
a Node structure with two
members data and next
Step 3: Define a Node
pointer 'head' and set it
to NULL.
16.
11/29/2025
16
Basic Operations
In a singly linked list we perform the following
operations
1. Insertion - To add/insert a new node to the list.
2. Deletion - To remove one existing node from the list.
3. Traversal - To access each element of the linked list.
4. Search - To find a node in the list.
5. Sort - To sort the nodes.
11/29/2025
20
Basic LinkedList Operation
Creating a new node
Structure_Name *new_node= new Structure_Name;
Student *S1= new Student;
Accessing Data from a Node
S1->age; or S1->name;
Checking if the List is Empty
if (head == NULL) // Empty else // Not Empty
Finding the Last Node in the List
temp=head;
while(temp->next!=NULL)
temp=temp->next;
21.
11/29/2025
Andargachew A.
21
Exercise-3
1. Howdo we access the 3rd
element in a singly linked list, and
what happens during the process?
2. How do you insert a new node in the middle of a singly linked
list? Illustrate how the pointers are updated during the insertion.
3. What are the three types of insertion we can do in a linked
list?
4. Write a pseudocode for inserting a node at the beginning
22.
22
Doubly Linked Lists
10/23/2017
A doubly linked list is a type of linked list in which
each node contains links to both its successor (next)
and predecessor (previous) nodes.
This allows for traversal in both directions (forward
and backward) making certain operations more
efficient compared to singly linked lists.
23.
11/29/2025
Andargachew A.
23
Structureof a Node in a Doubly Linked List
Each node typically contains three fields:
Previous Pointer (LPoint) – points to the previous node in
the list.
Data – stores the actual information.
Next Pointer (RPoint) – points to the next node in the list.
24.
11/29/2025
Andargachew A.
24
WhyUse a Doubly Linked List?
A doubly linked list is useful when you need to
navigate or manipulate data in both directions
(forward and backward).
Here are the main reasons to use it:
Bidirectional Traversal
Easier Deletion of Nodes
More Flexibility in Insertion
Efficient Backtracking
Better Performance in Certain Operations
25.
11/29/2025
25
Basic Operations
In a doubly linked list we perform the following
operations
1. Insertion - To add/insert a new node to the list.
2. Deletion - To remove one existing node from the list.
3. Traversal - To access each element of the linked list.
4. Search - To find a node in the list.
5. Sort - To sort the nodes.
26.
11/29/2025
Andargachew A.
26
Exercise-4
1. Howdo you insert a new node with value - 62 (address: 400) in
the middle of a singly linked list after the node with value 19?
Illustrate how the pointers are updated during the insertion.
2. Write pseudocode to insert a node at the end of a doubly
linked list?
3. How would you delete a node with value 19 from a doubly linked
list. Describe how the pointers are updated.
27.
11/29/2025
Andargachew A.
27
Circular LinkedList
A circular linked list is a variation of the traditional
linked list in which:
The last node points back to the first node, forming a
closed loop.
Both singly and doubly linked lists can be implemented
as circular lists
In both circular singly and doubly linked lists, the last
node’s next points to the first node.
In a circular doubly linked list, the first node’s previous
also points to the last node.
28.
11/29/2025
Andargachew A.
28
CircularSingly Linked List
In a circular singly linked list:
Each node has a single next pointer.
The next pointer of the last node points to the first node
instead of NULL.
29.
11/29/2025
Andargachew A.
29
CircularDoubly Linked List
In a circular doubly linked list:
Each node has both next and previous pointers.
The next pointer of the last node points to the first node.
The previous pointer of the first node points to the last node.
This forms a complete circular structure in both directions.
30.
11/29/2025
30
Basic Operations
In a circular list we perform the following operations
1. Insertion - To add/insert a new node to the list.
2. Deletion - To remove one existing node from the list.
3. Traversal - To access each element of the linked list.
4. Search - To find a node in the list.
5. Sort - To sort the nodes.
31.
11/29/2025
Andargachew A.
31
Linked Lists:Benefits & Drawbacks
Benefits
Fast Insertions and Deletions:
Inserting or deleting nodes can be done in constant time O(1) if the position
is known-particularly efficient at the head or tail of the list.
Dynamic Memory Allocation:
Memory is allocated as needed, so there’s no need to define the size of the
list ahead of time. This offers greater flexibility compared to arrays.
Drawbacks
Slow Search Performance:
Searching through a linked list requires O(n) time in the worst case, as
elements must be accessed one by one. Techniques like binary search aren’t
applicable.
No Random Access:
Unlike arrays, you can’t directly access an element by index. Traversal from
the head is required to reach a specific node.
32.
11/29/2025
Andargachew A.
32
Variants ofLinked Lists
Linked lists come in several forms, each designed to
optimize specific operations like traversal, insertion,
deletion, or memory usage.
Skip List
A multi-level linked list with forward pointers that "skip" over
multiple elements
Self-Organizing List
Reorders nodes based on access frequency (e.g., Move-to-Front
heuristic)
Unrolled Linked List
Each node stores multiple elements (as a block/array)
33.
11/29/2025
33
Assignment-2
Topics:
SkipList
A skip list is a layered, probabilistic data structure that allows fast search,
insertion, and deletion operations within an ordered sequence
Self Organizing list
A self-organizing list dynamically reorders its nodes based on access patterns.
Unrolled linked list
An unrolled linked list is a variation of a linked list where each node stores
multiple elements instead of just one
Note
You are required to prepare a 10-minute presentation covering the
above topics. Please ensure that your presentation consists of a
maximum of 10 slides.