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
5
votes
7 answers

Non-Recursive DFS Implementation

Recently I needed to implement non-recursive DFS as part of a more complicated algorithm, Tarjan's algorithm to be precise. The recursive implementation is very elegant, but not suitable for large graphs. When I implemented the iterative version, I…
Nir Friedman
  • 17,108
  • 2
  • 44
  • 72
4
votes
3 answers

a non recursive approach to the problem of generating combinations at fault

I wanted a non recursive approach to the problem of generating combination of certain set of characters or numbers. So, given a subset k of numbers n, generate all the possible combination n!/k!(n-k)! The recursive method would give a combination,…
Mark
  • 195
  • 2
  • 11
4
votes
2 answers

How to get submodule's poms to NOT inherit a plugin in the parent?

My project has a parent pom and several submodule poms. I've put a plugin in the parent that is responsible for building our installer distributables (using install4j). It doesn't make sense to have this plugin run on the submodules, so I've put…
UrLicht
  • 939
  • 1
  • 14
  • 25
4
votes
1 answer

Do you know any build tool that manges the build using non-recursive make approach?

I have been searching stackoverflow, but I failed to find a satisfiable answer to my question. Miller's paper Recursive Make Considered Harmful is well known in the community. Basically, I have been using the non-recursive make to manage the builds…
ozox
  • 472
  • 2
  • 11
3
votes
2 answers

AVL Tree Non-Recursive

I'm learning AVL Tree and got TLE in recursive code. My tutor suggests to iterative solution. I searched and found a solution which saves parent node in child. I wonder this one could get problem in memory, doesn't it? And is there another way to…
Hâm Zon
  • 105
  • 1
  • 2
  • 8
3
votes
1 answer

Simple Non-recursive Makefile with object files in separate directory

I have searched and tried a few examples to get a simple project done using non-recursive makefiles. In the past, I had used simple single directory codebase but now I am putting together an environment for more than one engineer :-) +--app | +--…
guraaf
  • 163
  • 4
  • 12
3
votes
4 answers

Retrieving a Binary-Tree node's depth non-recursively

Can anyone point out a way of getting the depth of a Node in a Binary Tree (not a balanced one, or BST) without using recursion? Ideally in Java/C/C# The node is represented as: class Node { Node Left; Node Right; string Value; int…
Chris S
  • 64,770
  • 52
  • 221
  • 239
2
votes
1 answer

convert object structure of n child tree to nested list in python

I made two classes as follow: Node class class Node: def __init__(self,title): self.title = time self.child = [] And implement methods like getTitle, getChild, addChild, isEmpty: if child = [] and more Tree class class…
Jay
  • 37
  • 1
  • 8
2
votes
2 answers

How merge sort works at arrays of length N?

I've hit the books and was faced with problem i can't solve. I have been looking the information up a long. I broke my mind trying to understand it. So, I'm given an array of length N (int) to sort it by using non-recursive merge sort algorithm. I…
aristari
  • 25
  • 1
  • 5
2
votes
3 answers

Towers of Hanoi non-recursive function

I'm trying to figure out how to implement a non-recursive algorithm for the Hanoi Towers problem in function hanoi_2 below, but I have no idea how to continue... It throws an error: "can't pop from empty list". It works somehow when I input an odd…
2
votes
2 answers

How to make this search function non-recursive?

I am trying to turn this recursive function into a non-recursive one.This is a search function from a binary search tree. I am aware it is natural to make it recursive, but for learning purposes I would like to make it non-recursive. How could I do…
2
votes
0 answers

Iterative Quicksort steps?

I have to implement an iterative quicksort in java for homework. i've search a lot about it but i couldn't find a website with a clear explanation about how to implement an iterative quicksort. i have found this code in java, and it sorts very well,…
2
votes
1 answer

Non-recursive DFS vs BFS, only differ in stack vs queue?

I am looking at the non-recursive DFS and BFS of a general graph. Besides the fact that the former uses a stack instead of a queue, the only difference is that it "delays checking whether a vertex has been discovered until the vertex is popped from…
sinoTrinity
  • 1,125
  • 2
  • 15
  • 27
2
votes
1 answer

Binary search tree - Iterative check for height

So, I'm having a bit of problem. I know how to traverse tree, using recursion or not, using stack or not. But, I also want to track height of every leaf, and if height(or depth) is less than given argument to print that leaf. Here is my code using…
2
votes
1 answer

Implementation of Tower Of Hanoi - iterative procedure

I have been working last night on implementing Tower of Hanoi without using recursion. I have found an algorithm on Wikipedia about the same topic on the wiki page wiki for TOH. I have implemented it, it's working fine (for odd numbers :for now).…
cracknut
  • 61
  • 1
  • 5