Data Structure
 Networking
 RDBMS
 Operating System
 Java
 MS Excel
 iOS
 HTML
 CSS
 Android
 Python
 C Programming
 C++
 C#
 MongoDB
 MySQL
 Javascript
 PHP
- Selected Reading
 - UPSC IAS Exams Notes
 - Developer's Best Practices
 - Questions and Answers
 - Effective Resume Writing
 - HR Interview Questions
 - Computer Glossary
 - Who is Who
 
Server Side Programming Articles - Page 1109 of 2650
 
			
			492 Views
When it is required to select the nth smallest element from a list in linear time complexity, two methods are required. One method to find the smallest element, and another method that divides the list into two parts. This division depends on the ‘i’ value that is given by user. Based on this value, the list is split, and the smallest element is determined.Below is a demonstration of the same −Example Live Demodef select_smallest(my_list, beg, end, i): if end - beg k: return select_smallest(my_list, pivot_val + 1, end, i - k) return my_list[pivot_val] ... Read More
 
			
			486 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)] print("The list is : ") print(my_list) my_result = sorted(my_list, key = lambda tup : sum([len(str(ele)) for ele in tup ])) print("The sorted tuples are ") print(my_result)OutputThe list is : [(11, 23, 45, 678), (34, 67), (653, ), (78, 99, 23, 45), (67, 43)] The sorted tuples are ... Read More
 
			
			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 for the same −Example Live Democlass Stack_structure: def __init__(self): self.items = [] def check_empty(self): return self.items == [] def push_val(self, data): self.items.append(data) def pop_val(self): return self.items.pop() my_instance = Stack_structure() text_input = ... Read More
 
			
			316 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 a demonstration for the same −Example Live Democlass Node: def __init__(self, data): self.data = data self.next = None class LinkedList_structure: def __init__(self): self.head = None self.last_node = None def add_vals(self, data): ... Read More
 
			
			248 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): self.data = data self.next = None class LinkedList_structure: def __init__(self): self.head = None self.last_node = None def add_vals(self, data): if self.last_node is None: self.head = Node(data) ... Read More
 
			
			230 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 = data self.next = None class LinkedList_structure: def __init__(self): self.head = None self.last_node = None def add_vals(self, data): if self.last_node is None: self.head = Node(data) self.last_node ... Read More
 
			
			187 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 a demonstration for the same −Example Live Democlass Node: def __init__(self, data): self.data = data self.next = None class LinkedList_structure: def __init__(self): self.head = None self.last_node = None def add_vals(self, data): ... Read More
 
			
			281 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 demonstration for the same −Example Live Democlass Node: def __init__(self, data): self.data = data self.next = None class LinkedList_structure: def __init__(self): self.head = None self.last_node = None def add_vals(self, data): if ... Read More
 
			
			187 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. Two lists instances are created and the previously defined method is called on these linked list instances.Below is a demonstration for the same −Example Live Democlass Node: def __init__(self, data): self.data = data self.next = None class LinkedList_structure: def __init__(self): ... Read More
 
			
			262 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 is a demonstration for the same −Example Live Democlass Node: def __init__(self, data): self.data = data self.next = None self.prev = None class DoublyLinkedList_structure: def __init__(self): self.first = None self.last = None ... Read More