AmitDiwan has Published 10744 Articles

Sort Tuples by Total digits in Python

AmitDiwan

AmitDiwan

Updated on 14-Apr-2021 14:17:14

472 Views

When it is required to sort the element in a list of tuple based on the digits, the ‘sorted’ method and the lambda function can be used.Below is a demonstration for the same −Example Live Demomy_list = [(11, 23, 45, 678), (34, 67), (653, ), (78, 99, 23, 45), (67, 43)] ... Read More

Python Program to Check String is Palindrome using Stack

AmitDiwan

AmitDiwan

Updated on 14-Apr-2021 14:16:04

965 Views

When it is required to check if a string is a palindrome using stack data structure, a stack class is created, and push and pop methods are defined to add and delete values from stack. Another method checks to see if the stack is empty or not.Below is a demonstration ... Read More

Python Program to Print Nth Node from the last of a Linked List

AmitDiwan

AmitDiwan

Updated on 14-Apr-2021 14:11:01

307 Views

When it is required to print the specific node from the end of a linked list, the methods ‘list_length’ and ‘return_from_end’ methods are defined. The ‘list_length’ reutrns the length of the linked list.The ‘return_from_end’ method is used to return the nth element from the end of the linked list.Below is ... Read More

Python Program to Print Middle most Node of a Linked List

AmitDiwan

AmitDiwan

Updated on 14-Apr-2021 14:07:43

235 Views

When it is required to print the middle most element of a linked list, a method named ‘print_middle_val’ is defined. This method takes the linked list as a parameter and gets the middle most element.Below is a demonstration for the same −Example Live Democlass Node:    def __init__(self, data):     ... Read More

Python Program to Reverse only First N Elements of a Linked List

AmitDiwan

AmitDiwan

Updated on 14-Apr-2021 14:04:07

216 Views

When it is required to reverse a specific set of elements in a linked list, a method named ‘reverse_list’ is defined. This iterates through the list, and reverses the specific set of elements.Below is a demonstration for the same −Example Live Democlass Node:    def __init__(self, data):       self.data ... Read More

Python Program to Find Number of Occurrences of All Elements in a Linked List

AmitDiwan

AmitDiwan

Updated on 14-Apr-2021 14:00:12

176 Views

When it is required to find the number of occurences of all the elements of a linked list, a method to add elements to the linked list, a method to print the elements and a method to find the occurrence of all elements in the linked list are defined.Below is ... Read More

Python Program to Find the first Common Element between the 2 given Linked Lists

AmitDiwan

AmitDiwan

Updated on 14-Apr-2021 13:57:11

267 Views

When it is required to find the common element that occurs for the first time between two linked lists, a method to add elements to the linked list, and a method to get the common element that occurs for the first time in these linked lists is defined.Below is a ... Read More

Python Program to Add Corresponding Positioned Elements of 2 Linked Lists

AmitDiwan

AmitDiwan

Updated on 14-Apr-2021 13:53:03

179 Views

When it is required to add the corresponding elements of specific position in two linked lists, a method to add elements to the linked list, a method to print the elements of the linked list, and a method to add elements to corresponding positions of a linked list are defined. ... Read More

Python Program to Find the Largest Element in a Doubly Linked List

AmitDiwan

AmitDiwan

Updated on 14-Apr-2021 13:49:57

249 Views

When it is required to find the largest element in a doubly linked list, a method to add elements to the doubly linked list, a method to print the elements of the doubly linked list, and a method to find the largest element in a doubly linked list are defined.Below ... Read More

Python Program to Detect the Cycle in a Linked List

AmitDiwan

AmitDiwan

Updated on 14-Apr-2021 13:46:26

453 Views

When it is required to detect a cycle in a linked list, a method to add elements to the linked list, and a method to get the element in the linked list are defined. Another method is defined that checks if the head and rear values are same or not. ... Read More

Advertisements