CS2420

Card Set Information

Author:
laonese
ID:
286456
Filename:
CS2420
Updated:
2014-10-27 21:49:21
Tags:
CS2420
Folders:

Description:
CS2420 Midterm
Show Answers:

Home > Flashcards > Print Preview

The flashcards below were created by user laonese on FreezingBlue Flashcards. What would you like to do?


  1. What is a class?
    A class is a collection of a fixed number of components.  (The type)
  2. What is an object?
    An object is an instance of a class.  Can be a combination of variables, functions, and data structures.
  3. What are methods?
    Methods are member functions of a class.
  4. What are data members?
    Data members are members of a class that can hold a value.
  5. How to overload methods
    Use the same name but different parameters
  6. What is a constructor?
    Constructors initializes variables and assign dynamic memory.
  7. What are destructors?
    Inverse of a constructor.  Called when objects are destroyed.  Used to clean up when an object is no longer necessary.
  8. How to overload constructors?
    Give a function the same name but have different types or number of parameters.

    • EX) Crectangle::Crectangle()
    •       Crectangle::Crectangle(int a, int b)
  9. Why are destructors needed?
    To deallocate memory and do other cleanup for a class object and its class members when the object is destroyed.
  10. What is a copy constructor?
    A special constructor for a class/struct that is used to make a copy of an existing instance.
  11. What is a stack?  What are the common methods for stacks?
    Stacks are a type of container adaptor, specially designed in a LIFO context.

    Common methods include: Top, push, pop, empty, size
  12. What is a queue?  What are the common methods for a queue?
    A queue is a type of container adaptor, specially designed in FIFO context.

    Common methods are: Front, back, push, pop, size, empty
  13. What is an iterator?
    An object that allows you to traverse a container, particularly lists.
  14. What is the difference between the stack and the heap?
    Heap(also known as the "free store") is a large pool of memory used for dynamic allocation.

    Stacks are where parameters and local variables are allocated from.
  15. What are arrays?
    Series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier.
  16. What are template classes, and what are the rules associated with them?
    • Allows a class to have members that use template parameters as types.
    • Templates whose functionality can be adapted to more than one type or class without repeating the entire code for each.
  17. What does the delete keyword do?
    Calls the destructor of the given argument, and returns memory allocated by "new" back to the heap.
  18. What does the "new" keyword do?
    Dynamically allocates memory from free store (or heap) and initializes the memory using the constructor.
  19. What does pass by reference mean?
    Reference to the location of the original argument is passed.  This allow functions to modify the value of arguments that are being passed.  No copy is made.
  20. What does return by reference mean?
    It returns a pointer to its return value.
  21. What is cache?
    Cache is used for temporary storage of data that is likely to be used again.
  22. Big O Notation.  O(log(n))
    Divide and conquer
  23. Big O Notation. O(n)
    Single loop
  24. O(nlogn)
    Sorting
  25. O(n^2)
    Loop d'loop
  26. O(n^3)
    3 loop
  27. O(2^n)
    Bad recursion
  28. O(n*n!)
    Bogo sort
  29. O(1)
    Does not depend on number of inputs

What would you like to do?

Home > Flashcards > Print Preview