
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

254 Views
Suppose we have a binary tree; we have to calculate the length of the longest path which consists of nodes with consecutive values in increasing order. Every node will be treated as a path of length 1.So, if the input is likethen the output will be 3 as (11, 12, 13) is maximum consecutive path.To solve this, we will follow these steps −Define a function solve(), this will take root, prev_data, prev_length, if not root is non-zero, then −return prev_lengthcur_data := val of rootif cur_data is same as prev_data + 1, then −return maximum of solve(left of root, cur_data, prev_length+1) ... Read More

431 Views
we have an array A. A has all elements occurring m times, but one element occurs only once. We have to find that unique element.So, if the input is like A = [6, 2, 7, 2, 2, 6, 6], m = 3, then the output will be 7.To solve this, we will follow these steps −INT_SIZE := 8 * size of an integer type variableDefine an array count of size: INT_SIZE. and fill with 0for initialize i := 0, when i < INT_SIZE, update (increase i by 1), do −for initialize j := 0, when j < size, update (increase ... Read More

387 Views
Suppose we have a binary tree. As we know the succinct encoding of Binary Tree performs close to lowest possible space. The n’th Catalan number is designated by the number of structurally different binary trees with n different nodes. If the n is large, this is about 4n; thus, we require minimum about log2(4) n = 2n bits to encode it. A succinct binary tree therefore would consume 2n + O(n) bits.So, if the input is likethen the output will beencoded −Structure List 1 1 1 0 0 1 0 0 1 0 1 0 0Data List 10 20 40 ... Read More

2K+ Views
Pandas is a very widely used python library for data cleansing, data analysis etc. In this article we will see how we can use the query method to fetch specific data from a given data set. We can have both single and multiple conditions inside a query.Reading the dataLet’s first read the data into a pandas data frame using the pandas library. The below program just does that.Exampleimport pandas as pd # Reading data frame from csv file data = pd.read_csv("D:\heart.csv") print(data)OutputRunning the above code gives us the following result −Query with single conditionNext we see how we ... Read More

514 Views
As part of data cleansing activities, we may sometimes need to take out the integers present in a list. In this article we will have an array containing both floats and integers. We will remove the integers from the array and print out the floats.With astypeThe astype function will be used to find if an element from the array is an integer or not. Accordingly we will decide to keep or remove the element from the array and store it in the result set.Example Live Demoimport numpy as np # initialising array A_array = np.array([3.2, 5.5, 2.0, 4.1, 5]) ... Read More

2K+ Views
Sometimes in a Python dictionary we may need to to filter out certain keys of the dictionary based on certain criteria. In this article we will see how to filter out keys from Python dictionary.With for and inIn this approach we put the values of the keys to be filtered in a list. Then iterate through each element of the list and check for its presence in the given dictionary. We create a resulting dictionary containing these values which are found in the dictionary.Example Live DemodictA= {'Mon':'Phy', 'Tue':'chem', 'Wed':'Math', 'Thu':'Bio'} key_list = ['Tue', 'Thu'] print("Given Dictionary:", dictA) print("Keys for filter:", ... Read More

1K+ Views
Both abs() and fabs() represent the mathematical functions which give us the absolute value of numbers. But there is a subtle difference between both of them which we can explore in the exmaples below.ExampleThe abs() functions returns the absolute value as an integer or floating point value depending on what value was supplied dot it. But the fabs) function will always return the value as floating point irrespective of whether an integer or a floating point was supplied to it as a parameter. Live Demoimport math n = -23 print(abs(n)) print(math.fabs(n)) n = 21.4 print(abs(n)) print(math.fabs(n)) n = ... Read More

906 Views
In this problem, we are given a two matrix mat[][]. Our task is to create a program to find the maximum sum of elements from each row in the matrix in C++.Problem DescriptionHere, we will find the maximum sum by taking one element from each row of the matrix in such a way that the element at the current row is greater than the last row element to be considered as a sum. We will find the maximum sum of elements that follows the above condition and print -1 if it is not possible.Let’s take an example to understand the ... Read More

345 Views
In this article, we are given a number N. Our task is to create a program to find the maximum sum of distinct numbers with LCM as N in C++. To achive this first of all we need to find the sum of maximum numbers that have N as the Lowest Common Multiple (LCM). For better understanding Let us go through 3 key concepts − Least Common Multiple (LCM): The lowest common multiple(LCM) of two or more integers is the smallest positive integer that is divisible for all of the integers. For example, the LCM of 4 and 5 ... Read More

190 Views
In this problem, we are a number N. Our task is to create a program to find the Maximum sum of distinct numbers such that LCM of these numbers is N in C++.Problem DescriptionWe need to find the sum of all factors of the number N. And add all distinct to find the maximum sum.Let’s take an example to understand the problem, InputN = 12Output28ExplanationAll distinct factors of N are 1, 2, 3, 4, 6, 12. Sum = 1 + 2 + 3 + 4 + 6 + 12 = 28Solution ApproachA simple solution will be finding all the factors ... Read More