Questions tagged [algorithm]
An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem. Use this tag when your issue is related to algorithm design.
algorithm
121,043
questions
-3
votes
0
answers
18
views
Association Rule Mining support count where there are duplicated items [closed]
When I learned about Association Rule Mining, the example was similar to https://www.geeksforgeeks.org/frequent-item-set-in-data-set-association-rule-mining/ and Frequent Itemsets & Association ...
-1
votes
0
answers
41
views
Swift: Complex matching algorithm needed
I have a problem implementing an algorithm to match invoices with transactions. So far the matching works quite well but from the code with the comment:
// Search for a transaction that can cover ...
0
votes
0
answers
68
views
Permutation summation in Pandas dataframe growing super exponentially
I have a pandas dataframe that looks like
import pandas as pd
data = {
"Race_ID": [2,2,2,2,2,5,5,5,5,5,5],
"Student_ID": [1,2,3,4,5,9,10,2,3,6,5],
"theta": [8,9,2,...
0
votes
0
answers
42
views
Design a Data structure ~(simple rate limiter) [closed]
I'm studying DSA for my interviews && university exams and kinda stuck right now.
There is a problem statement: given n(limit of request) and m(window time), design a data structure that ...
1
vote
2
answers
65
views
How to sort an array by only being able to swap an element with another element two positions ahead (i+2)?
I have an array of integers that I need to sort. However, the only operation allowed is to swap an element at index i with the element at index i+2. This means traditional sorting algorithms like ...
-1
votes
2
answers
58
views
Flip consecutive zeroes to ones in k operations to have maximum number of ones, find the maximum number of ones
You are given a binary string made of 0 and 1, and a value k which represents number of operations. You can flip consecutive 0s in each operation to 1s. Find the maximum number of 1s after k ...
-1
votes
0
answers
15
views
how to find the Minimum Spanning Tree on graph like that? [closed]
enter image description here
i think that this quastion have a liniar complexity solution ; i will addd the algorithm of procedure Prim(G, w):
input: גרף G עם קבוצת צמתים V וקבוצת קשתות E, פונקציית ...
0
votes
3
answers
51
views
difficulty to understand the code, and maybe the concept itself (recursion problem)
this code below is from Grokking Algorithms book that is an exercise for the functional programming/recursion and an application for the D&C concept. the function finds the maximum number in a ...
-1
votes
3
answers
97
views
How can I print this pattern [closed]
Problem statement:
You are given an integer n, representing the side length of a rhombus. Your task is to write a program to print the pattern of the sides and diagonals of the rhombus.
INPUT
The ...
0
votes
0
answers
89
views
How to fix color bar in canvas?
I have JavaScript code that draws vertical bars and changes their color based on the average music frequency. I tried to change the color of each bar to match the color of the previous bar, but I got ...
1
vote
0
answers
27
views
Calculate node value based on its surrounding cells [closed]
I have a 2D float array of width * height elements and I want to generate a mesh using it as a heightmap. The texture I've generated from the array was also width * height, so the mesh should have (...
0
votes
0
answers
20
views
Pathing for an Enemy AI [closed]
I am developing a video game in Game maker Studio, and I want to make an enemy with dynamic pathing. Previously I had to manually place nodes in the world that determined the paths that the enemy ...
2
votes
1
answer
29
views
Why do you exclude negative numbers from a max path sum algorithm
Here is a correct max path sum algorithm
export function maxPathSum(tree: BinaryTree): number {
let currMax = -Infinity;
const helper = (node: BinaryTree | null): number => {
if (!node) ...
1
vote
2
answers
66
views
How to break multiple try catch blocks in powershell
I have a class with +- 25 API functions for which I want to write a test-script.
I test my API-functions before and after a software upgrade so that I'm sure everything remains working.
However, I ...
-8
votes
1
answer
59
views
I have a task to count the number of times I've played music from favorite artists and I need to rank it from most played to least played [closed]
What is the difference between the first function and the second function if they do the same task and what is faster?
Note that the first function of GPT4 chat
def selectionSort(arr):
""...