Skip to content
Advertisement

Tag: recursion

How can I mimic a Javascript “spread operator” in C#?

I am following a tutorial on Dynamic Programming on youtube to understand more about Recursive functions, and I am stuck where a spread operator is used. Code in JavaScript This is the code in C# where I’m trying to replicate the function EDIT: Should I use a Dictionary and use a key? I don’t understand how to work my way

Recursively filter an array of infinitely nested objects by mutliple matching conditions but only return parent that has an instance of both matches

I have the following array of objects; however this could be any unknown key/value and be infinitely nested, for now this is a testing sample: My current implementation is as follows: Basically I am adding to the “selected” array then using that to filter the data array by. I do want to ensure the key matches the “column” also however

how to sort recursively in JS

I’m trying to sort an Array type data recursively. Here’s the data structure. I wanna sort by either ‘id’ or ‘name’. This is what I tried. In my poor logic, it seems working but not properly working. Because item’s children or children’s children is not sorted. 🙁 What should I fix? or maybe my approach was totally wrong? Thank you

Memoize a recursive Fibonacci function

I created a withMemo function that returns a memoized version of the provided function. How can I memoize this fibonacci function that works with recursion ? Indeed withMemo(fibo) doesn’t improve performance since the recursive calls inside fibo still point to the unmemoized version… So I have to alter the declaration of fibo to make momoization work: Is there a way

Advertisement