## Error in N Queens Problem using Backtracking and Recursion

I first implemented a zero matrix indicating that all the positions of the chessboard are initially available n=int(input()) answer=[] restrictedIndices=[[0 for i in range(n)] for j in range(n)] dp(n,…

## How to use recursion to give the minimum integer in a list using python?

I am trying to write a recursive function called my_minimum that receives a list of integers as parameter and returns the minimum stored in the list. I am able to get the user to input integers …

## How to implement AVL tree rotation?

I have coded an AVL Tree and my logic for the rotations is correct but I am still not able to get it working properly. For rotations on the root node my rotations work properly but if the rotation is …

## Using Recursion to check for sum of tuples in a list

I have a func which takes a list of tuples, each tuple contains two items: item name and value. I need the func to return True if it’s possible to divide the tuple list into two equal valued groups …

## How to calculate time complexity of these two functions? (recursion)

The first function: def f1(n): if n == 1: return 1 return f(f(n-1)) The second function: def f2(n): if n == 1: return 1 return 1 + f(f(n-1)) Now I can see why both of the function’s space …

## while-loop problem for acess a list element

I want to append each element of [1,2] to [, , ] and as a consequence, the final array that I want is [[1,1], [1,2], [2,1], [2,2], [3,1], [3,2]] But my code has a mistake I couldn’t recognize …

## Replace All Specific Characters in String using Python

I have a problem with a function I am trying to implement that needs to replace some letters (in a given string), for some other characters, defined on a dictionary. I have this dictionary: chars = { …

## Recursively searching for a string in a list of characters

I have a problem to solve which is to recursively search for a string in a list (length of string and list is atleast 2) and return it’s positions. for example: if we had ab with the list [‘a’,’b’,’c’]…

## I want to extract all the values that a class object holds

I have an object Vm of Type I want to iterate over this object by a loop so that I don’t have to manually extract the …

## function that prints counding down numbers and up but in a pattern

I already know how to count down and up using reccurssive function but I cant figure out how to define another function to have spaces in a pattern like this: Desired output My code for counting down …