All Questions
12,660
questions
0
votes
0
answers
6
views
Studies on Square Roots
This post marks the beginning of my ventures into calculating square roots. However, I have no idea how the processor, more specifically the FPU with the fsqrt instruction, performs the process. I ...
0
votes
0
answers
30
views
Calculating a list of voxels within multiple overlapping Axis-Aligned-Bounding-Boxes, without looping over the same space
I have a method that returns a list of voxel coordinates within an AABB. Let's say a voxel is 1x1x1 cm, and a bounding box is 2x2x2, then it will return 8 voxels by looping over the dimensions of the ...
1
vote
3
answers
113
views
In-Place Reordering of Doubly Linked List Nodes to Ensure Memory Contiguity
I am working on a program that deals with doubly linked lists that are allocated within a bounded memory region:
constexpr std::size_t numNodes = 15;
Node* block = new Node[numNodes];
I would like to ...
2
votes
1
answer
66
views
Having issues calculating APSP for matrix size n >= 4
I'm having issues finding the problem with the following implementation of Floyd-Warshall APSP Algorithm.
Currently working on a vjudge exercise and I'm having issues figuring out what's the problem ...
-2
votes
3
answers
103
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
2
answers
90
views
Why does my Delaunay Triangulation using the Bowyer Watson algorithm not work?
I am implementing delaunay triangulation on a random set generated points, making use of the Bowyer Watson algorithm.
I seem to be running into a issue where the output seems to be generating way too ...
1
vote
2
answers
167
views
Smallest element after xor
Starting with array of N positive integers, support Q queries. Each query contains a positive integer i. To answer the query, replace each element of the array with the result of xoring it with i, ...
1
vote
1
answer
95
views
Why does the sliding window algorithm not work for this problem statement?
The question is regarding an algorithm which I'm using to solve a problem. The problem statement is: (or view it here)
"Given arrival and departure times of all trains that reach a railway ...
1
vote
1
answer
156
views
Thread pool design
I have a design question about thread pool. Consider the following code:
int main() {
auto po = std::execution::par_unseq;
// If Parallel STL uses TBB as the backend, I think the thread pool
/...
1
vote
1
answer
87
views
Determine which elements of sequence A can be used to create given sequence B in linear time
Let's say we have sequence A and subsequence of A, called B. I need to determine which elements of sequence A could be potentially used to construct subsequence B.
For example, assume A = [1, 3, 2, 1, ...
1
vote
1
answer
104
views
Reversing characters of string of parenthesis to achieve at max H string depth
Given a integer H and string s which contains only ( and ) characters, and is properly formed (every opening bracket has corresponding closing bracket, the pairs of brackets are properly nested), ...
0
votes
0
answers
42
views
Why use two arrays of insertion_time and lowest_insert_time in Tarjans algorithm for Bridges in Graph? [duplicate]
I've been working on the LeetCode problem 1192. Critical Connections in a Network. From various sources, I have the following code:
class Solution {
int timer = 1;
void dfs(int node, int ...
2
votes
0
answers
79
views
What is the Time Complexity of a function if there is an upper limit to the variable
I have the following piece of code.
void foo(int n){
n=n*n;
for (int i=0;i<n;i++){
if(n<10)
cout << i;
else
break;
}
}
Now I wanted to ask if the time complexity ...
0
votes
3
answers
185
views
Isn't there any more efficient solution for the CodeForces 919-B/Perfect Number question?
So, here's the question:
We consider a positive integer perfect, if and only if the sum of its digits is exactly 10. Given a positive integer k, your task is to find the k-th smallest perfect ...
2
votes
1
answer
74
views
How to get the first value greater than x in a range with segment tree
I am trying to use a segment tree to handle queries (in O(log N) per query) of the form: find the first value > x in a particular range [ql, qr] (of an array of size N).
I've been using the ...