Category "data-structures"

Java - Predicate to find Node with set value

I came upon object graphs while studying. And while they seem "cool" and useful, a related problem to the material made absolutely no sense to me. public class

How do i create a function to convert a binary tree to a tuple?

i came across this question where i was tasked to convert a tuple into binary tree and then convert binary tree back to tuple and return both tree and tuple. i

Describing a numbering system that counts from x at the y position in an index

From a theoretical perspective, I'm interested in learning how one would correctly describe a numbering system that starts counting from x at the y position in

Recursively creates dataclasses based in nested dictionary

I have a dataclass called Config that is created through the properties and values of a dictionary. Since this dictionary can have nested dictionaries, i would

Distirbute Candy - Finding minimum reproducible example of the problem

The question is to distribute candies to N children.Each child has a rating. Distribution should be such that each child have at least one candy and children wi

How to convert circular linked list into singly linked list

First, I make circular linked list that look like 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> (head) Now, I am trying to convert this circular linked list

Fold in Scade Suite is confusing me

So I know how the reduce, accumulator and how fold works in C++, Python, etc... But for some reason in Scade Suite it's kinda confusing to me. Scade Suite Examp

Maximum Frequency Number in an array using Hashmaps

Problem: You are given an array of integers that contain numbers in random order. Write a program to find and return the number which occurs the maximum

Can we detect cycles in directed graph using Union-Find data structure?

I know that one can detect cycles in direct graphs using DFS and BFS. I want to know whether we can detect cycles in directed graphs using Union-Find or not? I

Logic of for loop using with array to access elements of the array in java

My code to access elements of array using for loop. The output of the program is [19,17,15] which are the elements of array int a[] = { 12, 15, 16, 17, 19, 23 }

What are the differences between different ETS table types?

According to the manual there are 4 types of ETS tables: set – The table is a set table: one key, one object, no order among objects. This is the default

Music Chairs problem implementation in C++

I am currently practicing algorithms and DS. I have stumbled upon a question that I can't figure out how to solve. So the question's link is there: In summary,

Why is Merge sort better for large arrays and Quick sort for small ones?

The only reason I see for using merge sort over quick sort is if the list was already (or mostly) sorted. Merge sort requires more space as it creates an extra

Is this a panel data set (multiple individuals and two variables from different points of time)?

I have a dataset with multiple individuals and two variables from different points of time, for example: Company Employees at t=1 (before a specific event) Rev

How to recursively insert elements into a binary tree and keep it balanced java?

I am doing a project for class and am stuck on trying to develop this method. Would anyone be able to give me an example? The instructions for the method are be

Which data structure can act like a circular queue?

The picture above has 25 action points such that: Each of the four corners of each of the three layers is an action point. The midsection of each of the four s

Insert and Delete element on Circular Queue

I'm studying about circular queue in data structure . As you can see from the code below, I try to delete a specific data and insert data on Circular queue. How

How to create a path drawing algorithm to display specific landmarks of a face mesh in Landmark Detection with Tensorflow.JS and React?

I have currently implemented a version of this tutorial: Real Time AI Face Landmark Detection in 20 Minutes with Tensorflow.JS and React It demonstrates how to

How to get original array from random shuffle of an array

I was asked in an interview today below question. I gave O(nlgn) solution but I was asked to give O(n) solution. I could not come up with O(n) solution. Can you

Minimum moves to transform a list so that each element equals its own frequency

Given a sorted array like [1,2,4,4,4]. Each element in the array should occur exactly same number of times as element. For Example 1 should occur 1 time, 2 shou