Skip to content
Advertisement

Tag: recursion

Can I use a lambda function like this?

I want to try to use lambda functions (which I do not understand well) so I can learn more about them. I have an assignment on trees that has us making a family tree class. children is a set of all of the children nodes to this node. Also as a side question, does this usage of AtomicInteger work similarly

Flat tree of objects while keeping father and child

I have a class Employee which has a tree structure with property team Using Java lambdas I need to flat this tree into same level list while converting Employee class into the following ConvertedEmployee while storing names in dedicated lead and subordinates properties. So ConvertedEmployee is in some sense a node which keeps parent and children. And I need to

Building a Recursive Data Structure with Spring WebFlux

I have a REST API that is built with the Spring WebFlux framework, and I have an endpoint which returns a Flux<ChannelResponse>, where ChannelResponse is a tree-structured object, as shown below: Now, I don’t have much experience with the reactive programming paradigm, but this is how I would implement such an endpoint with synchronous logic, such that each top-level channel

Need help understanding basic recursion problem

I have just started practicing with recursion I have this very simple practice program problem. There are bunnies standing in a line, numbered 1,2,3… The odd bunnies (1,2,3..) have normal 2 ears. The even bunnies (2,4,6…) have 3 ears, because they each have a raised foot. Recursively return the number of ears in the bunny line. I have the solution.

Finding a the “sub-path” in a hierarchical system, Java

I have this Hierarchical file system that is built like so: Given a path (not necessarily the complete path) for example for this system: a path be given like so: I am trying to make a function return the specified File if there exists a path where the given path is part of it, for example if it finds the

Recursion with bitwise operators

I have the following method in java that simplify Nor expressions using recursion: Now, when I want to simplify the expression (T ↓ y) ↓ y , it ouputs F ↓ y instead of ~(y). How I need to change the recursion to output the right simplified expression? Answer Your case isn’t covered, so you get the default, all the

Index of first distinct character between two strings using a recursive method

I need to find the index of the first distinct character between two strings using a recursive method. Examples with expected outputs: rFirstDistinctPlace(“Little parcels”, “Little pretzels”) -> 8 rFirstDistinctPlace(“Gold shadow”, “gold shadow”) -> 0 rFirstDistinctPlace(“gold”, “golda”) -> 4 rFirstDistinctPlace(“gold”,”gold”) -> -1 Note: I can’t use the .equals() function The thing I’m struggling with is that I need to return -1

Advertisement