Course topics 5, 6 and 7

Self-study (english videos and slides)

The topic for this week is the C++ Standard Template Library (STL)

The following links will take you to the video-lectures and the accompanying slides:

Standard Template Library (STL)

slides for Standard Template Library (STL)

Note The STL container performance video uses a table entitled Choosing container based on performance. There are some mistakes in the version of this table presented in the video. However, a corrected version of this table is given in the file containing the slides.

Week05 - Glossary

The STL can be divided into three parts. What are they?
What information does the STL documentation contain regarding the runtime efficiency of most STL algorithms?
For a C++ programmer it is important to know how to use the STL because
The two main types of STL containers are sequences and associative containers. What are the main features of sequence containers? (There may be more than 1 correct statement.)
For an associative container,
With regard to the appropriate choice of associative container, which of the following statements are correct? (There may be more than 1 correct statement.)
Let \(X\) be an STL container and \(Op1\) be some basic operation (example search for a value). It is possible that STL does not have a function that does \(Op1\) for \(X\). There are two reasons for this. One reason is that doing \(Op1\) for \(X\) is either impossible or it makes no sense. What is the other reason?
For which of the following cases does STL provide a function having a constant runtime efficiency? (There may be more than 1 correct case.)
When trying to write code that runs efficiently, a programmer should choose containers so that
Regarding iterators in STL, which of the following statements are true? (More than one statement may be true.)
Suppose \(i1\) and \(i2\) are iterators for some sequence container. If \(i2 < i1\) is true, which of the following is correct?
Suppose \(i1\) and \(i2\) are iterators from two different categories. Which of the following is correct?
Regarding iterator categories, which of the following statement are true? (More than one may be true.)
What is a central question, related to this course, whose answer can be found in this week’s videos?
Of the following topics, which do you think deserves further discussion/explanation during the weekly consultation session?
Were there any parts of the video lectures that were particularly difficult? Particularly interesting? Something about which you wish to learn more?

Extra links on the topic:

Week05 - Glossary

Viikko05 - Sanasto

Submit weekly exercises

Questions to be submitted this week

Week 6 of the course

Self-study

The topics for this week are the following: (i) STL algorithms (ii) Lambda functions and (iii) Tuning STL algorithms and containers

The following links will take you to the video-lectures and the accompanying slides:

STL algorithms

Suppose one has some STL container in variable \(A\) and one wishes to input \(A\) into an STL algorithm \(X\). What parameter (or parameters) would one input to \(X\) to indicate that one wishes \(X\) to use the entire container \(A\)?
For what reasons is it better to use algorithms from the STL library to compute some task rather than writing your own algorithms for computing the task? (There may be more than 1 correct reason.)

STL algorithms - examples

Suppose begin and end are two iterators associated with vector v. Suppose the location to the right of begin is \(i\) and the location to the right of end is \(j\). What is the significance of the difference end - begin?
Which of the following is true about the STL algorithsm?

Lambda functions

Suppose in C++ one has a vector std::vector<int> v{6, 3, 4, 9, 2, 7, 1, 11};. Which of the following will result in *it having a value of 2?
Regarding lambda functions, which of the following statements are true? (More than 1 may be true.)
Suppose in C++ one has a vector std::vector<int> v{-19, 21, -4, 6};. What will be the value of *it when the following is executed?:: auto it = std::find_if(begin(v), end(v), [](int i){ return (i%2 != 0 && i >0); });

Lambda functions and variable captures

When we say a lambda function captures a variable we mean
Suppose in C++ one has a vector v of integers and d is some nonzero integer. What will be the value of a when the following is executed?:: int a = std::count_if(v.begin(), v.end(), [d](int i){return (i % d != 0 && i*d > 0 );});

Tuning STL algorithms and containers

Which of the following statements, regarding tuning of STL algorithms, is true? (More than one statement may be true.)
The STL contains algorithms named count_if, find_if and remove_if. Which of the following properties do all these algorithms have?
What is a central question, related to this course, whose answer can be found in this week’s videos?
Of the following topics, which do you think deserves further discussion/explanation during the weekly consultation session?
Were there any parts of the video lectures that were particularly difficult? Particularly interesting? Something about which you wish to learn more?

Extra links on the topic:

Week06 - Glossary

Homework to be returned for the weekly exercises

Questions to be submitted this week

Posting submission...