algorithm Questions

1

I'm trying to optimize an algorithm that counts permutations with specific constraints. Given integers n, t, a, b where: n is the length of permutation (1 to n) t is the required number of fixed p...

2

Solved

What is the difference between divide and conquer, and branch and reduce. From Exact Exponential Algorithms by Fomin and Kratsch, branch and reduce algorithms uses two types of rules: A reduc...
Cribbs asked 14/12, 2016 at 10:44

6

Magic square: sum of any row, column, or diagonal of length is always equal to the same number. All 9 numbers are distinct positive integers. I am doing it this way in JavaScript, but what is the ...
Moiramoirai asked 16/10, 2018 at 17:44

2

Solved

I want to find the index of the first integer in an array of integers which is <= key. I can do it with binary search in log2(N)+1 compares. Shouldn't it be possible with only log2(N) compares? ...
Dg asked 13/8, 2015 at 18:48

3

Solved

In the sorting algorithms like heapsort or quicksort, why do standard publications or research papers prefer the term "non-descending" or "non-ascending" when they can simply use ascending or desce...
Ainu asked 24/2, 2017 at 16:48

12

Solved

I am doing exercises on codility. I have spent two days on this problem with no improvement in my score. I get 100% on my correctness score, but fail some performance tests because it returns the w...
Suckow asked 7/10, 2014 at 4:12

7

Solved

Given a unsolved sudoku, how can one show that it has a unique solution?
Cinder asked 19/2, 2011 at 19:0

1

Solved

Given we can do a left-rotate (and subsequently a right-rotate) of an array only in terms of calls to reverse, like so: void rotl(std::string &s, const int d) { std::reverse(s.begin() , s.begi...
Limekiln asked 18/9 at 8:32

7

Solved

I was very confused about this question. I know about finding the edit distance between 2 strings using recursion and dynamic programming as an improvement, however am confused about how to go with...
Armipotent asked 16/4, 2015 at 23:14

3

Solved

I have this graph network in R: library(igraph) n_rows <- 10 n_cols <- 5 g <- make_lattice(dimvector = c(n_cols, n_rows)) layout <- layout_on_grid(g, width = n_cols) n_nodes <- vco...
Kovar asked 13/9 at 12:49

2

Solved

I've taken a look at this questions , but I still don't see the difference between a Suffix tree and a Trie . Both have all the substrings of a given string , so where do they differ from one ano...
Soda asked 1/8, 2013 at 6:48

8

Solved

I'm trying to find a solution to a codility question on minimum slice of a subarray, and I've devised a solution using a modified version of Kadane's algorithm. I've currently gotten 90/100 and man...

3

Solved

I want to get a range of elements from a std::vector<MyClass> and store them as const-ref, because I only want to read but not modify them. #include <iostream> #include <vector> ...
Sweitzer asked 6/9 at 7:43

41

Solved

I'm trying to solve Codility lessons for coding practice and PermCheck is one of them. [Edit] Problem Description: A non-empty zero-indexed array A consisting of N integers is given. A permutati...
Dyson asked 15/12, 2014 at 22:19

2

Solved

How would you go about proving the correctness of merge sort with reasoning over the states of loop invariants?.The only thing that i can visualize is that during the merge step the subarrays(invar...
Pygmy asked 9/11, 2016 at 3:23

9

Solved

Among n persons,a "celebrity" is defined as someone who is known by everyone but does not know anyone. The problem is to identify the celebrity, if one exists, by asking the question only of the fo...

3

I'm working on a MongoDB project for my school. I have a Collection of sentences, and I do a normal Text search to find the most similar sentence in the collection, this is based on the scoring. ...
Lelandleler asked 27/3, 2017 at 8:33

4

Solved

I'm complitely new to Flood Fill algorithm. I checked it out from Wikipedia (http://en.wikipedia.org/wiki/Flood_fill). But didn't become that much wiser. I'm trying to use it in following situation...
Vulpine asked 7/11, 2013 at 15:34

7

I'm looking for an algorithm to find the best fit between a cloud of points and a sphere. That is, I want to minimise where C is the centre of the sphere, r its radius, and each P a point in my s...
Granule asked 27/4, 2012 at 2:45

13

Solved

I have this algorithm to generate all combinations of well-formed parentheses. Can someone explain the core concept of the algorithm? I tried debugging through it, but I still can't seem to grasp ...
Kultur asked 1/5, 2014 at 18:17

3

cppreference states: The ranges library is an extension and generalization of the algorithms and iterator libraries that makes them more powerful by making them composable and less error-prone. ...
Dittany asked 10/3, 2023 at 10:21

6

Solved

I am trying to determine whether a line segment (i.e. between two points) intersects a sphere. I am not interested in the position of the intersection, just whether or not the segment intersects th...
Selwyn asked 14/1, 2010 at 5:10

11

Solved

My friend ran into a question in an interview and he was told that there is an O(n) solution. However, neither of us can think it up. Here is the question: There is a string which contains just ( ...

9

Solved

I would like to implement this in C# I have looked here: http://www.codeproject.com/KB/cpp/PEChecksum.aspx And am aware of the ImageHlp.dll MapFileAndCheckSum function. However, for various reas...
Varityper asked 21/6, 2011 at 17:55

10

Solved

I wrote the following function to find the longest palindrome in a string. It works fine but it won't work for words like "noon" or "redder". I fiddled around and changed the first line in the for ...
Heptad asked 12/11, 2015 at 16:35

© 2022 - 2024 — McMap. All rights reserved.