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
Server Side Programming Articles - Page 1694 of 2650
284 Views
ConceptWith respect of a given undirected graph of b nodes and a edges, the job is to determine minimum edges needed to build Euler Circuit in the given graph.Input b = 3, a = 2 Edges[] = {{1, 2}, {2, 3}}Output 1By connecting 1 to 3, we can build a Euler Circuit.MethodWith respect of a Euler Circuit to exist in the graph we need that every node should haveeven degree because then there exists an edge that can be applied to exit the node after entering it.Now, there can be two cases −Existence of one connected component in the graphWith respect of ... Read More
237 Views
ConceptGiven A x B Chessboard, the task is to calculate the Maximum numbers of cuts that we can build in the Chessboard so that the Chessboard is not divided into 2 parts.Examples The examples are given below −Input A = 2, B = 4Output Number of maximum cuts = 3Input A = 2, B = 2Output Number of maximum cuts = 1MethodFor A = 2, B = 2 ,we can only build 1 cut (mark in red). If we build 1 more cut then the chessboard will divide into 2 piecesFor A = 2, B = 4 ,we can makes 3 cuts (marks in red). ... Read More
411 Views
ConceptSuppose a board of length p and width q is given, we require to break this board into p*q squares such that cost of breaking is least. For this board, cutting cost for each edge will be given. In a nutshell, we require selecting such a sequence of cutting such that cost is minimized.Examples With respect of above board optimal way to cut into square is −Total minimum cost in above case is 65. It is computed evaluated implementing following steps.Initial Value : Total_cost = 0 Total_cost = Total_cost + edge_cost * total_pieces Cost 5 Horizontal cut Cost = 0 + ... Read More
448 Views
Suppose we have a 2D array. Where each cell of which consists number cost which represents a cost to visit through that cell, we have to find a path from top-left cell to bottom-right cell by which total cost consumed is minimum.So, if the input is like32101661319111448158710111141751234891254221141100331124221then the output will be 340 as (32 + 11 + 14 + 48 + 66 + 13 + 19 + 7 + 34 + 12 + 21 + 42 + 21) = 340To solve this, we will follow these steps −Define cell with x, y coordinate and distance parameter.Define an array matrix of ... Read More
513 Views
ConceptWith respect of given three sorted arrays A, B, and C of not necessarily same sizes, compute the lowest i.e. minimum absolute difference between the maximum and minimum number of any triplet A[i], B[j], C[k] such that they are under arrays A, B and C respectively, i.e., minimize (max(A[i], B[j], C[k]) – min(A[i], B[j], C[k])).Input−A : [ 2, 5, 6, 9, 11 ] B : [ 7, 10, 16 ] C : [ 3, 4, 7, 7 ]Output−1ExplanationWhen we select A[i] = 6 , B[j] = 7, C[k] = 7, we get the minimum difference as max(A[i], B[j], C[k]) - ... Read More
619 Views
Suppose we have different k sorted arrays. We have to merge these arrays and display the sorted result.So, if the input is like k = 3 and arrays are {2, 4}, {3, 5, 7}, {1, 10, 11, 12} , then the output will be 1 2 3 4 5 7 10 11 12To solve this, we will follow these steps −define one type of pair with first element is an integer and second element is another pair of integers, name it as ppi.Define an array opdefine one priority queue qfor initialize i := 0, when i < size of arr, ... Read More
262 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
439 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
395 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