Bin Packing Problem (Minimize number of used Bins) in C++?

Arnab Chakraborty
Published on 29-Jan-2020 11:08:42
In case of given m elements of different weights and bins each of capacity C, assign each element to a bin so that number of total implemented bins is minimized. Assumption should be that all elements have weights less than bin capacity.ApplicationsPlacing data on multiple disks.Loading of containers like trucks.Packing ... Read More

Barabasi Albert Graph (for Scale Free Models) in C/C++?

Arnab Chakraborty
Published on 29-Jan-2020 11:00:00
The Barabási-Albert model is treated as one of several proposed models that produce scale-free networks. It combines two important general concepts: growth and preferential attachment. Both concepts i.e. growth and preferential attachment have wide existence in real networks. The meaning of growth is that the number of nodes in the ... Read More

Balanced expressions such that given positions have opening brackets in C++?

Arnab Chakraborty
Published on 29-Jan-2020 10:55:18
In case of a given integer m and an array of positions ‘position[]’ (1 <= length(position[]) <= 2m), find the number of ways of proper bracket expressions that can be constructed of length 2m such that given positions have the opening bracket.Note: position[] array is provided in the form of ... Read More

Autorun a Python script on windows startup?

Arnab Chakraborty
Published on 29-Jan-2020 10:43:54
Appending a Python script to windows start-up basically indicates the python script will run as the windows boots up. This can be accomplished by two step processes -Step #1: Appending or Adding script to windows Startup folderAfter booting up of the windows, it executes (equivalent to double-clicking) all the application ... Read More

Arrange consonants and vowels nodes in a linked list in C++?

Arnab Chakraborty
Published on 29-Jan-2020 10:37:05
In this technique, we transfer the nodes having vowels as keys to the beginning and consonants to the end. In this case we also maintain the order. Example is given below −Input: A-M-A-Z-O-N Output: A-A-O-M-Z-N Code (Complexity: O(N), Space O(1))Example Live Demo#include<iostream> using namespace std; class Node1{    public:    char ... Read More

Arrange a binary string to get maximum value within a range of indices C/C++?

Arnab Chakraborty
Published on 29-Jan-2020 08:14:40
In case of a given string consisting of only 0’s and 1’s, we are given M non-intersecting ranges A, B( A <= B), more specifically [A1, B1], [A2, B2], …, [AM, BM], Any two of these intervals does not overlap — formally, in case of each valid i, j such ... Read More

Are array members deeply copied in C++?

Arnab Chakraborty
Published on 29-Jan-2020 08:12:50
In case of C/C++, we can be able to assign a struct (or class in C++ only) variable to another variable of same type. At the time when we assign a struct variable to another, all members of the variable are copied to the other struct variable. In this case ... Read More

Angle between a chord and a tangent when angle in the alternate segment is given in C++?

Arnab Chakraborty
Published on 29-Jan-2020 08:06:13
In case of a given circle, chord and tangent is met at a particular point. The angle in the alternate segment is provided. The main job here is to find the angle between the chord and the tangent.ExamplesInput: z = 40 Output: 40 degrees Input: z = 60 Output: 60 ... Read More

An in-place algorithm for String Transformation in C++

Arnab Chakraborty
Published on 29-Jan-2020 07:57:41
For a given string, transfer all even positioned elements to end of string. While transferring elements, keep the relative order of all even positioned and odd positioned elements same.For example, if the given string is "a1b2c3d4e5f6g7h8i9j1k2l3m4”, transform it to “abcdefghijklm1234567891234” in-place and in O(n) time complexity.Following are the stepsCut out ... Read More

An application on Bertrandís ballot theorem in C/C++

Arnab Chakraborty
Published on 29-Jan-2020 07:51:43
In Bertrand's original paper, he explains a proof depended on a general formula for the number of favourable sequences implementing a recursion relation.ExampleLet there are 5 voters, of whom 3 vote for candidate A and 2 vote for candidate B (so p = 3 and q = 2). Ten possibilities ... Read More
Advertisements