There is a wave tracking algorithm which recursively checks each pixel at the wavefront. It tracks if a wave has grown into a pixel each timestep. It works great, but it trashes the stack if the images gets to big. 8MB works fine for 256×256, 64MB works good for 512×512 pixels, but bigger images are ..

#### Category : recursion

There is a wave tracking algorithm which recursively checks each pixel at the wavefront. It tracks if a wave has grown into a pixel each timestep. It works great, but it trashes the stack if the images gets to big. 8MB works fine for 256×256, 64MB works good for 512×512 pixels, but bigger images are ..

I am trying this code for solving 0/1 knapsack problem using Brute-force recursive solution, but it keeps running with no output at all when I make the size of the problem(profit and weight arrays) 100. if any one can tell me why? and how to solve it. Please if any one can tell me when ..

I wrote a recursive solution for the longest increasing subsequence and it worked perfectly fine. But when I applied dp on the same code it gives different answers. Problem Link: https://practice.geeksforgeeks.org/problems/longest-increasing-subsequence-1587115620/1 Recursive code: int LIS(int arr[], int n, int currIndex, int maxVal) { if (currIndex == n) { return 0; } int included = 0, ..

I just solved the subset sum problem: Given an integer array nums of size N. You are also given an integer B, you need to find whether there exists a subset in nums whose sum is B. If there exist a subset then return 1 else return 0. Constraints are: 1 <= N <= 100; ..

I am trying to figure out my last assignment for my C++ course. While I thought I had it in the bag, I am running into some issues. All I am trying to do is have a user input a sentence, and using the function str_length(char s[]), I figure out how many characters are in ..

I’m having trouble using Boost Serialization library with a recursive data structure. More precisely, I want to serialize a matrix which is represented by nodes containing a value, and where each node has access to its neighboors (top,bottom,left,right). In order to access a node, each entry point is stored in a vector (that is the ..

int hieght(BinaryTreeNode<int> *root) { if(root==NULL) { return 0; } int smallOutput1 = hieght(root->left); int smallOutput2 = hieght(root->right); if(smallOutput1>smallOutput2) { return smallOutput1+1; } else { return smallOutput2+1; } } int Diameter(BinaryTreeNode<int> *root) { if(root==NULL) { return 0; } int option1 = hieght(root->left) + hieght(root->right); int option2 = Diameter(root->left); int option3 = Diameter(root->right); return max(option1,max(option2,option3)); } According ..

I am trying to make a magic 8 ball that provides a random preset answer to any input except "bye". Each time the void function magic8ball() is called, it generates a random number from 0 – 19 and prints a corresponding response to the console. int main() { string question; cin >> question; while (question ..

I wrote one backtracking algorithm which resulted in TLE which was obvious. But I wanted to do the time complexity analysis for it. I thought that we will make 2N calls then 2N-1 calls then 2N-2 calls and so on. Total we make (2N)! calls and in each call we use a for loop on ..

## Recent Comments