Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles on Trending Technologies
Technical articles with clear explanations and examples
Python program to delete a new node from the end of the doubly linked list
When it is required to delete a node from the end of a doubly linked list, a ‘Node’ class needs to be created. In this class, there are three attributes, the data that is present in the node, the access to the next node of the linked list, and the access to the previous node of the linked list.Below is a demonstration for the same −Exampleclass Node: def __init__(self, my_data): self.prev = None self.data = my_data self.next = None class double_list: def __init__(self): self.head = None ...
Read MorePython program to delete a new node from the middle of the doubly linked list
When it is required to delete a node from the middle of a doubly linked list, a ‘Node’ class needs to be created. In this class, there are three attributes, the data that is present in the node, the access to the next node of the linked list, and the access to the previous node of the linked list.Another class needs to be created that would have an initialization function, and the head of the node would be initialized to ‘None’ inside this.Multiple methods are defined by the user to add node to the linked list, to display the nodes ...
Read MoreGolang Program to find the parity of a given number.
Definition − Parity refers to the count of 1s. If count of 1s is even, then it’s even parity; and if the count of 1s is odd, then the parity is Odd.ExamplesConsider n = 20(00010100)Parity of the given number 20 is even.Approach to solve this problemStep 1 − Define a method, where n and is an argument, return type is int.Step 2 − Calculate the count of 1s in the given number’s bit.Examplepackage main import ( "fmt" "strconv" ) func FindParity(n int) bool { parity := false for n != 0 { if ...
Read MorePython program to find the maximum and minimum value node from a doubly linked list
When it is required to find the maximum and minimum values from a doubly linked list, a ‘Node’ class needs to be created. In this class, there are three attributes, the data that is present in the node, the access to the next node of the linked list, and the access to the previous node of the linked list.Below is a demonstration for the same −Exampleclass Node: def __init__(self, my_data): self.prev = None self.data = my_data self.next = None class double_list: def __init__(self): self.head = None ...
Read MorePython program to insert a new node at the beginning of the Doubly Linked list
When it is required to insert a new node at the beginning of a doubly linked list, a ‘Node’ class needs to be created. In this class, there are three attributes, the data that is present in the node, the access to the next node of the linked list, and the access to the previous node of the linked list.Below is a demonstration for the same −Exampleclass Node: def __init__(self, my_data): self.prev = None self.data = my_data self.next = None class double_list: def __init__(self): self.head = ...
Read MoreGolang Program to count the number of flips to convert a given integer to another.
ExamplesConsider two numbers m = 65 => 01000001 and n = 80 => 01010000Number of bits flipped is 2.Approach to solve this problemStep 1 − Convert both numbers into bits.Step 2 − Count number of bits are flipped.Examplepackage main import ( "fmt" "strconv" ) func FindBits(x, y int) int{ n := x ^ y count := 0 for ;n!=0; count++{ n = n & (n-1) } return count } func main(){ x := 65 y := 80 fmt.Printf("Binary of %d is: %s.", x, strconv.FormatInt(int64(x), 2)) fmt.Printf("Binary ...
Read MoreHow to convert the character values in an R data frame column to lower case?
The character values can be stored in uppercase, lowercase, or a mixture of the two. If we have values that are either in uppercase or the mixture of lower and upper then we can convert those character values to only lowercase by using tolower function. We simply need to pass the vector or column of the data frame inside the tolower function as shown in the below examples.Example1Consider the below data frame −> x1 y1 df1 df1Output x1 y1 1 C -0.1036851 2 C -0.6176530 3 B 0.5763786 4 A 0.1943794 5 C 1.1196470 6 ...
Read MorePython program to insert a new node at the end of the Doubly Linked List
When it is required to insert a new node at the end of a doubly linked list, a ‘Node’ class needs to be created. In this class, there are three attributes, the data that is present in the node, the access to the next node of the linked list, and the access to the previous node of the linked list.Below is a demonstration for the same −Exampleclass Node: def __init__(self, my_data): self.prev = None self.data = my_data self.next = None class double_list: def __init__(self): self.head = ...
Read MoreGolang Program to check if the binary representation of a number is palindrome or not
ExamplesFor example, 101, 11, 11011, 1001001 are Palindrome. 100, 10010 are not Palindrome.Approach to solve this problemStep 1 − Convert number into binary representation.Step 2 − Traverse the converted binary representation from both side and check whether representation is palindrome or not.Examplepackage main import ( "fmt" "strconv" ) func IsPalindrome(n int) bool{ rev := 0 k := n for k != 0 { rev = (rev > 1 } return n == rev } func main(){ n := 3 fmt.Printf("Binary representation of %d is: %s.", n, strconv.FormatInt(int64(n), 2)) if IsPalindrome(n) == true{ fmt.Println("Palindrome") } else { fmt.Println("Not a Palindrome") } }OutputBinary representation of 3 is: 11. Palindrome
Read MoreHow to subset columns that has less than four categories in an R data frame?
If column is categorical then there can be at least two categories and there is no limit for the total number of categories but it will also depend on the total number of cases. If we have a data frame that contain some categorical columns having more or less categories than 4 then we might want to subset columns having less than four categories. This could be required in situations when we want to subset the data biasedly or have some predefined data characteristics that allows this change. The subset of such columns can be done with the help of ...
Read More