Categories

k-way merge sort base case

i don’t understand this particular sample code from geeksforgeeks on k-way merge sort. More specifically, I don’t understand what the "n" in the for loop in the base case for divide() is. Is it the number of students in each array? (which in this case is 4) Also could you please explain what the for […]

Categories

Join objects with one same property within different arrays

I have this array, that contains more arrays with objects inside that contains information about words founded in pages. Here one example: let data = [ [], [{ "word": "society", "count": 5, "pageIndex": 1 }, { "word": "identity", "count": 2, "pageIndex": 1 } ], [{ "word": "society", "count": 2, "pageIndex": 2 }, { "word": "identity", […]

Categories

Recreate Excel formula in SQL

I am trying to recreate the below Excel formula/table and have True/False display but am stuck. Excel Formula: =ABS(ROUND(MEDIAN(C\$2:C2),0)-ROUND(MODE.SNGL(C\$2:C2),0))<[sample.xlsx]variables!\$B\$2 I have 200+ rows of data and I need the Median and the Mode only calculated from the first row to the current row. I can create the Median for all rows in SQL, but this […]

Categories

How to get depth of tree of arrays given total num items and max array size?

Given this divide algorithm and sample data: const data = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, […]

Categories

Partition N where the count of parts and each part are a power of 2, and part size and count are restricted

How do you take a number representing a list of items, and divide it into chunks, where the number of chunks is a power-of-two, AND where each chunk also has a power-of-two number of items (where size goes up to a max power of two, so 1, 2, 4, 8, 16, 32, 32 being the […]

Categories

Partition N where the count of parts and each part are a power of 2, and part size and count are restricted

How do you take a number representing a list of items, and divide it into chunks, where the number of chunks is a power-of-two, AND where each chunk also has a power-of-two number of items (where size goes up to a max power of two, so 1, 2, 4, 8, 16, 32, 32 being the […]

Categories

How to divide an array into a tree of buckets sized by powers of two?

How do you take a number representing a list of items, and divide it into chunks, where the number of chunks is a power-of-two, AND where each chunk also has a power-of-two number of items (where size goes up to a max power of two, so 1, 2, 4, 8, 16, 32, 32 being the […]

Categories

Create an open ended question with learnr:tutorial in r

I want to allow students to input their student ID at the beginning of every quiz they take. There are no correct answers as long as they input a 7 digit number. This is what I have right now but the function does not run when the defined answers are sot one single text. How […]

Categories

Python speed up permutation of bits within 32Bit number

I’m interested in reordering the bits within a number, and since I want to do it several trillion times, I want to do it fast. Here are the details: given a number num and an order matrix order. order contains up to ~6000 lines of permutations of the numbers 0..31. These are the positions to […]