Me and my friends have coded this program that asks a user for a directed graph where the edges have weight. The program uses Dijkstra’s algorithm if all the edges are positive valued, if they are negative however, we are required to use Bellman-Ford’s algorithm, we are stumped at the fact that the program perfectly ..

#### Category : algorithm

There are N people standing in a line where the person i is at the ith position initially. A sequence of moves s given by K pairs of positions ai and bi is given. At each minute i=1…i=K the persons at the position i and j are swapped. The same K moves happen after K ..

I implemented queue and made a custom data type "coordinates" (I want to store x and y as a pair but I dont want to use pair provided is STL (for learning purposes)) But in the queue.front() implementation I am getting the error CODE: #include<iostream> using namespace std; template <class T> class node{ public: T ..

Well, this question requires finding a minimum time approach. I first tell the question then my approach. The problem statement is as follows: There are N stations and M trains each station is numbered 1,2,3..N, the employee is currently at station 1 and his office is at Nth station and employee has to reach to ..

I want the code for the algorithm preferably in C/C++. Input – General tree and process (convert) to binary tree. Output – Leaf nodes of both the trees. Source: Windows Que..

I am writing my proprietary class that will store values of a matrix in row-wise order. So the whole data will be stored in a T* data = new[numRows * numCols]; Here is the code for the iterator I planned to use. Let me know if you have suggestions how I would need to change ..

I’m trying to work on a problem statement that states: Given an array of integers and a range of indices l and r, find the index that stores the minimum element in that range. In case of multiple minimum values, return the one corresponding to the leftmost index. This is a standard RMQ problem, that ..

Obviously, there may be similar or even identical problems to this one, but I couldn’t find one because I don’t know what to type in Google. So please help me to name this problem correctly so other people with the same issue won’t have a hard time finding a solution. So we have this (both ..

I am trying to write implementation of LZ77 in C++ I write encoder part and test on easy examples, and everything looks fine. The problem is when I compress bigger files and want to save my result, output files are bigger then before whole procces, also it contains Chinese characters. It would be nice to ..

Basically I’m given a vector of numbers and a target number where the goal is to find the numbers in the array that add up to the number closest to n, that is less than n and I should be able to use the same number in the vector multiple times. For example: {4, 3}, ..

## Recent Comments