Interesting Uses of STL Algorithms [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I apologize because I know in advance this question may be closed. I know it is not an essentially technical question, but it is one that could be meaningfully answered by experienced c++ programmers.
I am teaching a C++ class for programming students and, naturally, I will be covering the STL algorithms. I was trying to think of examples I could give in lecture that would be really cool applications of STL algorithms that make fairly complicated code really simple. I know some people here have ridiculously more C++ experience than I do so I was wondering if you could think of some interesting/exciting applications of the STL algorithms that could be done via loops and functions, but are really easy and concise using the stl algorithms.
Some of my examples:
Check if palindrome: Made really easy with equals(s.begin(), s.begin() + v.size()/2, s.rbegin())
Tokenize string into vector: Easy with copy(istream_iterator<int>(cin), istream_iterator<>(), back_inserter(data))
Permutations: Classic recursive problem made easy by stl algorithms
Sorting: This one is obvious but also not very interesting (i.e. it's not a cool application of <algorithm> for students)

Related

Is it good to have an idea about the STL before studying Data Structures? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I'm currently self-studying C++ and I'm about to finish my OOP course, till now, I've finished the OOP concepts but the course also includes an introduction to the STL, but I feel like it's too early to have a look on the STL at this stage(before studying Data Structures).
Is it a good idea to skip the last part of the OOP course and start studying Data Structures right now? or should I complete the course anyway?
In my opinion, if you already can understand OOP principles you should use STL and do not care how it really works under the hood, but after that, you should learn basic data structures and all will come clear for you.

Should I learn to use the C++ STL containers instead of building them? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I've learned about data structures and algorithms in my university course and they taught us how to implement them. After reading some answers on SO and Quora, it seems that using the STL containers are recommended.
As a software engineer/developer, you should know how a particular data structure works under the hood. and you should be able to customize/invent one when you need it. that's the reason they thought you so.
But generally you won't need to reinvent the wheel. so when there are tried and tested data structures available, like the std::stack, there's no need to do it again. specially because you'll have more bug issues in your implementation than those of STL or any other well designed one like Boost.
Unless you think you have a better knowledge of software engineering than the designers of the STL - or you have some very specific hardware requirements that they are unaware of

Implementing specialized data structures in modern C++ [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
(Okay, so my previous question is on hold as being too broad, so I'm narrowing it down here.)
I'm looking to take part in algorithmic programming contests, and a lot of problems hinge on the use of specialized data structures which are extremely good at a certain operation - for example, Fenwick trees allow calculation of prefix sums of a list of values in logarithmic time.
What is the preferred way of implementing such data structures in modern C++ (i.e. using C++11 features)? Is it possible to use STL algorithms and containers instead of writing structs and coding every operation by hand?
I'm looking for Fenwick trees, segment trees, treaps and some other data structures often useful in IOI-style contests, but general strategies are more than enough.
there's an implementation of a fenwick tree here: http://www.algorithmist.com/index.php/Fenwick_tree
It uses std::vector as the underlying container.
arguably the method increase could be written in terms of std::transform or std::foreach.

How can I tell if an algorithm is efficient? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Relatively new to C++ but I am very interested in the algorithmic aspect of programming.
Is there a general framework for deciding if an algorithm is efficient? i.e. the quickest possible?
I am trying to write pseudocode on paper before implementing but there are probably many different ways to solve any given problem.
Would be very keen to learn best practice for constructing / analysing algorithms.
Thanks, and Happy New Year!
Yes you can start with the Wikipedia article explaining the Big O notation, which in a nutshell is a way of describing the "efficiency" (upper bound of complexity) of different type of algorithms. Or you can look at an earlier answer where this is explained in simple english

boost vs POCO as for learning curve and suitability for beginners (HTTP client) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
which library would you advise me to use? I don't know any of these libraries.
I heard, that Boost is very often used but also it's hard to code in.
So to make this question as objective as possible:
Just simply from the aspect of beginner programmer (I've coded ~1000 LOC in C++ in my life)
which library would be better to learn?
I'll be using it mainly for HTTP client.
The answer is bound to be subjective but with particular emphasis on for a beginner then I think POCO is clearly the way to go. It actually has some HTTPClient classes and once you get beyond the point of being happy that something works the code is clear enough to follow so that you can dig in and understand why it works if that is where things lead you.
POCO is well written OOP code and does not require much in the way of understanding templates and such. The classes are well integrated with one another, extensive, and the documentation more or less points you to the next (or previous) class that you need. You won't be dashing around 20 separate libs as Boost is likely to have you doing. (There is always time for that later!)