Questions tagged [vectors]
Vectors are sequence containers representing arrays that can change in size. For questions about geometric or algebraic vectors, use [coordinate-system] instead.
315 questions
7votes
2answers
112views
ADT vector in C++
I have created a vector ADT, and this is a brief code for all of you. I will further add some more methods in it. Kindly review my below code: ...
6votes
1answer
296views
C++ static vector revised implementation
This is a revised and expanded implementation of the original static_vector implementation based on the various suggestions and corrections from the kind people who reviewed the original version.The ...
12votes
4answers
2kviews
C++ static vector implementation
This is my custom static vector implementation similar to Boost’s StaticVector. Basically the idea is that the container should have a fixed compile time capacity, ...
3votes
1answer
352views
First dynamic array in C
I am new to C and have been learning it for about a month now. This is my attempt to implement a dynamic array. My code works, but i don't know whether or not it leaks memory. But my code works as I ...
1vote
1answer
109views
Bit vector in Java supporting O(1) rank() and O(log n) select() - follow-up
(This post is the continuation of Bit vector in Java supporting O(1) rank() and O(log n) select(). It resides here (version 1.0.1).) Basically, I have implemented everything harold suggested, except ...
2votes
3answers
127views
A dynamic array with an iterator compatible with std::sort
I wrote a Vector (dynamic array) class with an iterator usable with std::sort() . It seems to pass my tests. I wondering about the issues one can spot on this ...
1vote
1answer
165views
Bit vector in Java supporting O(1) rank() and O(log n) select()
Introduction I have this GitHub repository (version 1.0.0.). It implements a rank(i) operation in \$\Theta(1)\$ time, and ...
13votes
5answers
3kviews
Dynamic array of int in C
This is my first C program I just wrote in like 30 minutes and I was wondering if you could give me any pointers on ways to improve this. I'm decent at programming (around 5 years experience), but ...
1vote
1answer
214views
Positive Segments
I'm trying to solve the following question: You have an array A of size n, containing −1 or 1 only, and s segments (not necessarily different). Each segment is defined by 2 integers li and ri (1 ≤ li ...
-2votes
1answer
60views
Market Portfolio Binary Search Tree [closed]
I'm trying to solve the following problem here: First line of input contains the number of days D. The next d lines contains a character c and a number x. If c is B, then buy stock . If c is S, then ...
4votes
2answers
596views
O(nlogn) Lexicographically minimal rotation code but tle on this particular case
Based on a small suggestion here , this code tries to find lexicographically minimal rotation (question) by successively comparing two adjacent substrings in the very left , that can potentially give ...
4votes
1answer
182views
C++ custom vector class implementation
I've developed a custom vector class in C++, complete with functionalities like assignment, push_back(), emplace_back(), pop_back(), clear(), and size(). I would greatly appreciate any feedback on ...
8votes
2answers
407views
C++ std::vector Implementation
Implementation of the vector class in C++ for learning purposes. Tried to implement interesting parts from the API shown on cppreference.com, but some elements like ...
4votes
1answer
622views
C23 Vector Macro Implementation
I'm trying to implement a simple type-generic Vector with macros using the newest features of C23. Looking for any advice about macro design and pitfalls because I generally avoid macros at all costs. ...
1vote
2answers
67views
Implementing a function that takes in 2 collections of strings and compares them as if they are unordered in Rust
I'm new to Rust and I would like to implement a function to compare 2 collections of strings. The function should compare them as if they are unordered. In Python, I would implement something like ...