4 ms·
Data structure and algorithms problems in C++
- maccam912 9y agoAre these from somewhere? I might try to recreate this in Rust as a way to learn more of that language.
- steveklabnik 9y agoJust to caution you, data structures aren't a great way to learn Rust. See this recent discussion, for example: https://news.ycombinator.com/item?id=16072630 https://news.ycombinator.com/item?id=16072630 Algorithms are fine, though.
- mandliya 9y agoThese are from bunch of resources, CTCI, Leetcode, Geeksforgeeks and some from interview questions asked to me/friends/found on internet. I will update sources in the repo for the ones I remember.
- neosavvy 9y agoSick job, that's nearly 4 years of hard work there.
- brian-armstrong 9y agoThe bit twiddling in this looks fairly naive/slow. There's some really great, fantastically fast methods in https://graphics.stanford.edu/~seander/bithacks.html https://graphics.stanford.edu/~seander/bithacks.html that require some interesting insights in finite fields. These are usually the sorts of techniques you'd want to turn to for bit twiddles
- DominikD 9y agoSome of the solutions are not safe (and should be indicated as such). For example MIN/MAX in generic.h are macros so shouldn't be used with functions (and mustn't be used with functions that have side-effects). Macro parameters aren't bracketed either so operator precedence can bite there too. There's also potential for undefined or implementation-defined behavior (e.g. multiply_by_7() is left shifting signed int). Author's heart is in the right place it's just that his skills aren't necessarily up to the task, I'm afraid.
- mandliya 9y agoedit: Spellings. Thank you for the feedback. Some of the programs here are coded 4 years ago, when I had just started learning C++ and I never revisited them. At that time, I was in university, and this repo was to attract recruiters for internship. I got the job later, and kind of ignored to correct problems. I am sure if these are ran with strict compiler flags there would be many more issues. I will get around and fix it sometime soon.
- DominikD 9y agoSure thing, reading through the repo I understood it was used to learn stuff. But it may not be immediately understood by a novice. And thing with the Internet is: people will start using code from your repo and get into all sorts of issues. It's unlikely you'll smooth this code up. Nobody's got the time, let's be honest here. ;) So I'd recommend that you at least state explicitly that these functions shouldn't be lifted directly unless someone knows what he/she is doing.
- mandliya 9y agoThanks again for the response, I understand it might be better to put a warning note at the top of readme. Thank you again for the advice.