Server Side Programming Articles - Page 1944 of 2650

Convert an array to reduced form (Hashing) in C++

Ayush Gupta
Updated on 16-Jan-2020 06:59:07

140 Views

In this tutorial, we will be discussing a program to convert an array to its reduced form using hashing.For this we will be provided with an array. Our task is to convert the given array in its reduced form such that it only contains elements ranging from 0 to n-1.Example Live Demo#include using namespace std; //converting array to its reduced form void convert(int arr[], int n){    // copying the elements of array    int temp[n];    memcpy(temp, arr, n*sizeof(int));    sort(temp, temp + n);    //creating a hash table    unordered_map umap;    int val = 0;    for ... Read More

Convert an Array to a Circular Doubly Linked List in C++

Ayush Gupta
Updated on 16-Jan-2020 06:55:53

372 Views

In this tutorial, we will be discussing a program to convert an array to a circular doubly linked list.For this we will be provided with an array. Our task is to take the elements of the array and get it converted into a circular doubly linked list.Example Live Demo#include using namespace std; //node structure for doubly linked list struct node{    int data;    struct node *next;    struct node *prev; }; //node creation struct node* getNode(){    return ((struct node *)malloc(sizeof(struct node))); } //printing the list int print_list(struct node *temp){    struct node *t = temp;    if(temp == NULL) ... Read More

Convert an arbitrary Binary Tree to a tree that holds Children Sum Property in C++

Ayush Gupta
Updated on 16-Jan-2020 06:50:38

365 Views

In this tutorial, we will be discussing a program to convert an arbitrary binary tree to a tree that holds children sum property.For this we will be provided with a binary tree. Our task is to convert it into the binary tree that follows the children sum property. But the restriction is that we can only increment the values present in the nodes, neither can change the structure of the tree or decrement values in the node.Example Live Demo#include #include using namespace std; //node structure for binary tree class node{    public:    int data;    node* left;    node* right; ... Read More

Convert all substrings of length ‘k’ from base ‘b’ to decimal in C++

Ayush Gupta
Updated on 16-Jan-2020 06:45:26

102 Views

In this tutorial, we will be discussing a program to convert all substrings of length ‘k’ from base ‘b’ to decimal.For this we will be provided with a string of some certain length. Our task is to take the substrings from the given string of size ‘k’ and get it converted into the decimal numbers from being in base ‘b’.Example Live Demo#include using namespace std; //converting the substrings to decimals int convert_substrings(string str, int k, int b){    for (int i=0; i + k = 0; i--){          sum = sum + ((sub.at(i) - '0') * pow(b, ... Read More

Difference between the and$ operator in php

Mahesh Parahar
Updated on 13-Jan-2020 06:43:02

506 Views

$ operatorOperator is used to define variables in php. For example, message. Such variables can contain any type of value like int, string, etc.$$ operator$$ is a special operator that contains the name of another variable and can be used to access the value of that variable.ExampleFollowing the example, shows the usage of '′vs′$' operators. Live Demo    PHP Example     Outputmessage Welcome to Tutorialspoint

Difference between the AND and && operator in php

Mahesh Parahar
Updated on 13-Jan-2020 06:39:02

438 Views

'AND' Logical operator'AND' operator is a logical AND operator but has low precedence to = operator.'&&' Logical operator'&&' is also a logical AND operator but has high precedence to = operator.ExampleFollowing the example, shows the difference of 'AND' vs '&&' operators. Live Demo    PHP Example     Output$result = $x AND $y bool(true) $result = $x && $y bool(false)

Difference between the | and || or operator in php

Mahesh Parahar
Updated on 13-Jan-2020 06:35:31

376 Views

'|' Bitwise OR operator'|' operator is a bitwise OR operator and is used to set the bit to 1 if any of the corresponding bit is 1.'||' Logical Or operator'||' is a logical Or operator and works on complete operands as whole.ExampleFollowing example, shows usage of '|' vs '||' operators. Live Demo    PHP Example     Output$x | $y = 3 $x || $y = 1

Difference between !== and ==! operator in PHP

Mahesh Parahar
Updated on 13-Jan-2020 06:33:04

557 Views

'!==' comparison operator'!==' operator checks the unequality of two objects with a type check. It does not converts the datatype and makes a typed check.For example 1 !== '1' will results true.'==!' comparison operator'==!' operator is combination of two operators and can be written as == (!operands).ExampleFollowing example, shows usage of '!==' vs '==!' operators. Live Demo    PHP Example     Output$x !== operator $y = bool(true) $x ==! operator $y = bool(true)

Difference between float and double in C/C++

Mahesh Parahar
Updated on 24-Feb-2020 08:04:39

2K+ Views

As we know that in C/C++ we require float and double data type for the representation of Floating point numbers i.e the numbers which have decimal part with them.Now on the basis of precision provided by both of these data types we can differentiate between both of them.In simple words it could be state that double has 2x more precision as compare than float which means that double data type has double precision than as compare to that of float data type.In terms of number of precision it can be stated as double has 64 bit precision for floating point ... Read More

Difference between Structure and Array in C

Mahesh Parahar
Updated on 25-Feb-2020 07:13:01

7K+ Views

In C both Structure and Array are used as container for data types i.e in both structure and array we can store data and also can perform different operations over them.On the basis of internal implementation following are some basic differences between both.Sr. No.KeyStructureArray1DefinitionStructure can be defined as a data structure used as container which can hold variables of different types.On other hand Array is a type of data structure used as container which can hold variables of same type and do not support multiple data type variables.2Memory AllocationMemory allocation for input data in structure does not necessary to be ... Read More

Advertisements