Found 26504 Articles for Server Side Programming

Program to find out the minimum value from sum of node values of sub-trees in Python

Arnab Chakraborty
Updated on 23-Oct-2021 06:46:22

184 Views

Suppose, we have a tree that has all of its nodes numbered as 1 to n. Each of the nodes contains an integer value. Now if we remove an edge from the tree, the difference in the sum of the node values of the two sub-trees has to be minimal. We have to find out and return the minimum difference between such sub-trees. The tree is given to us as a collection of edges, and the values of the nodes are also provided.So, if the input is like n = 6, edge_list = [[1, 2], [1, 3], [2, 4], [3, ... Read More

Merge a linked list into another linked list at alternate positions in Java

Sunidhi Bansal
Updated on 22-Oct-2021 10:00:39

893 Views

We are given two data structures as linked list Let’s say, List_1 and List_2. The task is to merge the elements of linked list ‘List_2’ into the linked list ‘List_1’ at an alternate position and if we are left with the elements which can't be merged into ‘List_1’ then it will be printed as the ‘List_2’ remaining elements.For Example-:In −List_1 =List_2 =Out − Merged List is-:Explanation − we are given with two lists i.e. List_1 and List_2. We had merged the possible elements of list_2 into List_1 at alternate positions. So, elements after merging in List_1 are 10- >3->2->1->1->4->2->5->5 and in List_2 are ... Read More

Memory representation of Binomial Heap in C++

Sunidhi Bansal
Updated on 22-Oct-2021 09:43:54

511 Views

What is a Binomial Tree?Binomial tree is an ordered tree data structure, let's say, B0 consists of a single node whereas a binomial tree represented as Bk consists of two binomial trees i.e. Bk-1 which are linked together. The root of one binomial tree is the leftmost child of the root of the other binomial tree. Binomial tree is mostly used for fundamental and technical analysing of assets or the stocks.The nodes of a binomial tree represent the intrinsic value of an asset. It helps investors or buyers of the markets to analyze the right time and value for investment.What ... Read More

Min-Max Range Queries in Array in C++

Sunidhi Bansal
Updated on 22-Oct-2021 09:42:24

993 Views

Given an array Arr[] containing N elements. The goal is to find the minimum and maximum value from indexes of query.According to the query we are given starting index and ending indexes.For ExampleIn − Arr[] = { 1, 2, 3, 4, 5 } QStart = 1 QEnd = 4Out −Minimum Value : 2Maximum Value : 5Explanation −In the above queries the starting index is 1 and ending index is 4. Between these two indexes, minimum value in Arr is 2 and maximum value is 5In − Arr[] = { 10, 12, 3, 2, 5, 18 } QStart = 2 QEnd = 5Out −Minimum Value : ... Read More

New feature of C++17

Sunidhi Bansal
Updated on 22-Oct-2021 09:07:35

1K+ Views

The C++ Standards committee is always focusing on shipping new features every three years. The two main parts of the specification are the core functionality of the programming language and the Standard Template Library (STL). The new features are introduced to make the code cleaner, easier and compact. Following is the list of features that are introduced-:1. Fold ExpressionsFold expressions are used to write shorter codes for a variable number of arguments that can be passed to a function or can be returned from the function. It enables the use of any number of variables as arguments and in return ... Read More

2-3 Trees - Data Structures and Algorithms in C++

Sunidhi Bansal
Updated on 22-Oct-2021 08:56:52

8K+ Views

A 2-3 Tree is a type of tree in data structures in which every node of the tree is either a 2 nodeor 3 nodes. It is a special type of B-Tree with order 3.A 2 node in the tree is one which has one data part and two child nodes.A 3 node in the tree is one which has two data parts and three child nodes.Fig:- A 2-3 treeProperties of a 2-3 Tree:-Every internal node is either a 2 node or a 3 node.A node containing one data part can be a 2 node with exactly 2 children or ... Read More

Maximize the number of subarrays with XOR as zero in C++

Sunidhi Bansal
Updated on 22-Oct-2021 08:54:16

222 Views

We are given an array Arr[] containing integer values. The goal is to find the maximum number of subarrays with XOR as 0. The bits of any subarray can be swapped any number of times.Note:- 1

Maximize the summation of numbers in a maximum of K moves in range [L, R] in C++

Sunidhi Bansal
Updated on 22-Oct-2021 08:45:52

143 Views

We are given an array Arr[] containing integers and 2D array Q containing queries. Each query contains 3 values that are lpos, rpos and K. One can move from index i to next index i+1 in a single step or remain in that index. One can move from lpos to rpos in a maximum of K steps only. Add all numbers at each step including the leftmost number. The goal is to maximize the sum in maximum K moves. If no movement is possible from lpos to rpos in K steps then print “No”. Let us understand more.Let us see ... Read More

Minimum Sum Path In 3-D Array in C++

Sunidhi Bansal
Updated on 22-Oct-2021 08:35:04

189 Views

We are given a cube which can be formed using a 3-D array as cube[length][breadth][height]. The task is to calculate the minimum sum path which will be achieved by traversing the cube and hence print the result.Let us see various input output scenarios for this -In − int cube[length][breadth][height] = { { {2, 4, 1}, {3, 4, 5}, {9, 8, 7}}, { {5, 3, 2}, {7, 6, 5}, {8, 7, 6}}, { {3, 2, 1}, {4, 3, 2}, {5, 4, 3}}}Out  − Minimum Sum Path In 3-D Array are: 15Explanation − we are given a cube having length, breadth and height. Now, we ... Read More

Midy’s theorem in C++

Sunidhi Bansal
Updated on 22-Oct-2021 08:28:56

242 Views

We are given integer values as a_num that will store the numerator and p_den that will store the denominator which should be a prime number. The task is to check whether the operations performed on a_num after dividing with p_den proves the midy’s theorem or not.Steps to prove Midy’s theorem are-Input numerator as a_num and denominator as p_den which should always be a prime value.Divide the numbers. Check for the repeating decimal values.Store the decimal values until they are not repeating.Check whether the digits are even, if yes, then break them into halvesAdd both the numbers. If the output is ... Read More

Advertisements