Double Ended Priority Queue in C++

Hafeezul Kareem
Updated on 28-Jan-2021 06:53:07

697 Views

In this tutorial, we are going to create a double-ended priority queue using the set in c++.Let's see the steps to create a double-ended queue.Create a struct with a name as you wish.Create a variable for the queue using the set.size method that returns the size of the queue.is_empty method that returns whether the queue is empty or not.insert method to insert a new element into the queue.get_start method that returns an element from the left side of the queue.get_end method that returns the element from the right side of the queue.delete_start method that deletes the first element from the ... Read More

Double Base Palindrome in C++ Program

Hafeezul Kareem
Updated on 28-Jan-2021 06:51:40

363 Views

In this tutorial, we are going to write a program that checks whether the given number is a palindrome in two number systems.We have given a number and a base for another number system. We have to check whether the given number is a palindrome in the decimal number system and given number system.Let's see the steps to solve the problem.Initialize the number and number system base.Check whether the given number is a palindrome in the decimal number system or not.Convert the number into another number system in a string format.Check whether the converted number is palindrome or not.If the ... Read More

Divisors of n^2 That Are Not Divisors of n in C++ Program

Hafeezul Kareem
Updated on 28-Jan-2021 06:49:54

133 Views

In this tutorial, we are going to write a program that finds the divisors count of n-square and not n.It's a straightforward problem. Let's see the steps to solve the problem.Initialize the number n.Initialize a counter for divisors.Iterate from 2 to n^2n2.If the n^2n2 is divisible by the current number and nn is not divisible by the current number, then increment the count.Print the count.ExampleLet's see the code. Live Demo#include using namespace std; int getNumberOfDivisors(int n) {    int n_square = n * n;    int divisors_count = 0;    for (int i = 2; i

Division Without Using Operator in C++

Hafeezul Kareem
Updated on 28-Jan-2021 06:47:18

2K+ Views

In this tutorial, we are going to learn how to divide a number without using the division (/) operator.We have given two numbers, the program should return the quotient of the division operation.We are going to use the subtraction (-) operator for the division.Let's see the steps to solve the problem.Initialize the dividend and divisor.If the number is zero, then return 0.Store whether the result will be negative or not by checking the signs of dividend and divisor.Initialize a count to 0.Write a loop that runs until the number one is greater than or equals to the number two.Subtract the ... Read More

Divisible by 37 for Large Numbers in C++ Program

Hafeezul Kareem
Updated on 28-Jan-2021 06:45:55

250 Views

In this tutorial, we are going to write a program that checks whether the given large number is divisible by 37 or not.We are going to use a little bit of math here. Let's see the steps to solve the problem.Initialize the number.If the length of the given number is not divisible by 3, then add zeroes at the beginning of the number to make length is divisible by 3.Divide the number into 3 digits groups and add them.If the resultant sum is divisible by 37, then the given number is divisible by 37.If the resultant sum is 4 digits ... Read More

Divisibility by 64 with Allowed Bit Removal in C++ Program

Hafeezul Kareem
Updated on 28-Jan-2021 06:44:33

204 Views

In this tutorial, we are going to write a program that checks whether the given binary number is divisible by 64 or not.We have given a binary number and we can remove the bits to make it divisible by 64. After removing the bits, if the number is divisible by 64, then print Yes else No.The method that we are going to use is very simple. Let's see the steps to solve the problem.Initialize the binary number in string format.Iterate over the given binary number.Count the number of zeros.If the binary number contains more than or equal to 6 and ... Read More

Divisibility by 12 for a Large Number in C++

Hafeezul Kareem
Updated on 28-Jan-2021 06:42:37

183 Views

In this tutorial, we are going to write a program that checks whether the given large number in string format is divisible by 12 or not.We are going to use a little bit of math to solve this problem. If the number is divisible by 3 and 4, then the number will divisible by 12.A number is divisible by 3 if the sum of its digits is divisible by 3.A number is divisible by 4 if the last two digits of the number are divisible by 4.We are going to utilize the above statements and complete the program.ExampleLet's see the ... Read More

Divide Linked List into Two Lists of Size Ratio p:q in C++

Hafeezul Kareem
Updated on 28-Jan-2021 06:41:00

165 Views

In this tutorial, we are going to write a program that divides the given linked list into a p:q ratioIt's a straightforward program. Let's see the steps to solve the problem.Create a struct for the linked list node.Initialize the linked list with dummy data.Initialize the p:q ratio.Find the length of the linked list.If the length of the linked list is less than p + q, then it's not possible to divide the linked into a p:q ratio.Else iterate the linked list until p.After the p iterations, remove the link and create a new head for the second linked list.Now, print ... Read More

Divide Number into Two Parts Divisible by Given Numbers in C++

Hafeezul Kareem
Updated on 28-Jan-2021 06:39:27

586 Views

In this tutorial, we are going to write a program that divides a number into two parts which are divisible by the given numbers.We have given a number in string format and two other integers. The program should return whether it's possible to divide the given number into two parts such that the first part is divisible by the first number and the second part is divisible by the second part.Let's see the steps to solve the problem.Initialize the number and two integers for the division.Iterate over the number until the first part is divisible by the first number.Form the ... Read More

Divide Large Number Represented as String in C++ Program

Hafeezul Kareem
Updated on 27-Jan-2021 12:50:21

3K+ Views

In this tutorial, we are going to learn how to divide a large number that is represented as a string.We have given a large number in string format and a divisor. Our program should find a reminder.First, we will find a part of the given number that is greater than the dividend. And then we will add the remaining digits one by one to the divisor.Let's see the steps to solve the problem.Initialize the large number along with a divisor.Iterate over the given number until we extract the part that is greater than the divisor.Now, iterate from where we left ... Read More

Advertisements