C++ Logo

sg20

Advanced search

Re: [isocpp-sg20] Education references for teaching data structures implementation in C++

From: Neil Horlock <nhorlock_at_[hidden]>
Date: Sat, 30 May 2026 22:23:11 +0100
While I appreciate that Daniel's colleague specifically stated
"implementing basic data structures in C++", I have to wonder whether the
correct answer is to counter that question with another question, "Why?" As
in "Why are we teaching that?" It seems a somewhat dated idea, rooted in
the K&R mindset of "the best way to understand malloc is to write your own".

In my career, I've had (relatively rare) occasions when I've designed
specific data structures, but they've always come from a deeper
understanding of the domain and a specific need (typically low-latency feed
handlers with custom order-book semantics), and even then, they've not
always made sense in retrospect, or have been superseded by an optimised
generic solution, that was ultimately more maintainable. Most students, as
relative newcomers to software engineering would not normally have the
experience to make choices about subtle implementation details that might set
a hand-rolled data structure/class apart from any of the multitude of
containers and related classes libraries out there.

They would probably be better served by being taught how to choose those
from those tried and tested solutions, undserstanding data models at a more
abstract level and what characteristics of the data guide a choice one way
or another and if you need to go deeper still, then the architectural
influences (concurrency vs latency etc) that often constrain the choices
you have and when to worry about matters such as cache and the specifics of
modern processor architecture. Most importantly, realising that
re-inventing a faster/smoother wheel is rarely the right choice.

If a new graduate turned up in your team and proceeded to write a whole new
data structure solution, you'd be failing your team if you didn't ask them
how they decided that was necessary. If they can identify the reasons why
an existing container, be it standard or a 3rd-party custom one, is not fit
for purpose, then I would argue that they have the experience and
understanding to proceed and would likely not benefit from a basic course
in the first place.

There is, of course, a place and time where implementation techniques are
valuable, but I would argue that they lie quite a long way down the road
from when most students are learning about data structures at a basic level.

Neil

On Sat, 30 May 2026, 9:35 pm Bjarne Stroustrup via SG20, <
sg20_at_[hidden]> wrote:

