Server Side Programming Articles - Page 1669 of 2646

Python - How and where to apply Feature Scaling?

Nizamuddin Siddiqui
Updated on 06-Aug-2020 12:00:35

297 Views

It is a step of Data pre-processing which is applied to independent variables or features of data. It basically helps to normalise the data within a particular range.Why scaling?Most of the times, your dataset will contain features highly varying in magnitudes, units and range. But since, most of the machine learning algorithms use Euclidian distance between two data points in their computations, this is a problem.If left alone, these algorithms only take in the magnitude of features neglecting the units. The results would vary greatly between different units, 5kg and 5000gms.The features with high magnitudes will weigh in a lot ... Read More

Python - Getting started with SymPy module

Nizamuddin Siddiqui
Updated on 06-Aug-2020 11:54:41

774 Views

SymPy is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible. SymPy is written entirely in Python. SymPy only depends on mpmath, a pure Python library for arbitrary floating point arithmetic, making it easy to use.#Installing sympy modulepip install sympySymPy defines following numerical types: Rational and Integer. The Rational class represents a rational number as a pair of two Integers, numerator and denominator, so Rational(1, 2) represents 1/2, Rational(5, 2) 5/2 and so on. The Integer class represents Integer number.SymPy ... Read More

Sum of the nodes of a Circular Linked List in C++

sudhir sharma
Updated on 06-Aug-2020 08:29:34

346 Views

In this problem, we are given a circular linked list. Our task is to create a program to find the sum of the nodes of a Circular Linked List.We simply need to add all the node values of the linked list.Some important definitions Linked List is a sequence of data structures, which are connected together via links.Circular Linked List is a variation of the Linked list in which the first element points to the last element and the last element points to the first element. Both Singly Linked List and Doubly Linked List can be made into a circular linked list.Now, let’s ... Read More

Sum of the natural numbers (up to N) whose modulo with K yield R in C++

sudhir sharma
Updated on 06-Aug-2020 08:26:42

307 Views

In this problem, we are given three numbers N, K and R. Our task is to create a program to find the Sum of the natural numbers (up to N) whose modulo with K yield R.We will add all the numbers less than N that satisfy the following condition, i%K == R.Let’s take an example to understand the problem, Input N = 14, K = 4, R = 1Output 28Explanation − All the numbers less than N, that given 1 as remainder when divided by 4 are 1, 5, 9, 13.To solve this problem, we will loop from R to N, and ... Read More

Sum of the multiples of two numbers below N in C++

sudhir sharma
Updated on 06-Aug-2020 08:25:22

392 Views

In this problem, we have given three integers M1, M2, and N. Our task is to create a program to find the sum of multiples of two numbers below N.Here, we will add all the elements below N which are multiples of either M1 or M2Let’s take an example to understand the problem, Input N = 13, M1 = 4, M2 = 6Output  20Explanation − Number that are multiples of 4 and 6 that are less than 13 are 4, 6, 8, 12.A simple solution to the problem is to be looping from 1 to N and adding all values that can ... Read More

Sum of the mirror image nodes of a complete binary tree in an inorder way in C++

sudhir sharma
Updated on 06-Aug-2020 08:24:23

267 Views

In this problem, we are given a complete binary tree. Our task is to create a program to find the sum of the mirror image nodes of a complete binary tree in an inorder way.Here, we have to find the inorder traversal of the left sun-tree, and then for each node, we will add the mirror image with it. This means if we are traversing the left leaf node, we will add the value of the right leaf node with it. As it is the mirror image node.Some important definitionsComplete binary tree is a binary tree where all levels have ... Read More

Sum of the minimum elements in all connected components of an undirected graph in C++

sudhir sharma
Updated on 06-Aug-2020 08:17:40

455 Views

In this problem, we are given an array arr of N numbers where arr[i] represents (i+1)th node. Also, there are M pairs of edges where u and v represent the node connected by the edge. Our task is to create a program to find the sum of the minimum elements in all connected components of an undirected graph. If a node has no connectivity to any other node, count it as a component with one node.Let’s take an example to understand the problem, Input arr[] = {2, 7, 5, 1, 2} m = 2 1 2 4 5Output 8Explanation Below is the graph ... Read More

Sum of the elements from index L to R in an array when arr[i] = i * (-1)^i in C++

sudhir sharma
Updated on 06-Aug-2020 08:12:58

455 Views

In this problem, we are given two numbers L and R. We also have an array arr[] such that arr[i] = i*(-1)^i. Our task is to create a program to calculate the sum of the element from index L to R in an array when arr[i] = i*(-1)^i.So, we need to find the sum of elements within the range [L, R] of the array.Let’s take an example to understand the problem, Input L = 2 , R = 6Output 4Explanation arr[] = {-1, 2, -3, 4, -5, 6} Sum = 2+ (-3) + 4 + (-5) + 6 = 4A simple solution to ... Read More

Sum of the digits of a number N written in all bases from 2 to N/2 in C++

sudhir sharma
Updated on 06-Aug-2020 08:10:56

225 Views

In this problem, we are given a number N. Our task is to create a program to find the sum of the digits of the number N in bases from 2 to N/2.So, we have to convert the base of the number to all bases from 2 to N/2 i.e. for n = 9, bases will be 2, 3, 4. And the find the sum of all digits in these bases.Let’s take an example to understand the problem, Input N = 5Output 2Explanation  base from 2 to N/2 is 2. 52 = 101, sum of digits is 2.To, solve this problem, we take ... Read More

Sum of the alternate nodes of linked list in C++

sudhir sharma
Updated on 06-Aug-2020 08:08:29

604 Views

In this problem, we are given a linked list. Our task is to print the sum of alternate nodes of the linked list.Linked list is a sequence of data structure which are connected together via links.Now, let’s get back to the problem. Here, we will add alternate nodes of the linked list. This means we will add nodes are positions 0, 2, 4, 6, …Let’s take an example to understand the problem,  Input 4 → 12 → 10 → 76 → 9 → 26 → 1Output 24Explanation considering alternate strings − 4 + 10 + 9 + 1 = 24To solve this problem, ... Read More

Advertisements