# Data Structures and Algorithms Definitions and Questions Ch.1

Home > Preview

The flashcards below were created by user TKujawa on FreezingBlue Flashcards.

1. What is (one of the many) problems with the built-in C++ array class?
Objects that belong to this class do not behavior like first-class objects.
2. How do you instantiate a vector array of strings and fill it with values?
• 1) vector<string> samp(SIZE); samp[0] = STRING;
• 2) vector<string> samp{"STRING", STRING, STRING, ETC...}
3. What is a range for-loop? How do you write one? and which version of C++ supports it?
• a) A loop that will iterate over a collection sequentially.
• b) for(auto x : COLLECTION)
• c) C++11
4. What does the reserved word: 'auto' tell the compiler?
Automatically infer the appropriate data type. NOTE: useful for templates.
5. What is a pointer variable?
A variable that stores the address of a location in memory.
6. How are pointer variables used in linked lists?
Each node in a linked list contains a link to the next object in the collection; the link is a pointer variable.
7. What does a variable declared with an '*' denote? Ex: string *m;
This variable is a pointer variable: the value of m is the address of the object that it points at.
8. What is the keyword used to perform garbage collection in C++?
• 'delete' as in:
• int *m;
• delete m;
9. What is a memory leak?
When an object is no longer referenced and the memory it consumed is lost. Garbage collection is used to address this problem.
10. When are two pointer variables equal?
When they point to the same object.
11. What does a variable preceeded by '&' denote? What does this opperator do?
The operator returns the memory location where the object resides.
12. What is an lvalue? What are some examples?
An lvalue is an expression that identifies a non-temporary object. If a variable has a name than it is an lvalue (i.e inĀ  'm = 2' m is an lvalue).
13. What is an rvalue?
An expression that identifies a temporary object or a value not associated with an object.
14. What is an lvalue reference? How is it declared?
• a) An alias for another object.
• b) By putting an '&' after the datatype in a declaration. string str = "george clinton"; string & clonesOfFunkenstein = str;
15. How is an rvalue reference declared?
By placing a '&&' after a datatype.
16. Name three common uses for lvalue reference.
• 1) Alias complicated names.
• 2) Range for-loops (specifically making changes to the elements of the collection).
• 3) Avoiding a memory-intensive or needless copy.
17. What are functions that belong to a class called?
Member functions or methods.

### Card Set Information

 Author: TKujawa ID: 257605 Filename: Data Structures and Algorithms Definitions and Questions Ch.1 Updated: 2014-01-22 20:32:50 Tags: Algorithms Folders: Data Structures Description: Definitions from the first chapter of "Data Structures and Algorithms". Show Answers:

What would you like to do?

Home > Flashcards > Print Preview