250 Topics

Member Avatar for
Member Avatar for flyingcurry

The below is the main method, the wrapper method, and the array search method for a step recursive method used for finding the index position of the searched string. I am encoutering this problem when whatever search I put in, I get the return value of -1. Why and how …

Member Avatar for flyingcurry
0
164
Member Avatar for patto78

The following is a recursive function designed to return the factorial of a number. [CODE] def factorial(number, target): if number == 1: return target else: target = target*number factorial((number-1), target) print factorial(7, 1) [/CODE] As you'll see if you run it however it doesn't return my 'target' variable (the factorial …

Member Avatar for patto78
0
187
Member Avatar for insanely_sane

Ok... So I have the following program: [CODE]public int seq2 (int n) { if (n <= 0) return 1; else return seq2 (n - 1) + 2 * n - 1; }[/CODE] It gives the following output: 1 2 5 10 17 26 37 50 65 82 So that means …

Member Avatar for insanely_sane
0
184
Member Avatar for sid78669

I recently had an assignment for an advanced coding class where I was to create a Binary tree from inorder and preorder traversals. I first started out by creating my ADT for binary trees and working with that to create a new tree. The way I worked it was that …

Member Avatar for arkoenig
0
154
Member Avatar for insanely_sane

Yeah... I have a headache... So I have the following code: [CODE]public class inc { public static void main (String args[]) { new inc(); } public inc() { System.out.println (addTwo(7)); } public int addTwo(int n) { System.out.println (n); if (n < 1) { return 2; } else { return addTwo(n-1)+2; …

Member Avatar for insanely_sane
0
142
Member Avatar for knan

I have a set of text files in a folder. I want to read each file, convert the contents of the file to lowercase, remove punctuations and save them all in another directory with the same filenames. How can i do that???

Member Avatar for griswolf
0
318
Member Avatar for flyingcurry

The code for the Towers of Hanoi is here, the problem is what will the rest of the recursive calls be? [CODE] //provided in the main method that String Src="Src", Aux="Aux", Dst="Dst"; public static void solve (int diskNumber, String Src, String Aux, String Dst) { if (diskNumber ==0) return; else …

Member Avatar for flyingcurry
0
131
Member Avatar for peterman.k

I am going out of town and don't have access to my professor and / or tutors for the weekend, and we have an assignment involving a BST. I have done all of my insert, remove, and search functions, and went to the tutor about the remaining ones I have, …

Member Avatar for peterman.k
0
227
Member Avatar for flyingcurry

The program is supposed to find all the combinations of the letters in "computer", the algorithm was given to me, but I don't have any idea of how it dos its work, all I get from this is a an infinite amount of "nullp" Here is the code: [CODE] public …

0
89
Member Avatar for Yutxz

I received the error "possible loss of precision" on the last line of my code. Is it not possible to return a double? My instructions were to create a program, called power, that took a double (x) and raised it to an integer (n) power. [CODE] package power; /** * …

Member Avatar for Yutxz
0
194
Member Avatar for flyingcurry

The task is to use a recursive algorithm to determine the sum of two numbers n1 and n2. I just keep on returning to using the formula n1*n1 +n2*n2 The part which I have questions is I don't get how to do this in a recursive way. Thanks!

Member Avatar for flyingcurry
0
2K
Member Avatar for ChPravin

Hello, I know this question might sound stupid! I am using recursion inside a loop. I want to stop the loop as soon as the method is called recursively and resume it again when the call returns. I am not able to do so. Do I need to lock the …

Member Avatar for jon.kiparsky
0
1K
Member Avatar for raj26061990

The two numbers are accepted as Commamnd line arguements and GCD of those numbers are found using a recursive method.

Member Avatar for raj26061990
0
2K
Member Avatar for virtualvinodh

Hi, I wrote a piece of code for doing a recursive printing of all the leaf nodes. But it is not moving beyond one or two levels. Here is the code: [code=php] $root = array( "paa" => array ( "adi1" => array ( "cir1" => array ( "aka", "ra", "vinodh","dkido" …

Member Avatar for virtualvinodh
0
240
Member Avatar for ryuurei

I had been working on this program for a while. It was inspired by the slowness of Windows' search feature. I made it so I could simply look for files to see if/where they existed quickly. I eventually added in the feature to delete files. It was no major extension …

Member Avatar for tls-005
3
448
Member Avatar for xxpokerxx

Hi, I am trying to implement a binary tree(not sorted) using recursion. I have figured out most of my function however GetMax and GetMin are confusing me. [CODE]#include <stdio.h> #include <stdlib.h> #include <limits.h> typedef int TreeEntry; typedef struct binary_tree_node { TreeEntry item; struct binary_tree_node * left; struct binary_tree_node * right; …

Member Avatar for xxpokerxx
0
264
Member Avatar for TrustyTony

Here is my practise with [URL="http://www.boggled.org/"]boggle [/URL]letter square non-overlapping word finder after some drastic debugging and cleaning. I think it is reasonable speed also. Comments wellcome.

Member Avatar for TrustyTony
0
1K
Member Avatar for kymarscheng

I have made a program to test if the string entered is a palindrome or not. Here's the source code: [code=c]#include <stdio.h> #include <ctype.h> #include <string.h> void clrsp(char *); void rev(const char *,char *); int main() { char str1[80],str2[80]; printf("Enter a string: "); fgets(str1,80,stdin); str1[strlen(str1)-1]='\0'; //eliminate newline clrsp(str1); //clear spaces …

Member Avatar for urjapandya
0
148
Member Avatar for Dragazarth

Okay I was just mucking around on python. I have no programming experience at all, and I havent yet finished school anyhow, but I was interested in python and many say that it is great and everything... So I was trying to make a code that would solve this problem …

Member Avatar for Dragazarth
0
161
Member Avatar for garea

I have a problem with recursive imports in C++. I have this 2 classes: [CODE] //File A.h #include "B.h" class A{ public: A(){}; void doA(B b){ b.doB(); } } [/CODE] [CODE] //File B.h #include "A.h" class B{ public: B(){}; void doB(A a){ a.doA(); } } [/CODE] I tried to use …

Member Avatar for rodc
0
805
Member Avatar for tucanoj

I've been playing around with recursion a little bit, admittedly it's been some time since I've used it, and I'm feeling pretty rusty. I was simply trying to recursively reverse a linked list and wasn't getting anywhere and finally google'd some code and came across the below snippet, [code=c] node …

Member Avatar for tucanoj
0
125
Member Avatar for codewalkz

I currently have this function [CODE] processfn('sponsor = 1', 1, '', 0, 'buyer = 0'); function processfn($sponsor, $level, $sad, $sadista, $bumili) { $result = mysql_query("SELECT id FROM ahentes WHERE $sponsor") or die(mysql_error()); if (mysql_num_rows($result) > 0) { $sad = mysql_num_rows($result); while ($row = mysql_fetch_array($result)){ $sila[] = "buyer = '".$row['id']."' "; …

Member Avatar for codewalkz
0
79
Member Avatar for codewalkz

It's like a tree pyramid. I want to get the members sponsored by the current user. The result will be used to get its sponsored members and so on until everyone is read. How can I achieve this? I currently have this code but I can only go to level …

Member Avatar for cwarn23
0
118
Member Avatar for codewalkz

I am currently making a binary tree and I was able to create the tree. What I am facing now is " How to get the total number of children in my left side and total number in my right side ". The structure is: [CODE] 1 2 3 4 …

Member Avatar for codewalkz
0
1K
Member Avatar for arthurav

Given the degree of the polynomial and a vector with the polynomial's coefficients is there a more efficient way to recursively calculate the polynomial result for a given x? This is what i have tried, and it works, but I am asking if there is a more efficient way to …

Member Avatar for arthurav
0
3K
Member Avatar for Alexpap

Hi all, I was always a bit confused about how to create a recursive function, so thats where i need you help. :) I have a treeview, in wich the user adds/removes dynamicaly nodes and a button wich should save the treeview structure in a database table when clicked. The …

Member Avatar for gusano79
0
150
Member Avatar for nickguletskii

I am trying to do a very large recursive operation, but it just hangs up. IS there any way of pausing t for some time, then make it continue? Thanks in advance.

Member Avatar for nickguletskii
0
89
Member Avatar for jpl1993

i'm pretty clueless about everything dealing with python. i need help creating a sorting algorithm that can sort names in a list alphabetically. and example code to help get me started would be much appreciated.

Member Avatar for lllllIllIlllI
0
136
Member Avatar for jpl1993

so i have a project due in my computer programming class and i need some serious help. we are learning about recursive sorting, such as merge sort, selection sort, etc. my project has to do with taking 10 people and sorting them in order by their names (alpabetically), rank (numerically), …

Member Avatar for griswolf
0
119
Member Avatar for codewalkz

Hi, I need something like recursion wherein the query repeats itself using it's result to start the NEXT - SAME - QUERY. I made 1 but it just simple reecho the same result. [CODE]// KUNIN ANG ID NI KURIMAW $root = $_GET['id']; $result = mysql_query("SELECT COUNT(*) as count, id, sponsor …

Member Avatar for codewalkz
0
145

The End.