Category "algorithm"

Convert camelCase to snakeCase

I have a dictionary something like this: { 'firstName': 'abc', 'lastName': 'xyz', 'favoriteMovies': ['Star Wars', 'The lone ranger'], 'favo

Does the size of the prime number in Shamir's Secret Sharing affect the security of the sharding?

I've been working on an implementation of Shamir's Secret Sharing, and was wondering if the prime number selected will impact on the security. This is mainly be

Resizing an array by a non-constant, continually

I’d like to perform amortized analysis of a dynamic array: When we perform a sequence of n insertions, whenever an array of size k fills up, we reallocate

Optimization of a short-length cyclic convolution

I have two sequences of 8 unsigned bytes and I need to compute their cyclic convolution, which yields 8 unsigned 19 bits integers. As I repeat this million time

A program to evaluate arithmetic expression

Here's an interesting problem I haven't managed to deal with yet. Given an arithmetic expression in Reverse Polish Notation, write a program to evaluate it. T

When can we have duplicate nodes in the heap in dijikstras algorithm?

So this question came to my mind when solving some dijikstra's based leetcode problems. We have node, distance pairs in priority queue at each step. Having dupl

Longest K Sequential Increasing Subsequences

Why I created a duplicate thread I created this thread after reading Longest increasing subsequence with K exceptions allowed. I realised that the person who wa

Count how many iterations of deletion until array is ordered

I'm trying to write a program whose input is an array of integers, and its size. This code has to delete each element which is smaller than the element to the l

which algorithm does google keyboard uses for automatic suggestions (personal vocab included)?

I am confused since google cannnot train their text generation models with each individuals personal vocabulary. I was trying to develop something similar but

Infected Fish can eat another fish having size less that its own. Minimum number of operation required

An evil scientist has developed an injection that induces insatiable hunger in a fish. On giving this injection, a fish of size x can eat another fish of smalle

My check for whether a graph is a Binary Tree always returns false

I have this question that is medium level and couldn't even think on how to solve this problem, my solution could be overkill as I have no idea on how to traver

Algorithm to return all combinations of 3 combinations from a array of length 6 without the number appearing with the same set of numbers

I was trying to write a algorithm in javascript that returns all the possible 3 digit numbers numbers from a given array of length 6 For Example var arr = [1, 2

Merging overlapping axis-aligned rectangles

I have a set of axis aligned rectangles. When two rectangles overlap (partly or completely), they shall be merged into their common bounding box. This process w

Is there a solution to the TSP problem that is effective and not limited to space?

Is there any method of solving the traveling salesman problem effective and that is not limited by space (as is the case of the Held-Karp algorithm), excepting

Merging 4 sorted Arrays into one

I have this method to merge 2 sorted arrays into one sorted array: public void merge(T[] a, int l1, int r1, T[] b, int l2, int r2, T[] c, int l3) {

Determine if relation is in BCNF form?

How do I determine if the following relation is in BCNF form? R(U,V,W,X,Y,Z) UVW ->X VW -> YU VWY ->Z I understand that for a functional dependency A

What is the time complexity of while loops?

I'm trying to find the time complexity of while loops and I have no idea where to begin. I understand how to find the complexity class of for loops, but when it

'int' object is not subscriptable?

I'm doing an algorithm challenge on www.edabit.com, where you have a list of dice rolls, and: if the number is 6, the next number on the list is amplified by a

Javascript twoSum algorithm: Given an array of integers, return indices of the two numbers such that they add up to a specific target

Given an array of integers, return indices of the two numbers such that they add up to a specific target. Example: Given nums = [3, 2, 4], target = 6, Because

Recursive and Iterative Binary Search: Which one is more efficient and why?

I have written the algorithms for recursive and iterative binary search: Recursive AlgorithmBinSrch(a, i,l,x) // Given an array a[i :l] of elementsin nondecre