non-recursive

Non-recursive Fibonacci Sequence in Assembly

梦想与她 提交于 2021-02-11 15:45:04
问题 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. INCLUDE Irvine32.inc .data prev DWORD ? next DWORD ? val DWORD ? count DWORD ? total DWORD ? myMsg BYTE "Fibonacci Sequence ",0dh,0ah,0 .code main PROC mov ecx,15 mov val,1 mov prev,-1 mov eax,1 mov edx,OFFSET myMsg call WriteString L1: mov count,ecx

Towers of Hanoi non-recursive function

跟風遠走 提交于 2021-01-04 07:14:43
问题 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 number, however, when the third turn passes things go wrong. When an even number is input as the number of discs the program doesn't even start. What is wrong? from turtle import * from tkinter import * # used for the dialog box from tkinter

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

耗尽温柔 提交于 2020-01-23 17:38:24
问题 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 direct me to the non recursive version (using while loop)? Also write if this version is more efficient in terms of time complexity? 回答1: Just happened to see this long forgotten question. Do you mean something like, if you are given a tree: A B C D E

LL(1) table-driven compilers with ANTLR or ANTLR3

梦想的初衷 提交于 2020-01-15 10:59:14
问题 Is it possible to create a LL(1) table-driven (non-recursive) compiler with ANTLR or ANTLR3 ? 回答1: No. However since ANTLR is open source you could modify a fork of ANTLR to do it. ANTLR builds lexers and parsers as recursive descent source code. This is why ANTLR is easy to use and popular because people can look at the source code and understand how the lexer and parser work versus looking at table entries. Because it is source code, one can also use tools to debug the source code. If ANTLR

Non-recursive implementation of Flood Fill algorithm?

ε祈祈猫儿з 提交于 2019-12-29 06:53:31
问题 I'm working on a small drawing application in Java. I'm trying to create a 'bucket-fill' tool by implementing the Flood Fill algorithm. I tried using a recursion implementation, but it was problematic. Anyway, I searched around the web and it seems that for this purpose, a non-recursive implementation of this algorithm is recommended. So I ask you: Could you describe a non-recursive implementation of the Flood Fill algorithm ? An actual code example, some pseudo-code, or even a general

How to implement depth first search for graph with non-recursive aprroach

匆匆过客 提交于 2019-12-27 19:10:53
问题 Well, I have spent lots of time on this issue. However, I only can find solutions with non-recursive methods for a tree: Non recursive for tree, or recursive method for the graph, Recursive for graph. And lots of tutorials(I don't provide those links here) don't provide the approaches as well. Or the tutorial is totally incorrect. Please help me. Updated: It's really hard to describe: If I have a undirected graph: 1 / | \ 4 | 2 3 / 1-- 2-- 3 --1 is a cycle. At the step: push the neighbors of

How can I get number of leaf nodes in binary tree non-recursively?

此生再无相见时 提交于 2019-12-24 20:21:22
问题 I have a practice question that I'm stumped on - to get the number of leaf nodes in a binary tree without using recursion. I've had a bit of a look around for ideas, I've seen some such as passing the nodes to a stack, but I don't see how to do it when there's multiple branches. Can anyone provide a pointer? 回答1: NumberOfLeafNodes(root); int NumberOfLeafNodes(NODE *p) { NODE *nodestack[50]; int top=-1; int count=0; if(p==NULL) return 0; nodestack[++top]=p; while(top!=-1) { p=nodestack[top--];

Non-recursive add function in a binary tree using c++

血红的双手。 提交于 2019-12-23 02:29:24
问题 I am writing an Add function to add nodes to a binary tree non recursively. I have run into the problem of only being able to produce one level deep binary tree. I debugged it and I know where the problem is but can't figure out how to fix it. Maybe fresh pair of eyes will see something i dont... The problem is that my temp node is being reset to the root value every new function call and hence, adding nodes linearly. Anyways, here is the function: void BinaryTreeNonRec::add(int num){