> I think that the ancient sources suggested here demonstrate the need for
> an up-to-date approach.
> On 5/29/2026 12:34 PM, Muneem via SG20 wrote:
>
> Also note that I am 17-18, so some of what I said will be incredibly
> impractical and impossible to teach since I am not on the front lines of
> the industry, nor am I planing to be for a considerable amount of time. I
> still hope that it gives a proper image of what I want to learn and advance
> it, and how many others would naturally want the same.
>
> On Fri, 29 May 2026, 9:02 pm Muneem, <itfllow123_at_[hidden]> wrote:
>
>> I agree that having an implementation as a reference can help. I am new
>> to c++ (1 year in) and it helps me as well, but I also think that having
>> mathematical information around such structures are all useful. The thing
>> about math is that it reassures you of correctness and efficiency,
>> alongside making it easy to reference in your memory.
>>
>> If I were to start from scratch, I would want a teacher/teaching resource
>> that could first teach me the basics (classes and exceptions) then about
>> what each container/data structure is meant for, then exception safeties,
>> an implementation implementating such structures with exception safeties in
>> mind, then the formal math of it, like what does it mean for a ordered
>> map/set to be weakly ordered, and at last, the standard's interface. For me
>> the math and making use of performance gurrenties, with some common sense
>> is important. For example, I want to know when vectors may be impractical
>> enough to not be able to utilize holes in memory.
>>
>> A resource for classes and exceptions, alongside exception safety would
>> be the classic book of Bjarne Stroustrup "The c++ programming language 4th
>> edition". For a more detailed view into each container, you would probably
>> have to write code yourself based on modren features. For performance and
>> how to make use of it, you would again need to show the assembly and how it
>> maps to the CPU usage, for mathematical definitions of certain orderings in
>> order maps/sets, a resource would be:
>> https://eceweb.uwaterloo.ca/~dwharder/aads/Abstract_data_types/ . I
>> sadly haven't found time to read the all of it (though I am planning to),
>> but had to read some parts out of necessity.
>>
>> I don't know what the conference is exactly for but this is my view. Hope
>> it is useful.
>>
>> On Mon, 25 May 2026, 1:59 am Ohlan,Kartik via SG20, <
>> sg20_at_[hidden]> wrote:
>>
>>> I think almost every university uses Introduction to Algorithms(CLRS),
>>> but in my opinion one thing that would make CLRS more appealing to students
>>> is including practical implementations of data structures such as Red-Black
>>> Trees, AVL Trees, and similar concepts and how these are used in real life
>>> like Linux scheduler for example. My only issue with the book is that it is
>>> extremely mathematical.
>>>
>>> Some of my favorite books are Competitive Programming 4 and *Data
>>> Structures and Algorithm Analysis in C++*.
>>>
>>>
>>>
>>> When I studied data structures, my professor strongly emphasized
>>> implementing your own data structures from scratch—for example, recreating
>>> something like LLVM’s small_vector and pushing it until it breaks to truly
>>> understand its behavior.
>>>
>>>
>>>
>>> Best,
>>>
>>> Kartik
>>>
>>>
>>>
>>> *From: *SG20 <sg20-bounces_at_[hidden]> on behalf of Ville
>>> Voutilainen via SG20 <sg20_at_[hidden]>
>>> *Date: *Sunday, May 24, 2026 at 4:47 PM
>>> *To: *sg20_at_[hidden] <sg20_at_[hidden]>
>>> *Cc: *Ville Voutilainen <ville.voutilainen_at_[hidden]>
>>> *Subject: *Re: [isocpp-sg20] Education references for teaching data
>>> structures implementation in C++
>>>
>>> External.
>>>
>>> On Sun, 24 May 2026 at 23:03, Bjarne Stroustrup via SG20
>>> <sg20_at_[hidden]> wrote:
>>> >
>>> >
>>> > On 5/24/2026 3:34 PM, JOSE DANIEL GARCIA SANCHEZ via SG20 wrote:
>>> > > Dear all,
>>> > >
>>> > > I have been asked by a colleague about good teaching references
>>> > > (preferrrably books) for teaching basic implementation of data
>>> > > structures in C++.
>>> > >
>>> > > Any recommendations?
>>> >
>>> > Sorry no. I have never taught datastructures and I'm not up on what
>>> > materials people use for that. From what I have seem from students, I'm
>>> > rather suspicious on the quality of those courses.
>>>
>>> I have no idea either. I've never seen any decent materials for it,
>>> and wouldn't know where to find them.
>>>
>>> Not that I've ever needed to write a custom container, for example,
>>> either.
>>>
>>> I do understand the need for such. Being able to provide
>>> implementations that have various different trade-offs
>>> is certainly useful in all sorts of high-performance scenarios, which
>>> I luckily have never had to deal with. :)
>>>
>>> I wonder how the LLM suggestions of
>>>
>>>
>>> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.amazon.co.uk%2FData-Structures-Algorithm-Analysis-United%2Fdp%2F032144146X&data=05%7C02%7Cko496%40drexel.edu%7C6d19e2ee64cc4cb1676a08deb9d5adf0%7C3664e6fa47bd45a696708c4f080f8ca6%7C0%7C1%7C639152524573967399%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=NquiiWe058c7N6r5CnOQtYz%2B%2BuPUZxAAiFgENo%2Fp7Jw%3D&reserved=0
>>> <https://www.amazon.co.uk/Data-Structures-Algorithm-Analysis-United/dp/032144146X>
>>>
>>> and
>>>
>>>
>>> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.amazon.co.uk%2FProgramming-Program-Design-Including-Structures%2Fdp%2F1133526322&data=05%7C02%7Cko496%40drexel.edu%7C6d19e2ee64cc4cb1676a08deb9d5adf0%7C3664e6fa47bd45a696708c4f080f8ca6%7C0%7C1%7C639152524573985144%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=NJWpt4FGPb9yJJ%2B%2BdAQ0TuKbm1vV7rFkZCvWpgDxQUk%3D&reserved=0
>>> <https://www.amazon.co.uk/Programming-Program-Design-Including-Structures/dp/1133526322>
>>>
>>> and
>>>
>>>
>>> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.amazon.co.uk%2FProblem-Solving-C-Walter-Savitch%2Fdp%2F0134448286&data=05%7C02%7Cko496%40drexel.edu%7C6d19e2ee64cc4cb1676a08deb9d5adf0%7C3664e6fa47bd45a696708c4f080f8ca6%7C0%7C1%7C639152524573997189%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=fgU%2FUIetjg9Ob9gSCz1Z4h0l0tyQR9FY%2F3pJQL9Bj2A%3D&reserved=0
>>> <https://www.amazon.co.uk/Problem-Solving-C-Walter-Savitch/dp/0134448286>
>>>
>>> fare. The middle one is ancient, but I have no idea whether that matters.
>>>
>>> I think the challenge here is to keep the students awake. I don't
>>> think talking about how to implement what std::vector and std::list
>>> do will do that. They would probably stay awake for 10 minutes when
>>> talking about the difference between std::list and std::forward_list,
>>> but something more interesting with a reasonable rationale would be
>>> needed.
>>> --
>>> SG20 mailing list
>>> SG20_at_[hidden]
>>>
>>> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.isocpp.org%2Fmailman%2Flistinfo.cgi%2Fsg20&data=05%7C02%7Cko496%40drexel.edu%7C6d19e2ee64cc4cb1676a08deb9d5adf0%7C3664e6fa47bd45a696708c4f080f8ca6%7C0%7C1%7C639152524574009122%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=A8ZSp6GN2npjscAm%2BBGspUkAR9POReNo%2FHmUmZTqQvQ%3D&reserved=0
>>> <https://lists.isocpp.org/mailman/listinfo.cgi/sg20>
>>> --
>>> SG20 mailing list
>>> SG20_at_[hidden]
>>> https://lists.isocpp.org/mailman/listinfo.cgi/sg20
>>>
>>
> --
> SG20 mailing list
> SG20_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/sg20
>

Received on 2026-05-30 21:23:27