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
1
vote
1 answer

Define a recursively expanded variable using a variable whose name is computed from a simply expanded variable

I've run into a difficulty in defining generic rules for a non-recursive make system. Background For further reading, rather than me reproducing too much existing material, see this earlier question, which covers the ground pretty well, and…
1
vote
0 answers

Non-recursive Depth First Search using Matlab Function Block in Simulink for tree

this is my first post on Stack Overflow. I really admire the site and all the users who help the others code a lot. Hopfully I can get some help from you:) The problem I have met can be described as follows: Start from a given node(root…
1
vote
0 answers

Need help fixing binary search tree add and in order methods

I'm working on an assignment where I have to implement these two methods( add() and inOrder() ). The code below is what I have so far. What I need help with is adjusting the code to work. Currently, it does not do what I want it to. add() will only…
william h
  • 47
  • 5
1
vote
2 answers

exception in merge for non-iterative mergesort algorithm

I'm trying to create a non-recursive version of MergeSort but for some reason merge is keeping the code from running in its entirety. Mergesort Code: public void mergeSort(int[] input) { int n = input.length; int size; int l; for…
Maria-Andersado
  • 777
  • 1
  • 9
  • 18
1
vote
1 answer

Rewrite recursive BNF rule with iteration

Look at the following recursive BNF rule (1) X = Xa | b This produces sentences like X = b X = ba X = baa X = baaa ... This can be written as (2) X = b a* where the right hand side is not recursive Now take a look at the following recursive BNF…
Bob Ueland
  • 1,804
  • 1
  • 15
  • 24
1
vote
0 answers

Implementing a non-recursive (botton-up) MergeSort algorithm

I was given an assignment to implement the following algorithm:   I am a little confused by reading the algorithm itself, I tried to follow the algorithm but, since I cannot understand it completely my code does not work. Can anyone, please, have a…
Georgi Koemdzhiev
  • 11,421
  • 18
  • 62
  • 126
1
vote
1 answer

Least common ancestor search in binary tree non recursive version - Java

I am searching a non recursive algorithm version of finding the least common ancestor in a sorted binary tree written in Java. Everything I found is only the recursive version (even on stackoverflow and on other websites). Can some one write or…
Yuval Levy
  • 2,397
  • 10
  • 44
  • 73
1
vote
1 answer

How to write an *interruptible* recursive(?) descent parser

I have a pretty standard recursive descent parser. The algorithm is straightforward: each function reads characters from a stream and either returns FAIL or calls subsequent parse functions (specified by a corresponding grammar rule): function…
tillda
  • 18,150
  • 16
  • 51
  • 70
1
vote
2 answers

List of Current Folder files ONLY?

Hello I'm trying to get Perforce syntax to obtain (for example using "fstat") list of files only in given folder (depot), without rubbish from all sub-folders. But I was not able to find anything in the docs, nothing related when using Google, even…
LiLol
1
vote
2 answers

Recursive Permutation, Ellis Horowitz Algorithms and data structure Confusion.

I am a beginner programmer in my first year of university. My tutor has asked us to do some research on a recursive algorithm and make it none recursive. No natter how much I try it seems impossible. The question reads A is a character string…
Swapnull
  • 278
  • 1
  • 3
  • 14
1
vote
3 answers

Find number of ways in a maze non recursively

Given a matrix[n,n] I want to find out how many ways we can reach from [0,0] to [n,n] non recursively. My approach is to Create a stuct Node to store row, col and path travelled so far Add node to a Queue Iterate thru queue till not empty .…
SheldonCooper
  • 93
  • 1
  • 11
1
vote
3 answers

Binary Tree : Non recursive routine to print ancestor of a node in a Binary Tree?

I have to write a non recursive program to print the ancestor (parent of parent) of a given node in a Binary Tree. What logic should I use ?
Nikunj Banka
  • 11,117
  • 16
  • 74
  • 112
1
vote
3 answers

java binary tree insert function non recursive

I have written a code for inserting to the binary tree an element generic's type which is ordered by their names. Don't think it is correct though. public boolean insert(E e) { BTNode temp = root; if (root == null) { …
user1417426
  • 27
  • 2
  • 6
0
votes
2 answers

Non-recursive Fibonacci Sequence in Assembly

In some homework, I have to create a Fibonacci Sequence program in Assembly. I created this code, but it doesn't seem to be working correctly and I am not sure as to why. I believe that I am doing this correctly, but EAX remains "2" every loop. …
seiryuu10
  • 843
  • 1
  • 10
  • 14
0
votes
1 answer

non-recursive predictive table-driven LL(1) parser in functional programming

I want to know which is the best way to build a non-recursive predictive table-driven LL(1) parser in functional programming: Hand-coding in Haskell or OCaML or does it exist a tool that can help me with this?
Academia
  • 3,984
  • 6
  • 32
  • 49