Articles on Trending Technologies

Technical articles with clear explanations and examples

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

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 457 Views

When it is required to insert a new node in 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.Below is a demonstration for the same −Exampleclass Node:    def __init__(self, my_data):       self.previous = None       self.data = my_data       self.next = None class double_list:    def __init__(self):       self.head = ...

Read More

Golang Program to count the set bits in an integer.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 2K+ Views

ExamplesFor example, 101, 11, 11011 and 1001001 set bits count 2, 2, 4 and 3 respectively.Approach to solve this problemStep 1 − Convert number into binary representation.Step 2 − Count the number of 1s; return count.Examplepackage main import (    "fmt"    "strconv" ) func NumOfSetBits(n int) int{    count := 0    for n !=0{       count += n &1       n >>= 1    }    return count } func main(){    n := 20    fmt.Printf("Binary representation of %d is: %s.", n,    strconv.FormatInt(int64(n), 2))    fmt.Printf("The total number of set bits in %d is %d.", n, NumOfSetBits(n)) }OutputBinary representation of 20 is: 10100. The total number of set bits in 20 is 2.

Read More

How to create a frequency table in data frame format in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 8K+ Views

To create a frequency table in R, we can simply use table function but the output of table function returns a horizontal table. If we want to read the table in data frame format then we would need to read the table as a data frame using as.data.frame function. For example, if we have a table called T then to convert it into a data frame format we can use the command as.data.frame(T).Example1> x1 x1Output[1] 2 0 2 3 2 3 1 2 1 4 0 0 4 4 1 3 1 2 1 3 2 3 2 1 4 ...

Read More

Python program to remove duplicate elements from a Doubly Linked List\\n

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 317 Views

When it is required to remove the duplicate elements in 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.previous = None       self.data = my_data       self.next = None class double_list:    def __init__(self):       self.head = None     ...

Read More

Golang Program to find the minimum and maximum number, using binary operations.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 269 Views

ExamplesFor example, x = 12, y = 15 => Maximum number is 15.For example, x = 13, y = 17 => Minimum number is 13.Approach to solve this problemStep 1 − Define method, findMax and findMin, that accept two integer x and y.Step 2 − Return integer according to defined method.Examplepackage main import "fmt" func FindMax(x, y int){    fmt.Printf("Maximum element in %d, and %d is: %d", x, y, x - ((x - y) &    ((x - y) >> 31))) } func FindMin(x, y int) {    fmt.Printf("Minimum element in %d, and %d is: %d", x, y, y + ...

Read More

Python program to rotate doubly linked list by N nodes

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 305 Views

When it is required to rotate a doubly linked list by a specific number of nodes, 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.previous = None       self.data = my_data       self.next = None class double_list:    def __init__(self):       self.head = None ...

Read More

Golang Program to round up the next highest power of 2.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 609 Views

ExamplesFor example, n = 12 => Next number power of 2 is 16.For example, n = 20 => Next number power of 2 is 32.Approach to solve this problemStep 1 − Define method, that accepts a number n.Step 2 − Iterate k := 1 until k < n.Step 3 − In a loop, calculate k

Read More

Python program to search an element in a doubly linked list

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 607 Views

When it is required to search for an element in 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 it and ...

Read More

Golang Program to round up the next previous power of 2.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 286 Views

ExamplesFor example, n = 12 => Previous number power of 2 is 8.For example, n = 20 => Previous number power of 2 is 16.Approach to solve this problemStep 1 − Define a method that accepts a number n.Step 2 − Perform n | (n >> k), where k is 1, 2, 4, 8, 16.Step 3 − At the end, return n - (n >> 1).Examplepackage main import "fmt" func PreviousPowOf2(n int) int{    n = n | (n >> 1)    n = n | (n >> 2)    n = n | (n >> 4)    n = ...

Read More

Python Program to Print an Identity Matrix

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 871 Views

When it is required to print an identity matrix, nested loops can be used.Below is a demonstration for the same −Examplen = 4 print("The value of n has been initialized to " +str(n)) for i in range(0, n):    for j in range(0, n):       if(i==j):          print("1", sep=" ", end=" ")       else:          print("0", sep=" ", end=" ")    print()OutputThe value of n has been initialized to 4 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1ExplanationThe value of ‘n’ is ...

Read More
Showing 1431–1440 of 61,248 articles
« Prev 1 142 143 144 145 146 6125 Next »
Advertisements