Vector Flashcards
How do you implement In order traversal?
Base case: check if node is null. Recursion through all left subtree, print the node, then recursion through right subtree.
How to initialize an empty std::vector in c++?
std::vector<int> vect;</int>
How to add a value to a std::vector in c++?
vect.push_back(x);
where x is some value.
How to initialize a std::vector with initial values in c++?
std::vector<int> vect{10, 20, 30};</int>
What is a quick way to loop through all items in a std::vector using a for loop and : ?
for (int x : vect)
cout «_space;x «_space;” “;
where int is the type of vector.
How to create a std::vector with size n and all initialized to the same value?
std::vector<int> vect(n, value) ;</int>
What are access specifiers in c++?
Keywords that define the accessibility or visibility level of class members.
What is the default access specifier for c++ classes?
By default, class members are private.