Questions tagged [non-recursive]

non-recursive programming avoids risks of recursion by using iteration instead.

In several programming languages, recursion can lead to out-of-memory problems, using non-recursive approaches can avoid this risk.

120 questions
0
votes
1 answer

Non recursive ray_color function from Raytracing in One Weekend in GLSL using compute shaders

I am trying to write a real time ray tracer using compute shaders in opengl 4.3. I know that this is a rather popular question. I have checked this, and this, but the architecture provided over there does not really correspond to my use case. I am…
Kaan E.
  • 515
  • 4
  • 16
0
votes
2 answers

nonrecursive inorder traversal of a (ordinary) tree

Usually in-order is defined for binary trees. Let's say that in-order is "extended" for (ordinary) trees. If tree is single node then that node is the in order traversal of the tree. If tree T is tree with T1, T2, ..., Tk sub trees and r as a root,…
user10999031
0
votes
1 answer

Non-recursive Depth-First search:

In this post biziclop inserted the pseudocode for the non-recursive Depth-First Search algorithm. If we want to use the recursive DFS algorithm is used to check the nodes for a propriety, we can exploit two variants: pre-order (when a node is…
Asghabard
  • 191
  • 13
0
votes
1 answer

Binary Search Tree. Insert method inserting incorrectly

I have an issue where my items in my binary tree are being inserted incorrectly. I'm inserting strings in each node. I think I might be doing something wrong because it seems like I always end up with the wrong tree. i.e. A, B, C I should have …
user445338
0
votes
0 answers

How can I implement DFS on a DAG with revisits, return values and without recursion?

I would like to implement a DFS algorithm on a DAG that collects information from the children and passes it on to the parents. It is allowed to revisit a node multiple times when it is connected to the root node via different paths. In my case,…
Lenar Hoyt
  • 5,971
  • 6
  • 49
  • 59
0
votes
0 answers

Non-recursive Alpha beta pruning implementation

I'm trying to convert the recursive version of Alpha beta pruning to non-recursive one because I have to implement it on CUDA. Here is the recursive version int Bot::minimaxAlphaBeta(Board & board, int depth, bool isMax, int alpha, int beta, int x ,…
Duke
  • 253
  • 1
  • 13
0
votes
2 answers

Traverse nested list and assign an interdependent value to each element w/o recursion (Python)

I want to dissolve the recursion of the following function because some input data lead to an exceeding recursion depth error. Increasing the recursion depth is not a solution in the long-run. def foo(x): for element in x.elements: …
fotinsky
  • 972
  • 2
  • 10
  • 25
0
votes
2 answers

Non-recursive flood filler method

I am making non-recursive flood fill method in Java which uses coordinates of clicked pixel (x,y) and color code as input. img is buffered image. Code works, but only for large simple shapes (like squares), and sometimes does not fill even…
0
votes
1 answer

Non Recursive Make

I have a project that I would like to convert from recursive to non recursive make. The structure looks like the following +--app | +-- Makefile +--lib1 | +-- Makefile | +-- x.c | +-- y.c | +--lib2 | +-- Makefile | +-- x.c What I am trying…
0
votes
1 answer

Non-recursive O(N) space merge sort

I am coding the non-recursive merge sort algorithm in Java I have to make sure if this method works as a non recursive as well as the space complexity should be O(N) Instruction I got: You can use O(N) space (in addition to the input array) and your…
0
votes
2 answers

Construct a no recursive insert method for binary tree

I have completed the recursive insert function and it works perfectly, but I can not get the non recursive solution to work. public void insert(T item){ root= nonRecursive(root,item); } public BinaryTreeNode nonRecursive(BinaryTreeNode tree, T…
mdavies23
  • 67
  • 8
0
votes
1 answer

WinSCP .NET assembly - GetFiles root directory non-recursive (without subdirs)

I'm trying to download files from a directory, without the other directories in the wanted directory. I've searched over the Internet for an answer, and the only thing I found is to use FileMask "|*/" in TransferOptions, which isn't working, and…
user5441417
  • 101
  • 3
  • 9
0
votes
2 answers

Making zip archive relative to given path in non-recursive makefile

I'm using an implementation of non-recursive make similar to the one covered here: http://evbergen.home.xs4all.nl/nonrecursive-make.html Here's an example of the problem. The main Makefile includes foo/Rules.mk. foo/Rules.mk contains the snippet: #…
darkfeline
  • 9,404
  • 5
  • 31
  • 32
0
votes
0 answers

KnapSack algorithm in Java without recursion and without value

I have seen many solutions which solves the Knapsack problem in java using recursion; I'm trying to convert the solution into non-recursive function which probably uses "Stack" or any other optimal solution. I also don't have a value array and I…
Sagar Jani
  • 257
  • 1
  • 10
0
votes
0 answers

zip a directory non recursive php

I have no idea if this is possible since there is no information available on the internet. I spend two hours searching without any result. I am trying to zip a directory without knowing the file names that are in the directory. I tried many…
Quartermain
  • 163
  • 3
  • 17