Kavya Elemati

Kavya Elemati

4 Articles Published

Articles by Kavya Elemati

4 articles

Python Program To Detect A Loop In A Linked List

Kavya Elemati
Kavya Elemati
Updated on 27-Mar-2026 1K+ Views

A linked list is said to have a loop when any node in the linked list is not pointing to NULL. The last node will be pointing to one of the previous nodes in the linked list, thus creating a loop. There will not be an end in a linked list that has a loop. In the below example, the last node (node 5) is not pointing to NULL. Instead, it is pointing to node 3 and a loop is established. Hence, there is no end to the above linked list. ...

Read More

Python Program To Convert An Array List Into A String And Viceversa

Kavya Elemati
Kavya Elemati
Updated on 27-Mar-2026 338 Views

Python provides several methods to convert between lists and strings. The most common approaches are using join() to convert lists to strings and split() to convert strings back to lists. Converting a List to String Using Loop You can iterate through all items in a list and concatenate them into a string ? words = ["I", "want", "cheese", "cake"] result = "" for item in words: result = result + item + " " print(result.strip()) # Remove trailing space I want cheese cake Using join() Function ...

Read More

Python Program To Get The Middle Element Of A Linked List In A Single Iteration

Kavya Elemati
Kavya Elemati
Updated on 27-Mar-2026 2K+ Views

A linked list stores data in non-contiguous memory locations using nodes connected by pointers. Each node contains data and a link to the next node. Finding the middle element efficiently requires the two-pointer technique to avoid multiple iterations. Brute Force Approach The brute force method requires two passes through the linked list ? First pass: Count total nodes to find length Second pass: Traverse to the middle position (length/2) Time complexity: O(n), but requires two iterations Two-Pointer Technique (Single Iteration) This optimal approach uses slow and fast pointers moving at different speeds ? ...

Read More

Python Program To Add Elements To A Linked List

Kavya Elemati
Kavya Elemati
Updated on 27-Mar-2026 2K+ Views

A linked list is a linear data structure where elements are stored in nodes, and each node contains data and a reference to the next node. Unlike arrays, linked list elements are not stored in contiguous memory locations, making insertion and deletion operations more efficient. In Python, we can implement a linked list using classes. Each node contains data and a pointer to the next node. The first node is called the head, and the last node points to None. Linked List Structure Every node in a linked list contains ? Data − The actual ...

Read More
Showing 1–4 of 4 articles
« Prev 1 Next »
Advertisements