OK, so i do have a perfectly good working code but im trying a different way and its bugging me why its not working. any help would be much appreciated. the program suppose to list all the available directories and then ask the user which directory he's searching for, takes the input and search for the directory. if the directory exist it will find it and list all the files in it and the path to it. if it can't find the directory it will throw a message or exception saying so. Now it lists all the directories just fine …

Member Avatar
Member Avatar
+0 forum 3

First question, is there any difference between binary search and recursive binary search??? I looked through google and everything but couldnt find any useful info. I did find irritative and recursive but that was it. and second question: Given a desired search value of 98 and an array with the following sorted integer values: Index: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Value: 1, 12, 28, 35, 49, 62, 73, 86, 98, 120 Indicate the comparisons made in a recursive binary search function, as well as the values for each of the following variables: int low, int …

Member Avatar
Member Avatar
+0 forum 4

This shows the application of a Memoize decorator to speed up recursive functions in Python.

Member Avatar
Member Avatar
+4 forum 4

Hello ! I have a task that is difficult for me to handle. The task is: Create recursive function that can be generate a string of length N (N <= 100), formed by the letters 'A', 'B' and 'C' and does not containing two identical adjacent substring. For example: enter for N = 6 and the program should generate such a string in which no one else to repeated substrings: ABACAB. Wrong strings are: **AA**BACA - because 'A' is to 'A'; A**BCBC**A - as 'BC' is to 'BC' and **ABCABC** is also wrong because 'ABC' is to 'ABC'. I made …

Member Avatar
Member Avatar
+0 forum 2

How do I write a recursive function to compute (3^2)+(3^3)+(3^4).......+(3^n) ?

Member Avatar
Member Avatar
+0 forum 9

How do I write a program to compute run-time of a recursive and non-recursive functions to find the 43rd Fibonacci number?

Member Avatar
Member Avatar
+0 forum 12

So I am trying to remove line feed within an array but not cariage returns. Having trouble using array walk, the ltrim function is not working. I need to remove ONLY the line feed("\n") not the cariage return("\r") so using trim will not work. I tried setting the chr(10) and still not working. Any idea's $array = array( [0] => array(C1TEXT => 0001), [1] => array(C1TEXT => 0002), [2] => array(C1TEXT => \n), [3] => array(C1TEXT => \r), [4] => array(C1TEXT => 0003), [5] => array(C1TEXT => 0004), [6] => array(C1TEXT => 0005), [7] => array(C1TEXT => \n), [8] => …

Member Avatar
Member Avatar
+0 forum 4

Hello, I want help for recursive in php which like structure is attachment file.. [1] **Sire (Parent)** > Sub1 ->nChild.. > Sub2 [2] **Dam (Parent)** > Sub1 ->nChild.. > Sub2 ->nChild.. Do you have some example of code so its better for me. Thank You.

Member Avatar
Member Avatar
+0 forum 6

hi all, this is some extra credit from class we sat around cleaning up code today this is what we came up with public boolean equals2(IntTree t2){ return equals2(this.overallRoot, t2.overallRoot); } private Boolean equals2(IntTreeNode r1, IntTreeNode r2){ if(r1 == null || r2 == null){ return r1 == null && r2 == null; } return ((r1.data==r2.data)&& equals2(r1.left, r2.left) && equals(r1.right, r2.right)); } we get five points extra credit if we can shorten any further. So my question iscan someone explain to me the ^ character and is that the right path to shortening this code

Member Avatar
Member Avatar
+0 forum 7

