Pavitra has Published 177 Articles

Python Program to Count set bits in an integer

Pavitra

Pavitra

Updated on 20-Dec-2019 07:22:44

311 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given an integer n, we need to count the number of 1’s in the binary representation of the numberNow let’s observe the solution in the implementation below −#naive approachExample Live Demo# count ... Read More

Python Program to Count number of binary strings without consecutive 1’

Pavitra

Pavitra

Updated on 20-Dec-2019 07:20:06

198 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a positive integer N, we need to count all possible distinct binary strings available with length N such that no consecutive 1’s exist in the string.Now let’s observe the solution ... Read More

Python Program to Count Inversions in an array

Pavitra

Pavitra

Updated on 20-Dec-2019 07:17:40

197 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a list, we need to count the inversion required and display it.Inversion count is obtained by counting how many steps are needed for the array to be sorted.Now let’s observe ... Read More

Python Program for Triangular Matchstick Number

Pavitra

Pavitra

Updated on 20-Dec-2019 07:15:18

77 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a number X which represents the floor of a matchstick pyramid, we need to display the total number of matchstick required to form a pyramid of matchsticks with x floors.Now ... Read More

Python Program for Tower of Hanoi

Pavitra

Pavitra

Updated on 20-Dec-2019 07:04:37

2K+ Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given n disks and a series of rods, we need to transfer all the disks to the final rod under the given constraints−We can move only one disk at a time.Only the ... Read More

Python Program for Subset Sum Problem

Pavitra

Pavitra

Updated on 20-Dec-2019 06:59:44

1K+ Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a set of non-negative integers in an array, and a value sum, we need to determine if there exists a subset of the given set with a sum equal to ... Read More

Python Program for Stooge Sort

Pavitra

Pavitra

Updated on 20-Dec-2019 06:55:01

145 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given an array, we need to sort it using stooge sort.Algorithm1. Check if value at index 0 is greater than value at last index, then swap them. 2. sort the initial ... Read More

Python Program for Sieve of Eratosthenes

Pavitra

Pavitra

Updated on 20-Dec-2019 06:51:15

2K+ Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a number n, we need to print all primes smaller than or equal to n. Constraint: n is a small number.Now let’s observe the solution in the implementation below −Exampledef ... Read More

Python Program for Recursive Insertion Sort

Pavitra

Pavitra

Updated on 20-Dec-2019 06:48:55

1K+ Views

In this article, we will learn about the solution to the problem statement given below.Problem statement− We are given an array, we need to sort it using the concept of recursive insertion sort.Insertion sort works on creating a parallel array in which we manually insert the elements in the specified ... Read More

Python Program for QuickSort

Pavitra

Pavitra

Updated on 20-Dec-2019 06:46:04

6K+ Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given an array, we need to sort it using the concept of quicksortHere we first partition the array and sort the separate partition to get the sorted array.Now let’s observe the solution ... Read More

Previous 1 ... 4 5 6 7 8 ... 18 Next
Advertisements