Questions tagged [lower-bound]

In mathematics, especially in order theory, a lower bound of a subset S of some partially ordered set (K, ≤) is an element of K which is less than or equal to every element of S.

A subset S of a partially ordered set K may fail to have any bounds or may have many different upper and lower bounds. By transitivity, any element less than or equal to any lower bound of S is again a lower bound of S. This leads to the consideration of greatest lower bounds (or infima).

213 questions
-1
votes
2 answers

How to find the index of element which just smaller than current element in set (c++20)

Let suppose the values in my set are S={1,2,3,4}; Now I want to know how many numbers are there which are smaller than 3,then I will use s.lower_bound(3); But I am not able to get the count of numbers less than 3 when I…
-1
votes
1 answer

Merge k sorted arrays of size n in less then O(nklogk) time complexity

The question: Merge k sorted arrays each with n elements into a single array of size nk in minimum time complexity. The algorithm should be a comparison-based algorithm. No assumption on the input should be made. So I know about an algorithm that…
linuxbeginner
  • 39
  • 1
  • 7
-1
votes
4 answers

Finding the lower bound of vector of pairs based on first value of pair

I have a vector of pair "v" which is sorted according to the first value of the pair. Now I want to find out the lower bound of vector "v" according to the first value of the pair -- while finding the lower bound I want to ignore the second. int pl;…
-1
votes
1 answer

Python: set lower- and upperbounds, remove them from array, and calculate the mean of new array

enter image description here I need help to figure this out! I am pretty new to coding python. I have set in the print statement my upper and lower bounds to be 25 and 15, i have then tried to define 2 lines, that removes the number that exceeds the…
sedative
  • 1
  • 2
-1
votes
1 answer

Decision trees in finding lower bounds of algorithms

One way to find the lower bound of a comparison based algorithm is to use the decision tree. U have two questions regarding this method : 1) We know that the height of the tree is path that connects the root node to the farthest leaf node ( longest…
AAA
  • 151
  • 1
  • 9
-1
votes
2 answers

How to verify if there is an element < x in a set C++

Is there an element that is smaller than a given x in a std::set s If there isn't print "x is the smaller than any element", if there is then print "the biggest element that is smaller than x". By the way, you also know that x is not in the set is :…
Alex
  • 1
  • 3
-1
votes
1 answer

finding the return value of the lower_bound

I am trying to use a lower_bound to find out if value is inside a vector of pointers to struct. I am using auto it = lower_bound( myVector.begin() , myVector.end() , value , comparer() ); comparer function looks like struct comparer { bool…
user3706129
  • 229
  • 4
  • 15
-1
votes
4 answers

understanding of lower bound for comparison-based sorting algorithm

First, I know lower bound is O(nlogn) and how to prove it And I agree the lower bound should be O(nlogn). What I don't quite understand is: For some special cases, the # of comparisons could actually be even lower than the lower bound. For…
gongzhitaao
  • 6,566
  • 3
  • 36
  • 44
-2
votes
1 answer

Shouldn't lower_bound return an iterator pointing to end()?

I am trying to understand lower_bound better. I have the code below: #include #include #include int main() { std::vector data = { -1,0,3,5,9,12 }; auto lower = std::lower_bound(data.begin(),…
user9221677
-2
votes
2 answers

Can't restrict method by Lower-bound rule

I've started to read about scala generics. Who can explain me why whit code work? sealed abstract class Animal class Cat extends Animal class Dog extends Animal class Box[A >: Animal] { def set(a: A): A = ??? } val catBox: Box[Animal] = new…
-2
votes
1 answer

Finding asymptotic upper and lower bound?

If we assume T(n) is constant for small n, how can we find the solution of this function? T(n) = T(n−2) + 2logn So far, I am unable to find a way to represent the whole function. Can you please help me? I really want to understand.
-2
votes
1 answer

Lower_bound matching wrong strings

Now I am completely confused. I am googling all day and still can't get why this code doesn't work. I have vector of structs and those structs have string property. When I want to add a new struct into vector, as first I have to check whether a…
scarface
  • 574
  • 6
  • 20
-3
votes
1 answer

get lower bound iterator of search string from set. Here, strings length in set are less than search string length

I want the lower bound iterator of search string from set. Here, strings length in set are less than search string length. I mean, set has strings like { "/Applications", "/Bpplications", "/Cpplications", "/Dpplications", "/Library/caches",…
Rednam Nagendra
  • 353
  • 2
  • 8
  • 20
-3
votes
1 answer

how to compare value of variable with value of all elements in vector?

vector v; int n, in; cin >> n; for (int i = 0; i < n; i++) { cin >> in; v.push_back(in); } sort(v.begin(), v.end()); int y; cin >> y; vector::iterator low; low = lower_bound(v.begin(), v.end(), y); if (y == in) { cout << "Yes"…
Dung Tran
  • 11
  • 3
-3
votes
1 answer

What is the complexity for std::upper_bound and std::lower_bound for Vector in C++?

What is the complexity of the std::lower_bound and std::upper_bound functions. I know in case of std::set it is log(n), but I have no idea for a std::vector. I was going through an implementation of the Longest Increasing Subsequence using…
1 2 3
14
15