Articles on Trending Technologies

Technical articles with clear explanations and examples

Queries for bitwise AND in the index range [L, R] of the given Array using C++

Prateek Jangid
Prateek Jangid
Updated on 26-Nov-2021 2K+ Views

In this article, we have given a problem in which we are given an array of integers, and we are tasked to find the bitwise AND of the given ranges, for example 7minus;Input: arr[ ] = {1, 3, 1, 2, 32, 3, 3, 4, 4}, q[ ] = {{0, 1}, {3, 5}} Output: 1 0 0 1 AND 31 = 1 23 AND 34 AND 4 = 00 Input: arr[ ] = {1, 2, 3, 4, 510, 10 , 12, 16, 8}, q[ ] = {{0, 42}, {1, 33, 4}} Output: 0 8 0We are going to apply the brute ...

Read More

Find the Pentagonal Pyramidal Number using C++

Prateek Jangid
Prateek Jangid
Updated on 26-Nov-2021 358 Views

A pentagonal pyramidal number is equal to the number of items in a pentagonal base pyramid. Look at some Pentagonal numbers below.Sum of Pentagonal Numbers till N equals to Nth Pentagonal Pyramidal Number. In this article, we will discuss finding the Nth Pentagonal Pyramidal number, for exampleInput : N = 4 Output : 40 Explanation : Sum of first four pentagonal numbers 1, 5, 12, 22 is 40. Input : N = 6 Output : 126 Explanation : Sum of first four pentagonal numbers 1, 5, 12, 22, 35, 51 is 40.Approach to find The SolutionSimple ApproachAs per the ...

Read More

Find the Pell Number using C++

Prateek Jangid
Prateek Jangid
Updated on 26-Nov-2021 724 Views

In the given problem, we are given an integer n we need to find Pn, i.e., the pell number in that position. Now, as we know, pell number is a part of a series given by this formula −Pn = 2*Pn-1 + Pn-2With first two starting numbers − P0 = 0 and P1 = 1Approach to find The SolutionNow we will solve this problem by two approaches: recursive and iterative.Recursive ApproachIn this formula, we will recursively apply the formula of Pell Number and do n iterations.Example#include using namespace std; int pell(int n) {    if(n

Read More

C++ Return Previous Element in an Expanding Matrix

Prateek Jangid
Prateek Jangid
Updated on 26-Nov-2021 323 Views

Discuss a problem based on expanding the matrix. Expanding matrix is a matrix whose size continuously increases by some factor.Here we have a matrix of characters whose size is expanding by a factor of 2, i.e., if the original size of the matrix is N * N, then the size of the expanded matrix becomes 2N * 2N. We are given a sequence of characters present at ( i, j ), and we need to return the sequence of characters present at (i, (j - N - 1)%N).Let’s understand by visualizing some initial expanded matrix, Given Matrix -> [ a, ...

Read More

Find the Pattern of 1's inside 0's using C++

Prateek Jangid
Prateek Jangid
Updated on 26-Nov-2021 463 Views

In this article we are given values of several rows and several columns. We need to print a Box pattern such that 1’s get printed on 1st row, 1st column, last row, last column, and 0’s get printed on remaining elements. For example −Input : rows = 5, columns = 4 Output :    1 1 1 1    1 0 0 1    1 0 0 1    1 0 0 1    1 1 1 1 Input : rows = 8, columns = 9 Output :    1 1 1 1 1 1 1 1 1   ...

Read More

C++ Reverse a path in BST using queue

Prateek Jangid
Prateek Jangid
Updated on 26-Nov-2021 289 Views

Given a binary search tree, and we are required to reverse its path from a particular key, for example.Approach to Find the SolutionIn this approach, we will make a queue and push all the nodes until we get the root.Example  #include using namespace std; struct node {    int key;    struct node *left, *right; }; struct node* newNode(int item){    struct node* temp = new node;    temp->key = item;    temp->left = temp->right = NULL;    return temp; } void inorder(struct node* root){    if (root != NULL) {        inorder(root->left);        cout ...

Read More

Restoring Division Algorithm For Unsigned Integer in C++

Prateek Jangid
Prateek Jangid
Updated on 26-Nov-2021 2K+ Views

Discuss dividing an unsigned integer using a division algorithm. Some division algorithms are applied on paper, and others are implemented on digital circuits. Division algorithms are of two types: slow division algorithm and fast division algorithm. Slow division algorithm includes restoring, non-performing restoring, SRT, and non-restoring algorithm.In this tutorial, we will discuss the Restoring algorithm, assuming that 0 < divisor < dividend.Approach to Find the SolutionIn this, we will use register Q to store quotient, register A to store remainder, and M to store divisor. The initial value of A is kept at 0, and its value is restored, which ...

Read More

Responsive Video or Slideshow Embeds in Bootstrap with Examples

Prateek Jangid
Prateek Jangid
Updated on 26-Nov-2021 669 Views

Bootstrap is a free open source and is one of the most famous HTML, CSS, and Javascript frameworks. It's used for user interfaces and themes that create what a user sees in a website or application, and it's utilized on the client rather than the server.Responsive web applications automatically adapt to various screen sizes. It is used to create responsive mobile-first web apps and websites; mobile-first refers to designing for smaller displays first and then scaling up to bigger ones. As a result, you won't have to worry about your app not working on different devices or with different screen ...

Read More

Find the Pair with a Maximum Sum in a Matrix using C++

Prateek Jangid
Prateek Jangid
Updated on 26-Nov-2021 363 Views

In this article, we will discuss finding a pair with a maximum sum in a given matrix or 2-D array. For exampleInput : matrix[m][n] = {    { 3, 5, 2 },    { 2, 6, 47 },    { 1, 64, 66 } } Output : 130 Explanation : maximum sum is 130 from element pair 64 and 66. Input : matrix[m][n] = {    { 55, 22, 46 },    { 6, 2, 1 },    { 3, 24, 52 } } Output : 107 Explanation : maximum sum is 130 from element pair 55 and ...

Read More

Find the Pair with Given Sum in a Matrix using C++

Prateek Jangid
Prateek Jangid
Updated on 26-Nov-2021 378 Views

In this article, we will discuss the program of finding a pair with a given sum in a given matrix. For example −Input : matrix[n][m] = {    { 4, 6, 4, 65 },    { 56, 1, 12, 32 },    { 4, 5, 6, 44 },    { 13, 9, 11, 25 } }, SUM = 20 Output : Pair exists. Explanation : Sum = 20 is equal to the sum of numbers 9 and 11 which exists in the matrix. Input : matrix[n][m] = {    { 5, 7, 3, 45 ...

Read More
Showing 46881–46890 of 61,298 articles
Advertisements