Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c++]

Programming questions are off-topic here. Do not ask questions about how to write code in C++. However, conceptual questions about computer science are more appropriate. See our help center for the scope of this site.

0
votes
1answer
24 views

radix-sort with different bases

So i understand how to use radix-sort in base 10 and utilize mod 10 to go through the numbers. But not sure about 2,8 or 16. Does it follow the same idea? and i read somewhere that i need to pass ...
-1
votes
0answers
12 views

Undefined reference to one's own implemented STL Stack container adapter [on hold]

I am a beginner in C++ and have implemented my own stack STL container adapter. When I implement a function that checks whether the brackets are balanced or not in C++ code, C++'s compile log says ...
1
vote
0answers
23 views

How does C++'s type checking work when passing overloaded or templated functions as parameter

As I understand, C++ in general features 'one-way' type checking. That is checking the sub-expressions and get their types, and see if the types so far satisfy the constraints imposed by the current ...
1
vote
1answer
28 views

Complete the following table by specifying the scope of each declaration

I'm having a hard time understanding this question. Can each declaration have more than one scope or can a declaration have more than one scope? If it's the later it would be: Declaration ...
5
votes
1answer
585 views

Where are C++ templates inside of the lambda cube?

C++ templates have type variables and can express lambdas, so they must have System F embedded. But is that exactly where they are located in the lambda cube? Can C++ templates produce new types or ...
1
vote
0answers
24 views

Summary of types of equivalence and equality in type theory, with notations and examples

Coming from non-computer science background, I am trying to understand the different types of equivalence and equality usually used in type theory. Ideally, I am looking for clear definitions and ...
1
vote
2answers
52 views

Compare each array $i$ member to all array $j$ member where $(i > j)$ , in time less than $O(n^2)$

I am new to algorithms so sorry to ask simple question I am working on a problem which is about array of integers, my solution is right but not good enough, because I have time exceeded exception on ...
2
votes
0answers
63 views

Implementing a linear programming feasibility test in 3D

I have a little problem which requires determining if a system of linear inequalities in 3D is infeasible. The constraints (or oriented planes) are added one by one, so there is an opportunity to stop ...
0
votes
1answer
83 views

Bytes from integer using bitwise operators

So I am extremely confused with using bitwise shifts used to extract the bytes from an integer. I find that if I do something like this... ...
1
vote
2answers
182 views

Which algorithm is used by STL sort? [closed]

I implemented my own shellsort, shown in plot below are the timings for it. 0 means std::sort, used for comparision 1 means single thread 2 to 12 means multi-thread (pthreads) Which algorithm is ...
0
votes
1answer
61 views

How to count number of 1s of the first k positions in a bitset (bitmap)?

Input: Given a bitset $b$, which is is an array of 0s and 1s, of length $L$, and a positive integer $k$. Output: the total number of 1s in the first $k$ position of $b$. Obviously it can be done in $...
1
vote
1answer
67 views

How signed number stored in c/c++ language? [closed]

Either in 2's complement form or in 1's complement form?
1
vote
0answers
48 views

Generate an AST from an indefinite grammar and logic

As said in the title, I have to generate an AST from a grammar and logic (or a"syntax" if you prefer). This grammar and syntax are both indefinite in the program, meaning that it is the user (a ...
-1
votes
1answer
26 views

How is ReLU used in machine learning functions

I've seen how sigmoid would be used in machine learning sigmoid(dot(activations, weights)-bias) like this ^ but sigmoid makes sure your values are between 0 and ...
1
vote
0answers
912 views

To find median of k sorted arrays of n elements each in less than O(n*k*log(k))

How to find median of k sorted arrays each of length n? Note that total elements would be n*k. I know it can be done in O(n*k*log(k)) using merge technique. I am looking for a better time efficient ...
1
vote
1answer
86 views

Why isn't deque implemented as a dynamic array?

We know that std::vector in C++ is implemented as a dynamic array with specific pattern of reallocation (multiplying capacity by a constant), which allows it to ...
1
vote
1answer
201 views

Find maximum non contiguous subarray that respect a specific rule [closed]

Given these two arrays: [5, 3, 4, 1, 2] [1, 3, 2, 4, 5] Find the maximum subsequence in both arrays that the index of the elements are in a crescent order: ...
0
votes
1answer
298 views

Find Length of longest substring with all 1's in a binary string with k queries

Given a string of size n consisting of 0s and/or 1s.you have to perform k queries and there are two types of queries possible. "1"(without quotes): Print length of the longest substring with all '1'. ...
0
votes
1answer
45 views
-3
votes
1answer
63 views

How to overload > & < operator for my card Class? [closed]

I need help overloading the comparison operators ( > , < ) so that I can compare Cards from my Card class. The card are made up of a rank that is of type integer and a Suit that is type Enum. The ...
1
vote
1answer
58 views

Print maximum frequency number in an array(with slight modification)

There is an integer array and 2 variables Q and M.The output required is the number which has the maximum frequency in the array, but the catch is that each number in the array can be increased/...
1
vote
2answers
96 views

How do compilers implement symbolic (rather than textual) insertion?

From a programming language designer's point of view, how is "symbolic" insertion implemented as opposed to "textual" insertion using pre-processor macros? I understand the basics of how "textual" ...