Python Articles

Page 518 of 855

Python program to remove duplicate elements from a Circular Linked List

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 447 Views

When it is required to remove duplicates from a circular linked list, a Node class needs to be created. In this class, there are two attributes: the data that is present in the node, and the access to the next node of the linked list. In a circular linked list, the head and the rear are adjacent to each other. They are connected to form a circle, and don't have NULL value in the last node. Another class needs to be created that would have an initialization function, and the head of the node would be initialized to ...

Read More

Python program to insert a new node at the middle of the Circular Linked List

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 422 Views

When it is required to insert a new node at the middle of the circular linked list, a Node class needs to be created. In this class, there are two attributes: the data that is present in the node, and the access to the next node of the linked list. In a circular linked list, the head and the rear are adjacent to each other. They are connected to form a circle, and don't have 'NULL' value in the last node. Instead, the last node points back to the first node. Node Class Structure The Node class ...

Read More

Python program to insert a new node at the end of the Circular Linked List

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 545 Views

When it is required to insert a new node at the end of the circular linked list, a Node class needs to be created. In this class, there are two attributes: the data that is present in the node, and the access to the next node of the linked list. In a circular linked list, the head and the tail are adjacent to each other. They are connected to form a circle, and don't have NULL value in the last node. Instead, the last node points back to the first node. ...

Read More

Python program to insert a new node at the beginning of the Circular Linked List

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 684 Views

When it is required to insert a new node at the beginning of a circular linked list, a 'Node' class needs to be created. In this class, there are two attributes, the data that is present in the node, and the access to the next node of the linked list. In a circular linked list, the head and the rear are adjacent to each other. They are connected to form a circle, and don't have 'NULL' value in the last node. Instead, the last node points back to the first node. Node Class Structure First, we create ...

Read More

Python program to find the maximum and minimum value node from a circular linked list

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 406 Views

When it is required to find the maximum and minimum node values from a circular linked list, a Node class needs to be created. In this class, there are two attributes: the data present in the node, and the access to the next node of the linked list. In a circular linked list, the head and the tail are adjacent to each other. They are connected to form a circle, and don't have None value in the last node − instead, the last node points back to the first node. Implementation The implementation involves creating a Node ...

Read More

Python program to delete a node from the middle of the Circular Linked List

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 291 Views

When it is required to delete a node from the middle of the circular linked list, a Node class needs to be created. In this class, there are two attributes: the data that is present in the node, and the access to the next node of the linked list. In a circular linked list, the head and the rear are adjacent to each other. They are connected to form a circle, and don't have NULL value in the last node. Another class needs to be created that would have an initialization function, and the head of the node ...

Read More

Python program to delete a node from the end of the Circular Linked List

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 448 Views

When it is required to delete a node from the end of a circular linked list, a Node class needs to be created. In this class, there are two attributes: the data that is present in the node, and the access to the next node of the linked list. In a circular linked list, the head and the tail are adjacent to each other. They are connected to form a circle, and don't have NULL value in the last node − instead, the last node points back to the first node. Node Class Structure The Node class ...

Read More

Python Program to Print an Inverted Star Pattern

Akshitha Mote
Akshitha Mote
Updated on 25-Mar-2026 1K+ Views

In this article, we'll learn how to print inverted star patterns in Python. An inverted star pattern displays stars in descending order, where each row has fewer stars than the previous one. For example, with N=5 rows ? ***** **** *** ** * Basic Inverted Star Pattern The most common approach uses nested for loops − the outer loop controls rows, and the inner loop prints stars for each row. Using Nested Loops Here's how to create an inverted star pattern with spaces between stars ? # Number of rows N ...

Read More

Python program to create and display a Circular Linked List

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 872 Views

A circular linked list is a data structure where the last node points back to the first node, forming a circle. Unlike regular linked lists that end with None, circular linked lists have no end − the traversal can continue indefinitely. To implement a circular linked list in Python, we need two classes: a Node class to represent individual elements, and a CircularLinkedList class to manage the list operations. Node Class Structure Each node contains data and a reference to the next node ? class Node: def __init__(self, data): ...

Read More

Python program to create a Circular Linked List of n nodes and display it in reverse order

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 253 Views

When it is required to create a circular linked list and display it in the reverse order, a Node class needs to be created. However, the example below demonstrates a regular linked list implementation, not a true circular linked list. In a circular linked list, the last node points back to the first node instead of pointing to None, forming a circle. The head and tail are connected to each other. To display the data elements in reverse order, we can either reverse the list structure or traverse it backwards. Regular Linked List (Current Implementation) The current ...

Read More
Showing 5171–5180 of 8,546 articles
« Prev 1 516 517 518 519 520 855 Next »
Advertisements