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 1899 of 2650
165 Views
In this problem, we are given an integer n. Our task is to print the largest number less than n which can be formed by changing one set bit of the binary representation of the number.Let’s take an example to understand the problemInput: n = 3 Output: 2 Explanation: (3)10 = (011)2 Flipping one set bit gives 001 and 010. 010 is greater i.e. 2.To solve this problem, we will have to flip the rightmost set bit and make it zero which will create the number the greatest possible number less than n that is found by flipping one bit ... Read More
4K+ Views
Prim’s Algorithm is a greedy method that is used to find minimum spanning tree for a given weighted undirected graph.Weighted graph is a graph that has all edges with weight values.Undirected graph is a special type of graph in which all edges are bidirectional.Minimum spanning tree is a subset that contains all edges and vertices but no cycle and has the least possible total edge weight.In this article, we will learn about prim’s algorithm to find minimum spanning tree. Usually, the algorithm uses two arrays but in this solution, we will use only one.Program to show the implementation of prim’s ... Read More
130 Views
In this problem, we are given a number N. our task is to check whether the sum of digits at odd place of the number gives a prime number or not.Primality Test is the algorithm that is used to check whether the given number is prime or not.Let’s take an example to understand the problem, Input: 3425 Output: No Explanation: sum digits at odd place = 5 + 4 = 9, which is not a prime number.To solve this problem an easy approach would be adding all digits that are at odd places in the number and then checking whether ... Read More
12K+ Views
Prime Factor is a prime number which is the factor of the given number.Factor of a number are the numbers that are multiplied to get the given number.Prime Factorisation is the process of recursively dividing the number with its prime factors to find all the prime factors of the number.Example : N = 120 Prime factors = 2 5 3 Factorization : 2 * 2 * 2 * 3 * 5Some points to remember about prime factors of a numberSet of prime factors of a number is unique.Factorization is important in many mathematical calculations like divisibility, finding common denominators, etc.It’s ... Read More
385 Views
A sorted and rotated array is an array that is sorted in ascending or descending order and then rotated either left or right by a specific number of elements. There should exist exactly one pivot point around which the array is rotated. In this article, our task is to find the minimum element in the given sorted and rotated array. We will use the following two approaches mentioned below: Using Linear Search Using Binary Search Example Here is an example of searching the ... Read More
1K+ Views
Suppose we have an integer array called nums, we have to find the contiguous subarray within an array (containing at least one number) which has the largest product. So if the array is [2, 3, -2, 4], the output will be 6, as contiguous subarray [2, 3] has max product.To solve this, we will follow these steps −max_list := list of size nums, and fill with 0min_list := list of size nums, and fill with 0max_list[0] := nums[0] and min_list[0] := nums[0]for i in range 1 to length of numsmax_list[i] = max of max_list[i - 1]*nums[i], min_list[i - 1]*nums[i] and ... Read More
270 Views
In this problem, we are given two integers L and R. Our task to print the total numbers that have set bits counting to a prime number that is in between L to R.Let’s take an example to understand the problemInput: L = 7, R = 12 Output: 6 Explanation: 7 -> 111 , set bits = 2, prime number. 8 -> 1000 , set bits = 1, not prime number. 9 -> 1001 , set bits = 2, prime number 10 -> 1010 , set bits = 2, prime number 11 -> 1011, set bits = 3, prime number ... Read More
499 Views
Suppose we have a linked list, we have to perform the insertion sort on this list. So if the list is like [9, 45, 23, 71, 80, 55], sorted list is [9, 23, 45, 55, 71, 80].To solve this, we will follow these steps −dummy := new Node with some random valuenode := given listwhile node is not null, newNode = next of node, dummyHead := next of dummy, prevDummyHead := dummywhile true −if dummyHead is not present, value of dummyHead > value of nodenext of node := dummyHeadnext of prevDummyHead := nodebreak the loopprevDummyHead := dymmyHead, and dummyHead = ... Read More