Im trying to add odd numbers recursively from n to m but its not working . im sure its in the recursive logic on how im passing the arguments or something. public static int OddSum(int low, int up,int total) { if(low==up) { return up; }else { low+=2; return total += OddSum(low,up,total+low); }

Member Avatar
Member Avatar
+0 forum 6

Raffle function to generate unique numbers for each player, related to the same table with a recursive aproach. I had to do a simple raffle system for a contest that I was working on and tried many things and the most simple and the most effective one to generate unique numbers for each player was this, a simple recursive function.

Member Avatar
Member Avatar
+0 forum 3

In most modern languages, there are two fundamental approaches to repeating an action: either *iteration*, in which an action is placed inside a special-purpose structure which causes the action to be repeated, or *recursion*, in which a general-purpose function calls itself (or another function which in turn calls the earlier function). Which is to be used depends on the nature of the problem at hand, and to a great degree, the language being used. Some languages, especially Lisp and the various functional languages, strongly favor recursion; but most other languages, including C++, focus almost entirely on iteration. As a result, …

Member Avatar
Member Avatar
+1 forum 26

Hey everyone, I really need help in solving a problem that I have to use recursion for. I have a list of paper objects. Each paper object has its own author(s) objects. Each author object knows which paper(s) objects they belong to. I have to build a scholarly neighborhood for these authors. The user can select an author and specify the "width" of the neighborhood that they wish to view. The width of this neighborhood goes as follows: If they enter "0" the neighborhood will consist of only the author that they selected. If they enter "1" the neighborhood will …

Member Avatar
Member Avatar
+0 forum 4

Hey guys I had an assignment to recursively write the Towers of Hanoi then test it. I did not have too much of an issue getting the program written But I am not sure what the book means by test the efficiency do they want the number of moves my program makes, or do they want the time it takes to run. And how do I get either one? help is appreciated [CODE] import TerminalIO.KeyboardReader; public class towers { public static void main(String[] args) { KeyboardReader reader = new KeyboardReader(); int numberofRings = reader.readInt("Enter number of Rings: "); move (numberofRings, …

Member Avatar
Member Avatar
+0 forum 10

float det(float A[][10],int m) { float B[10][10],d=0; int i,a,b,x,y; if(m==2) return (A[0][0]*A[1][1])-(A[1][0]*A[0][1]); else { x=0;y=0; for(i=0;i<m;i++) { for(a=0;a<m;a++) { if(a==i) continue; else { for(b=1;b<m;b++) { B[x][x]=A[a][b]; x++; } } } if(i%2) d-=det(B,x); else d+=det(B,x); } } return d; } I tried to run the program, but it exits with error code 255. Using Dev CPP with MinGW. Pls Help!

Member Avatar
Member Avatar
+0 forum 1

Let's use the basic example.. I have a table for tree representation with just 3 columns: ID, PARENT_ID,NAME. If I delete a record X, how can I delete all recursive records that refer as PARENT_ID of deleted record?

Member Avatar
Member Avatar
+0 forum 1

# This is an advanced guess the number game. import random # The very basis of this game. import math # Used for math.ceil import time # Used to split up long portions of text. def errorDisplay(errorCode): if errorCode == '1': print('\n\n\nError ' + errorCode + ': unlockedGameModes outside of expected scope on line 36.') def introDisplay(): # Displays the intro and defines the playerName Var. at the local scope, then returns it to the global scope. print('The Guessing Game! Now with more frustration!') playerName = input('\nHello, what is your name? ') print('\nWelcome ' + playerName + '.') print('\nThis is …

Member Avatar
Member Avatar
+0 forum 4

I am trying to write several different sorting algorithms in order to time the differences between them when reading a file of a half million integers. For testing purposes, I am only using a few hundred integers, but I am getting a stack overflow error. Also, for testing reasons, I have an output file being created during this run so that I can see if the code is working correctly. Originally, I had 3 nested for loops that I believed were causing the errors (and horrible effeciencey), but I cleaned those up and I am still having the error. Can …

Member Avatar
Member Avatar
+0 forum 4

Hello, Would someone be willing to take a look at this segment of code? I am trying to figure out how this segment of code operates. I can see how the program can evaluate a simple prefix statement like + 7 6. I cannot see how the program can solve a statement like + + 7 6 + 5 4. I've inserted some print statements in order to see what the program is doing and it is showing a = 7, b = 6, a = 13, a = 5, b = 4, b = 9, (22 = total). I …

Member Avatar
Member Avatar
+0 forum 3

I inherited a website here at work. The menu system uses a convoluted jquery / javascript structure. There are 8 different types of "users" for this website, from administrator to contractor or accountant, etc, and the person made 8 different versions of the menus covering nearly 80 different pages within the site. We have had success before on generating a menu with some jquery within a sharepoint site that had a "list" of the menu structure we needed, but I am having trouble translating to php and sql. I have gotten the code to where if the user is an …

Member Avatar
Member Avatar
+0 forum 2

Hello, Does anyone know how to write recursive SQL statement for hierarhic output places from next table: TABLE PLACES: id-----place----------idParentPlace 1......World..........Null 2......Europe.........1 3......Mediterranean..2 4......North Europe...2 5......Italy..........3 6......Greece.........3 7......Island.........4 8......Norway.........4 I don't know if this is totally correct SQL recursive statement: WITH recursion AS (SELECT id, place, idParentPlace, 1 AS hierarhic FROM places WHERE idParentPlace IS NULL UNION ALL SELECT id, place, idParentPlace, idParentPlace + 1 FROM places WHERE idParentPlace IS NOT NULL) SELECT * FROM recursion; Any help please? Regards, TP

Member Avatar
Member Avatar
+0 forum 1

Hello guys, Do anyone know how to write recursive SQL statement for hierarhic output places from next table: id-----place----------idParentPlace 1......World..........Null 2......Europe.........1 3......Mediterranean..2 4......North Europe...2 5......Italy..........3 6......Greece.........3 7......Island.........4 8......Norway.........4 I was looking for alot of tutorials but didn't find anything useful. Any help is the most welcome! Regards, TP

Member Avatar
Member Avatar
+0 forum 2

Hi How can I create a recursive method that counts how many files with a certain file extension, which is in a directory and the directory's sub directories. Exceptions that can be thrown in the search of the file tree should be handled appropriately. The user of the program should specify the directory in which to start the search and the file extension for the type of files to be included, such as "*. cs. ' Im using windows form application.

Member Avatar
Member Avatar
+0 forum 2

hi i have that code and this function gives me static overflow when i run the problem and stopped to work can anyone tell me why is this happening public bool declaration_List() { // sc.token(); if (declaration_List()) { if (declaration()) return (true); } else return (false); if (declaration()) { return (true); } else return (false); }

Member Avatar
Member Avatar
+0 forum 3

How do I write a recursive function in C++ to display a triangle of * like this using a parameter size (e.g. 4 in the following example): * ** *** **** I am able to write a recursive function to display an inverted triangle like this: **** *** ** * The code for the inverted triangle function is: [CODE] void inverted(int a) { if (a==1) { cout<<"*"<<endl; } else { for (int i=0; i<a; i++) { cout<<"*"; } cout<<endl; inverted(a-1); } } [/CODE] I am allowed to use a loop (e.g. for loop) to print a row of * but …

Member Avatar
Member Avatar
+1 forum 13

I bet all Computer Science related courses would learn low level or machine level languanges in due time and in our university we used the portable 80x86 assembler NASM for our Assembly code So here's my experimentation on how to use "functions" and recursion using a Fibonacci Solver as a test case As you may notice the code only output the final outcome of the Fibonacci sequence instead of printing every number for all steps. I might or might not update this depending on my free time and motivation but for now here's what i've done :)

Member Avatar
+0 forum 0

Hi everyone, We all face dificullity in coding recursivly, maybe most of new codders and CS students. However, **my question today is related to How many number of execution been made by the recursive method.** Which I think a bit tidious. I'll be updaing this article with new questions any time I face a new problem. Anyway, @Tanyawin suggest, is to learn scheme languge since everything there made by recursion. (loops,etc) But I think it needs some times which I don't currently have since we're hitting the exams door soon. **My question is: when you invoke a recursive call inside …

Member Avatar
Member Avatar
+0 forum 3

Hi guys, I'm trying to solve a problem recusrively. I'm asked to multiply two numbers with only using Addition,Subtraction and Comparison. After looking around the internet, it seems that the Algorithm I should use is Egyptian Algorithm . [Click Here](http://en.wikipedia.org/wiki/Ancient_Egyptian_multiplication) I would like some tips on how to solve this. What's going to be my stopping condition? I know I should stope when I have sum of equal the large number. But how would I check?

Member Avatar
Member Avatar
+0 forum 16

Hi All, I am implementing a recursive registry delete using RegOpenKeyEx, RegDeleteKey and RegEnumKey. **Problem::** Though the code works perfectly fine for Vista x86/x64 and Win 7 x86/x64 but fails on XP for some keys in HKCR **Problem Area::** HKCR\Installer\SomeKey **Error Code::** 87 (INVALID_PARAMETER) **Weird Behaviour::** Deletes the key the moment I open the key using **REGEDIT**. **Code::** static BOOL K7RT_RcrsvRegDel( HKEY hKey, LPTSTR lpszSub ) { BOOL bRet = TRUE ; LONG lRet ; DWORD dwSize = MAX_PATH ; TCHAR szName[MAX_PATH] ; TCHAR szFullKey[MAX_PATH * 2] ; HKEY hKeySub = NULL ; HRESULT hr = NULL ; do{ lRet …

Member Avatar
Member Avatar
+0 forum 2

I'm Creating a class that I want to call a recursive function within it. However, the complier says i cant declare a function within a method, I was wondering how I could Recursively call that function, in the method, or how to recursively call that method, with out declaring the function out of the class; #include <iostream> #include <vector> #include <math.h> #include <cstring> using namespace std; class RMatrix { int sizeH; int sizeL; int TotalN, Replace; protected: bool ** Matrix; RMatrix(int, int); ~RMatrix(){for (int x = 0; x<sizeH; x++)delete [] Matrix[x]; delete [] Matrix;} void DisplayMx (); void RepMatrixf(); }; …

Member Avatar
Member Avatar
+0 forum 8

The End.