232 Discussion / Question Topics

Remove Filter
Member Avatar for
Member Avatar for dendenny01

I am trying to implement Connect 4 game using Min-Max as utility to find best possible move.<br><br> The game is played on a 6x7 grid, with six rows and seven columns. . The two players take turns placing pieces on the board: the red player can only place red pieces, …

Member Avatar for rproffitt
0
454
Member Avatar for abrogard

You know the Pareto Principle? The 80/20 rule? That 80% of the work gets done by 20% of the people? Or 80% of the money belongs to 20% of the people? And so on? Well it is 'recursive' inasmuch as it can be applied again to the 20% first recognised. …

Member Avatar for JamesCherrill
1
510
Member Avatar for samertaha

Hi, I have created a function that searches for a category in a category tree object and returns all the paths for it as an array of strings, please advice how I can improve it ? the result im getting now is : ["vehicles",["cars","mercedes"],["trucks","mercedes"],["motorcycles","BMW"]] i need it in one dimesional …

Member Avatar for samertaha
0
397
Member Avatar for Iamateur

Hie,I have Merge Sort Program .It's giving correct output but when checked through debugger it gives different values everytime.I also tried doing it manually but I am not getting the actual output. I will not ask now for complete program explanation. I just want to know the value over here.This …

Member Avatar for rproffitt
0
385
Member Avatar for Sherwin_4

Below is my code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream> using namespace std; ///////////////////////////////////////////////////////////////////////// /* // struct Edge // Represent one edge in the graph. Fields contain // two vertex numbers and a weight. */ struct Edge { int vertex_1, vertex_2, weight; }; //////////////////////////////////////////////////////////////////////// /* // struct Graph …

Member Avatar for Seif_2
0
376
Member Avatar for Sherwin_4

Good evening everyone, Does any one have a reference/videos/tutorials on how to use recursion effecitely in C++? v/r

Member Avatar for Chris_38
0
356
Member Avatar for Sherwin_4

Good morning everyone, The library will be home, 0800 till 2100. I've been working on trying my loops in my hailstone sequence into recursions. It seem recursion can easrier to do, instead of creating loops. I say seem, because now I have come to halt on my progress. The halt …

Member Avatar for JamesCherrill
0
781
Member Avatar for glao

Hello , I have this code: #include <iostream> #include <cstdio> #include <cstdlib> using namespace std; void message(int numbers) { cout << "Entry to function #" << numbers << endl; if ( numbers > 0 ) { cout << "This is a recursive function." << endl; message( numbers-1 ); } cout …

Member Avatar for glao
0
488
Member Avatar for Gà_1

Hi every one, I had implemented Karatsuba algorithm in C++, but I have been stuck for 2 days. First problem is the function give incorrect answer, second problem is it oftens crash when run (runtime error). I try to debug but cannot understand how it's not work. I hope someone …

0
226
Member Avatar for theoryforlife

Hello, I've been working at this code from a couple angles, I've had two people I've known to help me, but even with their help it hasn't worked. The question I have relates to CodeLab: Write the definition of a function named printStarBucks that receives a non-negative integer n and …

Member Avatar for Lukas_1
0
2K
Member Avatar for noobjavacoder

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 …

Member Avatar for Taywin
0
239
Member Avatar for noobjavacoder

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 …

Member Avatar for invisal
0
1K
Member Avatar for preslav_milev

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 …

Member Avatar for preslav_milev
0
618
Member Avatar for DS9596
Member Avatar for David W
0
387
Member Avatar for DS9596

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 for Schol-R-LEA
0
279
Member Avatar for gabrielcastillo

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 …

Member Avatar for gabrielcastillo
0
325
Member Avatar for ravi142

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 for Taywin
0
220
Member Avatar for Adami

Hi guys, I wrote the following code: public static boolean match(int[] a , int[] pattern) { //need to use the overloaded method, in order to work with the static method. return match(a,pattern,0,0); } /** This is an overloaded method that match between a pattern to a given string (as an …

Member Avatar for Adami
0
3K
Member Avatar for stephen.teacher

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 …

Member Avatar for stephen.teacher
0
298
Member Avatar for duncan55

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 += …

Member Avatar for jwenting
0
204
Member Avatar for ubhart

Hi, I am making program that finds solution how to put 12 knights(horses) to chess board that every square is dominated or engaged by other knight. Look at my code: #include <stdio.h> #include <stdlib.h> #include <stdbool.h> //(*******************************************************************************) void addNulls(char L[][9], int N[], int M[]) { int i,j,g; for (i=1 ; …

Member Avatar for ubhart
0
271
Member Avatar for ubhart

Hi I have to write program that finds a solution how to put 12 knights to a 8x8 chess board that every square would be dominated by one of the 12 knights. Do you have any suggestions from where I can start?

Member Avatar for ubhart
0
390
Member Avatar for Pyler

How's the result to this 7? void foo(int i){ if(i>1){foo(i/2);foo(i/2);}cout<<"#"<<endl;}

Member Avatar for vmanes
-1
221
Member Avatar for vibhu mishra

i have a c code for printing all permutation of string. I have a problem in understanding ,how recursion work in for loop and how backtracking is used in this code. Another question is that how stack work in recursion under for loop. my code--> # include <stdio.h> void swap …

Member Avatar for David W
0
352
Member Avatar for birinci2012

def isPrime(num,div=2): if(num==div): return True elif(num % div == 0): return False else: return isPrime(num,div+1)

Member Avatar for slate
0
995
Member Avatar for Schol-R-LEA

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 …

Member Avatar for Ancient Dragon
1
2K
Member Avatar for CheerfulBiscuit

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 …

Member Avatar for JamesCherrill
0
240
Member Avatar for jackslv

This is just a piece of code I've found over the Internet, and I'm trying to understand why the output is 3 1 1 2 1 1 2 3. Could anyone explain using a stack representation or something else, I am really stuck on this one. #include <iostream> using namespace …

Member Avatar for jackslv
0
232
Member Avatar for kruschev

#include <iostream> using namespace std; int f(int i) { if(i == 1) { return (1); } else { return 2*f(i-1); } } int main() { cout << f(5) << endl; //<--- I don't understand why this is 16. return 0; } I am having trouble understanding why f(5) = 16 …

Member Avatar for kruschev
0
214
Member Avatar for woomar

Hi. I was wondering how I could replace objects in a list without using a single loop. Here's what I have in terms of algorithm; but, I don't know how to implement.: replace(List list, oldObject, newObject) 1. if the first element in list is not null 2 if the old …

Member Avatar for woomar
0
238

The End.