Hafeezul Kareem has Published 345 Articles

Multiply any Number with using Bitwise Operator in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 25-Oct-2021 06:31:30

8K+ Views

In this tutorial, we are going write a program that multiplies the given two numbers using bitwise operators.The left shift () is used for the division.The multiplication of two numbers x, y can be written as x * y = (x * 2) * (y / 2) if y is ... Read More

Multiply a number by 15 without using * and / operators in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 25-Oct-2021 06:23:26

229 Views

We can using left shift (

Multiply a given Integer with 3.5 in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 25-Oct-2021 05:48:06

235 Views

To get the result of n * 3.5 we need to calculate (n * 2) + n + (n / 2). Moving the bits to left by 1 will give you n * 2 and moving the bits to right by will you n / 2. Add those to get ... Read More

Multiples of 3 or 7 in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 25-Oct-2021 05:40:28

813 Views

Given a number n, we need to find the count of multiples of 3 or 7 till n. Let's see an example.Input100Output43There are total of 43 multiples of 3 or 7 till 100.AlgorithmInitialise the number n.Initialise the count to 0.Write a loop that iterates from 3 to n.Increment the count ... Read More

Move last element to front of a given Linked List in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 25-Oct-2021 05:21:53

676 Views

Given a linked list, we have to move the last element to the front. Let's see an example.Input1 -> 2 -> 3 -> 4 -> 5 -> NULLOutput5 -> 1 -> 2 -> 3 -> 4 -> NULLAlgorithmInitialise the linked list.Return if the linked list is empty or it has ... Read More

Move all zeros to the front of the linked list in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 25-Oct-2021 05:02:21

225 Views

Given a linked list with random integers and zeroes. We have to move all the zeroes to the front of the linked list. Let's see an example.Input3 -> 0 -> 1-> 0 -> 0 -> 1 -> 0 -> 0 -> 3 -> NULLOutput0->0->0->0->0->3->1->1->3->NULL AlgorithmInitialise the linked list.Return if the ... Read More

Move all zeros to start and ones to end in an Array of random integers in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 25-Oct-2021 04:49:34

634 Views

In this tutorial, we are going to write a program that moves all zeroes to front and ones to end of the array.Given an array with zeroes and ones along with random integers. We have to move all the zeroes to start and ones to the end of the array. ... Read More

Move all zeroes to end of array in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 25-Oct-2021 04:44:33

2K+ Views

Given array with multiple zeroes in it. We have to move all the zeroes in the array to the end. Let's see an example.Inputarr = [4, 5, 0, 3, 2, 0, 0, 0, 5, 0, 1]Output4 5 3 2 5 1 0 0 0 0 0AlgorithmInitialise the array.Initialise an index ... Read More

Motzkin number in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 25-Oct-2021 04:40:19

126 Views

The Motzkin number series starts with 1, 1, 4, 9, etc.., We can get the generalised nth term with the sequence. The Motzkin number sequence is as follows.a0 = 1a1 = 1a2 = 4a3 = 9an = ((2 * n + 1)/ n + 2) * M(n-1) +((3 * n ... Read More

Previous 1 ... 3 4 5 6 7 ... 35 Next
Advertisements