Tagged Questions
3
votes
8answers
4k views
counting odd numbers in a list python
This is a part of my homework assignment and im close to the final answer but not quite yet. I need to write a function that counts odd numbers in a list.
Create a recursive function count_odd(l) ...
1
vote
0answers
43 views
Python Recursion Overhead
I have written a python program that solves Sudoku and want to make it faster. The core operation is a depth first search function which I implement as recursion. I thought I could eliminate the ...
0
votes
4answers
39 views
What is wrong with my Fibonacci sequence calculation in Python?
I am new to Python and would like to know if recursion works at all. I can't get my code running. It is supposed to print all the the fibonacci numbers:
#!/usr/bin/python
import time, sys
def ...
3
votes
3answers
792 views
Merge sort to count split inversions in Python
I am trying to use mergesort--which I get--to count the number of split inversions in a list (that is, where an element in the first half of the unsorted list should appear after a given element in ...
0
votes
0answers
41 views
Flat table to json tree in python
Again a flat table to hierarchy tree question:
I want to convert tables (originally xlsx) into a json hierarchy in python. Assume a soccer player database with regional information. The data has the ...
4
votes
1answer
61 views
Baktracking function which calculates change exceeds maximum recursion depth
I'm trying to write a function that finds all possible combinations of coins that yield a specified amount, for example it calculates all possible way to give change for the amount 2 British pounds ...
0
votes
1answer
32 views
counting iterations in recursion python
I saw the thread about how to keep count in a recursive function but I didn't quite follow the answer and it also didn't seem to apply to what I am looking for (at least from what I could tell so ...
2
votes
1answer
47 views
Tree Path from Root to Selected Node - The Pythonic Way
In a python application we have a tree made up of TreeNode objects, and we had to add a property on the TreeNode class that returns the path from the tree root to that node as a list. We have ...
0
votes
0answers
30 views
Jython exceeding recursion limit with Gson
I'm using Jython to make a Gson call to the method toJson(). I used a GsonBuilder to create the Gson object. The problem is that when calling the method, I get a 'RuntimeError: maximum recursion depth ...
0
votes
3answers
31 views
Update a key by calling a recursive function, updating other keys during same sequence
I'm excited to ask my first question here. I've run into some problems with recursion. I am coding with Python.
I am using a dictionary to store previously solved numbers in a mathematical sequence. ...
2
votes
2answers
75 views
Translate Recursive Python List Generator to C++
I need to convert this piece of python code for speed purposes.
r and n are user defined integer variables.
The function is supposed to generate all lists with the following criteria:
listSum = n, ...
0
votes
1answer
36 views
Unexpected python recursive multiplication return
It is my intention to recursively multiply two numbers with this function. I realize this is quite possibly far from optimal. Why does my call, print rec_mult(15, 1111), to this function print None ...
1
vote
0answers
40 views
Deleting a Node in an AVL Tree- SOLVED
I am working on an AVL Tree right now and am just about done except for the deleting a node method. I am a bit stuck right now and need some help. The way I did it was to find the node to be deleted ...
8
votes
4answers
1k views
How can a recursive regexp be implemented in python?
I'm interested how can be implemented recursive regexp matching in Python (I've not found any examples :( ). For example how would one write expression which matches "bracket balanced" string like ...
1
vote
1answer
30 views
Any ideas on why these two max/min value functions don't work for a BST in python?
So, in the case of these two functions, I input something like:
BSTTree.maxValue(BSTTree.root)
and let's say the BST looked something like this:
6
/ \
3 7
\
8
...