Best meeting point in 2D binary array in C++

sudhir sharma
Updated on 22-Nov-2019 07:32:49

268 Views

In this problem, we are given a 2D binary array i.e. it has values that are either 0 or 1, where 1 is marked as a home of a person of the group. And people of the group want to meet. So, they need to minimise the total distance travelled by them for meeting at a common point. A valid meeting point can be anywhere but not at anyone home.For find minimum distance a formula is created, this is named as manhattan distance, where distance −(p1, p2) = |p2.x| + |p2.y - p1.y|.Let’s take an example, to make the concept ... Read More

Best First Search (Informed Search)

sudhir sharma
Updated on 22-Nov-2019 07:29:28

7K+ Views

Best first search is a traversal technique that decides which node is to be visited next by checking which node is the most promising one and then check it. For this it uses an evaluation function to decide the traversal.This best first search technique of tree traversal comes under the category of heuristic search or informed search technique.The cost of nodes is stored in a priority queue. This makes implementation of best-first search is same as that of breadth First search. We will use the priorityqueue just like we use a queue for BFS.Algorithm for implementing Best First SearchStep 1 ... Read More

Benefits of Using Modern Learning Apps

sudhir sharma
Updated on 22-Nov-2019 07:27:48

337 Views

Advancements in technology have lead to a newer and more efficient way of learning. The usage of these modern learning techniques are gaining popularity. Modern learning methods used by teachers in e-learning are educational websites, educational applications, learning games, ebooks and virtual teaching courses.Using these modern learning methods, students can learn interactively and at their own pace. These learning apps and videos are used to transform teaching experience. It is more eco friendly technical and is more interactive as compared to traditional once which used chalk-board and pen-paper.Applications that are downloadable create an interactive environment for students to learn with ... Read More

Bell Numbers - Number of ways to Partition a Set in C++

sudhir sharma
Updated on 22-Nov-2019 07:24:12

970 Views

A bell number is used to denote the number of ways a set of n elements can be partitioned into subsets that are not empty (i.e. have at least one element).In this program, we are given a set of n elements and we have to find the number of ways to partition the set into non-empty subsets.ExampleInput : 3 Output : 5Explanation − let the set of three elements {1, 2, 3}.The subsets are {{1} , {2} , {3}} ; {{1} , {2, 3}} ; {{1 , 2} , {3}} ; {{2} , {1 , 3}} ; {1 , 2 , 3}.Bell ... Read More

Basic Graphic Programming in C++

sudhir sharma
Updated on 22-Nov-2019 07:06:43

21K+ Views

C++ programming language is a versatile programming language. Using C++ you can create low end graphics too i.e. creating basic shapes and words with stylish fonts and adding colors to them can be done using c++.Graphic programming can be done in c++ using your terminal or command prompt or you can download DevC++ compiler to create graphic programs.For terminal you need to add the graphics.h libraray to you GCC compiler. For this you will have type in the following commands.>sudo apt-get install build-essential >sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev guile-2.0 \ guile-2.0-dev libsdl1.2debian libart-2.0-dev libaudiofile-dev \ libesd0-dev libdirectfb-dev libdirectfb-extra libfreetype6-dev \ ... Read More

C++ program to find the Radius of the incircle of the triangle

Ayush Gupta
Updated on 21-Nov-2019 12:57:23

287 Views

In this tutorial, we will be discussing a program to find the radius of the incircle of a given triangle.For this, we will be provided with the sides of a particular triangle and our task is to find the radius of the incircle in that triangle.The formula for finding the radius of incircle isarea of the triangle/half perimeter of the triangleExample#include using namespace std; //calculating the radius of incircle float calc_radius(float a, float b, float c) {    if (a < 0 || b < 0 || c < 0)       return -1;    //half perimeter of ... Read More

C++ program to find the quantity after mixture replacement

Ayush Gupta
Updated on 21-Nov-2019 12:54:02

117 Views

In this tutorial, we will be discussing a program to find the quantity of milk left after mixture replacement.Let us suppose we have X litres of milk. From that, Y litres of milk is replaced with Y litres of water itself. This same procedure is done again and again Z number of times. Our task is to find the final amount of milk left in the container.Finding the relation among the values between the repetitive operations, we find the formula for finding the amount of milk after Z number of operations to beamount left = ((X-Y)/X)Z*XExample#include using namespace std; ... Read More

C Program for Hexagonal Pattern

Sunidhi Bansal
Updated on 21-Nov-2019 12:28:19

2K+ Views

We are given with an integer ‘n’ and the task is to generate the hexagonal pattern and display the final output.ExampleInput-: n=5 Output-:Input-: n = 4 Output-:Approach we are using in the given program is as follows −Input the number ‘n’ from userDivide the entire pattern into three parts i.e. upper part, middle part and lower part Start loop i for printing the upper part of the pattern from i to 0 and i to be less than n and keep incrementing the value of i Start loop m for printing the middle part of the pattern from m to ... Read More

Why you should learn Microsoft Office Suite at a professional level?

Swetha Prasanna
Updated on 21-Nov-2019 09:40:10

423 Views

Microsoft Office is a tool that most computer users across the globe use as a part of their daily lives with professionally or personally. The tool is so intertwined in the activities that we use at all levels of requirements – just from simply typing in a word document to using excel sheets at a complex level.When it comes to a professional level of learning, students and professionals look at acquiring deeper knowledge in software and technologies but tend to not realize the importance of MS Suite that is indispensable at every aspect of work. With decade-plus years of experience ... Read More

How to remove non-ASCII characters from strings

Maruthi Krishna
Updated on 21-Nov-2019 08:10:22

1K+ Views

The Posix character class \p{ASCII} matches the ASCII characters and the meta character ^ acts as negation.i.e. The following expression matches all the non-ASCII characters."[^\p{ASCII}]"The replaceAll() method of the String class accepts a regular expression and a replacement-string and, replaces the characters of the current string (matching the given pattern) with the specified replacement-string.Therefore, You can remove the matched characters by replacing them with the empty string “, using the replaceAll() method.Example 1import java.util.Scanner; public class Exp {    public static void main( String args[] ) {       Scanner sc = new Scanner(System.in);       String regex = ... Read More

Advertisements