AmitDiwan has Published 9818 Articles

Determinant of a Matrix in C++?

AmitDiwan

AmitDiwan

Updated on 16-Jan-2021 09:48:53

2K+ Views

The determinant of a matrix can be calculated only for a square matrix by multiplying the first row cofactor by the determinant of the corresponding cofactor and adding them with alternate signs to get the final result.$$A = \begin{bmatrix}a & b & c\d & e &f \g & h &i ... Read More

Disarium Number with examples in C++?

AmitDiwan

AmitDiwan

Updated on 16-Jan-2021 08:36:34

1K+ Views

A number whose sum of its digits powered with its respective position equals to the number itself is called a disarium number.The noOfDigits(int num) function takes the number and return the number of digits by constantly dividing the number by 10 while there is only ones place left. On each ... Read More

Depth of the deepest odd level node in Binary Tree in C++?

AmitDiwan

AmitDiwan

Updated on 16-Jan-2021 08:14:31

159 Views

Let us first define the struct that would represent a tree node that contains the int key and its left and right node child. If this is the first node to be created then it’s a root node otherwise a child node.struct Node {    int data;    struct Node ... Read More

Depth of an N-Ary tree in C++?

AmitDiwan

AmitDiwan

Updated on 16-Jan-2021 08:07:59

324 Views

Let us first define the struct that would represent a tree node that contains a character key and a vector of Node *.struct Node{    char key;    vector children; };Next we create our createNode(int key) function that takes an int key value and assign it to the key member ... Read More

Density of Binary Tree in One Traversal in C++?

AmitDiwan

AmitDiwan

Updated on 16-Jan-2021 08:03:50

214 Views

The density of a binary tree is calculated by dividing its size by its height.Binary tree density = size/height.Let us first define the struct that would represent a tree node that contains the data and its left and right node child. If this is the first node to be created ... Read More

Deletion in a Binary Tree in C++?

AmitDiwan

AmitDiwan

Updated on 16-Jan-2021 07:58:40

382 Views

The deletion is to be performed by replacing the deleted mode by bottom and rightmost node.Let us first define the struct that would represent a tree node that contains the data and its left and right node child. If this is the first node to be created then it’s a ... Read More

Diagonal of a Regular Heptagon in C++?

AmitDiwan

AmitDiwan

Updated on 16-Jan-2021 07:46:50

195 Views

To find the length of the diagonal we put the value of side in 2*side*sin (900/14). The value of sin (900/14) = 0.9.ExampleLet us see the following implementation to get the regular Heptagon diagonal from its side − Live Demo#include using namespace std; int main(){    float side = 12; ... Read More

Demlo number (Square of 11...1)” in C++?

AmitDiwan

AmitDiwan

Updated on 16-Jan-2021 07:44:20

257 Views

Demlo numbers are palindromic numbers that are generated by the square of number of form 11..1 given that the number is less than 10 digits.Let us first declare the string variables −string demNum = "1111"; string square = "";Now, we loop till the length of the demNum string. Inside the ... Read More

Deletions of “01” or “10” in binary string to make it free from “01” or “10" in C++?

AmitDiwan

AmitDiwan

Updated on 16-Jan-2021 07:40:45

141 Views

Let us first declare our initial string and calculate its length and pass them to the deleteSubstr(str,length) function.string str = "01010110011"; int length = str.length(); cout

Deleting a binary tree using the delete keyword in C++?

AmitDiwan

AmitDiwan

Updated on 16-Jan-2021 07:32:09

224 Views

Let us first define our binary tree using a class containing int data, btree_node * rightChild, btree_node * leftChild. The leftChild and rightChild are pointers to btree_node. All the members in our class are public.class btree_node {    public:       int data;       btree_node* leftChild;   ... Read More

Advertisements