
Learning C++ at Summer School:
5 Assignments
1 essay
10 days of lectures
About
The C++ course spanned two weeks and encompassed a total of six assignments, which included an essay on a topic of personal choice. The course presented itself as notably more demanding than I initially anticipated. It delved into various complex concepts and the underlying philosophy of C++, all while necessitating the creation of intricate programs within a short span of time. Although I had some prior exposure to C++, my previous interactions had not delved deeply into its intricacies. As a result, I encountered challenges that pushed me to my limits. Despite these difficulties, I persevered and successfully completed all of the assignments. In the sections that follow, I provide an overview of each assignment and my experience in tackling it. If you're interested in delving deeper, you can access the downloadable code and assignments I did.
Assignment 1
Assignment 2
Assignment 3
Assignment 4
Assignment 5
Assignment 6
- Assignment 1: Tool Chain
This first assignment was a simple start to course and required a 'hello world' program with a few experiments. It was a warm start to the course which I liked.
- Assignment 2: Measurment
I was required to conduct microbenchmarks for simple linear search algorithms on various scenarios using the std::find() and std::find_if() functions. I enjoyed the process of implementing and running these algorithms and observing their run times. It's satisfying to see my code work effectively and produce accurate results within reasonable timeframes. The use of standard library functions like std::find() and std::find_if() greatly simplifies the process of implementing search algorithms.
- Assignment 3: Concurrency
I implemented the find_all() algorithm, which identifies elements meeting specific criteria and returns their pointers in a vector. Evaluating its performance, I timed its execution on both large vectorand vector datasets. Additionally, I developed a parallel version by employing 10 threads to concurrently run the find_all() operation on distinct segments of the data. I enjoyed this assignment as I was able to see the effectiveness of thread-based parallelism in data.
- Assignment 4: List vs Vector
This assignment was a significant challenge that required me to implement and compare different data structures in terms of performance. The task involved generating a sequence of distinct random integers and inserting them in their proper order, then gradually removing elements from random positions. I conducted experiments using std::list, std::vector, and std::set (tree structure) to observe their performance differences. This undertaking was quite time-consuming, as gathering data for different numbers of elements took up to 10 minutes per iteration. Nonetheless, it was fascinating to find how each data structure exhibited distinct behaviours and timings. The insights gained from these experiments emphasised the critical role that data structures play in determining the efficiency of various algorithms.
- Assignment 5: Generic Programming
This assignment proved to be quite challenging for me, as working with matrices required careful consideration of various operations and generic implementations. I started by defining a 2D matrix of ints, Imatrix, which included default construction, assignment operators, subscripting capabilities, arithmetic operations (+, *, /, -, %), and specialised functions like Move, Row, and Column. I took care to ensure that the matrix didn't leak memory and handled exceptions for range errors. In the second part of the assignment, I generalised the matrix to take an element type T as a parameter. While implementing these functionalities, I encountered difficulties in managing generic types and ensuring proper behaviour for each operation. I tested the implementations with Matrix, Matrix , and Matrix , the latter of which required further adjustments due to the nature of the Chess_piece type.
- Assignment 6: Essay
For my personal choice essay on the topic of C++, I decided to conduct a comprehensive comparison between elements of C++, Python, and Java. The objective was to discern the strengths and weaknesses inherent in each language, potentially determining which one stands out as superior. I delved into various aspects such as language features, paradigms, and application domains to understand the nuanced design choices of these languages. Furthermore, I explored the evolving landscape of coding languages and investigated the feasibility of integrating different languages. This essay proved to be an enlightening experience, offering me insights into the specific contexts where each language excels and allowing me to appreciate the overall utility of C++.