Found 26504 Articles for Server Side Programming

Convert singly linked list into XOR linked list in C++

Ayush Gupta
Updated on 22-Jan-2020 07:13:44

285 Views

In this tutorial, we will be discussing a program to convert a singly linked list into XOR linked list.For this we will be provided with a singly linked list. Our task is to take the elements of that list and get it converted into a XOR linked list.Example Live Demo#include using namespace std; //node structure of linked list struct Node {    int data;    struct Node* next; }; //creation of new node Node* newNode(int data){    Node* temp = new Node;    temp->data = data;    temp->next = NULL;    return temp; } //printing singly linked list void print(Node* ... Read More

Convert singly linked list into circular linked list in C++

Ayush Gupta
Updated on 22-Jan-2020 07:07:07

567 Views

In this tutorial, we will be discussing a program to convert a singly linked list into circular linked list.For this we will be provided with a singly linked list. Our task is to take the elements of that list and get it converted into a circular linked list.Example Live Demo#include //node structure of linked list struct Node {    int data;    struct Node* next; }; //converting singly linked list //to circular linked list struct Node* circular(struct Node* head){    struct Node* start = head;    while (head->next != NULL)       head = head->next;    //assigning start to ... Read More

Convert min Heap to max Heap in C++

Ayush Gupta
Updated on 22-Jan-2020 07:04:04

741 Views

In this tutorial, we will be discussing a program to convert min heap to max heap.For this we will be provided with the array representation of the min heap. Our task is to convert that given min heap to max heap in O(n) time complexity.Example Live Demo#include using namespace std; //converting a given subtree into a heap void convert_arrayheap(int arr[], int i, int n){    int l = 2*i + 1;    int r = 2*i + 2;    int largest = i;    if (l < n && arr[l] > arr[i])       largest = l;    if (r ... Read More

Convert Hexadecimal value String to ASCII value String in C++

Ayush Gupta
Updated on 22-Jan-2020 07:00:38

2K+ Views

In this tutorial, we will be discussing a program to convert hexadecimal value string to ASCII value string.For this we will be provided with a string with some hexadecimal values. Our task is to get that hexadecimal value and convert it into equivalent ASCII values.Example Live Demo#include using namespace std; string convert_ASCII(string hex){    string ascii = "";    for (size_t i = 0; i < hex.length(); i += 2){       //taking two characters from hex string       string part = hex.substr(i, 2);       //changing it into base 16       char ch ... Read More

How to Install PHP 7 on Ubuntu Linux 14.04 LTS

Sharon Christine
Updated on 22-Jan-2020 06:58:20

593 Views

PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language. Originally created by Rasmus Lerdorf in 1994, the PHP reference implementation is now produced by The PHP Group. The latest version PHP is PHP7 and it provides 2x faster performance and 50% better memory consumption than PHP version 5.6. This article explains “How to install PHP7 on Ubuntu Linux”.Before installing PHP7, you should need to install a PPA called ondrej/php. This allows you to co-install PHP versions 5.6 and 7.0.Configuring a PPA for co-installable PHP 5.6 + 7.0To configure a PPA, use ... Read More

Convert given time into words in C++

Ayush Gupta
Updated on 22-Jan-2020 06:56:25

322 Views

In this tutorial, we will be discussing a program to convert given time into words. For this we will be provided with a specific time in the digital format.Our task is to convert that particular time into wordsExample#include using namespace std; //printing time in words void convert_time(int h, int m){    char nums[][64] = {       "zero", "one", "two", "three", "four",       "five", "six", "seven", "eight",       "nine", "ten", "eleven", "twelve",       "thirteen", "fourteen", "fifteen",       "sixteen", "seventeen", "eighteen",       "nineteen", "twenty", "twenty       one", ... Read More

Maximum spiral sum in Binary Tree in C++

Narendra Kumar
Updated on 03-Jun-2020 08:17:12

171 Views

In this problem, we are given a binary tree. Our task is to create a program that will find the maximum spiral sum in a binary tree in C++.Spiral sum of a binary tree is the sum of nodes that are encountered in the spiral traversal of the binary tree.In the spiral traversal of a tree, the nodes are traversed from the root to the leaf node. The traversal takes place from left to right then for the next level from right to left and so on for the further levels.Example −Output −5Explanation −We will consider the spiral traversal until the ... Read More

Maximum size subset with given sum in C++

Narendra Kumar
Updated on 21-Jan-2020 11:30:13

771 Views

Problem statementGiven an array of N elements and sum. We need to find size of maximum size subset whose sum is equal to given sumExampleIf input array is arr = { 2, 3, 5, 10 } and sum = 20 then output will be 4 as −2 + 3 + 5 + 10 = 20 which is equal to given sumAlgorithmWe can use dynamic programming to solve this problem.To count the maximal subset, we use another DP array (called as ‘count array’) where count[i][j] is maximal of.count[i][j-1]. Here current element is not considered.scount[i- X][j-1] + 1. Here X is value ... Read More

Maximum segment value after putting k breakpoints in a number in C++

Narendra Kumar
Updated on 03-Jun-2020 08:19:11

266 Views

In this problem, we are given a string that denotes a large number and an integer k roar denotes the number of breakpoints. Our task is to create a program that will find the maximum segment value after putting L breakpoints in a number.Here, we have to find the maximum number that can be generated after putting k breakpoint in the number given by the string.Let's take an example to understand the problemInput − string = “45972”, k = 3Output − 97Explanation −All possible number is: 45    9    7    2 4    59    7    2 ... Read More

Maximum removal from array when removal time >= waiting time in C++

Narendra Kumar
Updated on 03-Jun-2020 08:20:38

120 Views

In this problem, we are given an array of N elements. Our task is to find the maximum removal from the array when removal time >= waiting time.So, here we will be removing the elements of the array. The value of the element of the array denotes the removal time(time taken to remove the element from the array).The element has a waiting time which is the time it will have to wait till it will get removed.The element can be removed from the only if the removal time is greater than the time it has to wait.We have to find ... Read More

Advertisements