CS 235 Final

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

When is an AVL tree Critically Unbalanced and how do correct the imbalance (page 632)?

When parent balance is -2 or 2 and child balance is -1 or 1

What is tail recursion (page 416)?

Where the recursive call is at the "tail" of the function or near the last line

Know the syntax for valid throw and catch statements.

e.g. throw std::out_of_range("That is out of range");

What is a Huffman tree?

A binary search tree with frequencies of letters in them

What is an abstract class (page 202)?

A class that cannot be instantiated, must have at least one abstract (virtual) member function, serves as template for other classes

What are the reasons for using a template class (page 232)?

A class that stores and processes a collection of information

What is a min heap?

A heap where the root is the smallest value and all of the children are larger than the parent node

What is a "use case"?

A list of user actions and system responses for a particular subproblem

What is a concrete class (page 202)?

An actual class, one that can be instantiated (created with an object)

What is the "this" parameter (page 91)?

An implicit function parameter whose value is a pointer to the object for which the member function was called.

What is the relationship between two classes, A and B, where A declares class B to be A's friend?

B has access to A's private data members

What are the key components of a recursive algorithm?

Base case, Checks for invalid Recursive call

When does a loop invariant need to be true (page 167)?

Before loop execution begins, at the beginning of each repetition of the loop, at the exit of the loop

What cases should you consider when developing test cases (page 114, 152)?

Boundary cases

What are the advantages of exceptions vs error returns (page 138)?

By "throwing an exception," the user gets a chance to "catch" or "handle" the exception and perhaps recover from the error.

What are the advantages of recursion (page 403)?

Can be used to solve a variety of problems that otherwise would be difficult to conceptualize otherwise

What is data abstraction (page 73)?

Data can be allocated and used without being overly concerned with how the data is being stored or represented in memory.

How is throwing an exception different from printing an error and exiting the function (page 138)?

Depends if there is an exception handler or not. If not, they are the same. If so, the user can handle the exception and possibly recover from it.

What are friend classes (page 89)? Be able to look at sample code to determine who has access.

Friend classes can access member functions as well as private data members of the class of which it is friends.

How do you insert nodes into a heap (page 485)?

Insert at the bottom of the heap in the "next" position, and while the new item is not at the root and the new item is larger than its parent, then swap the new item and its parent which moves the item up the heap

If you define a Node as a struct, where would you put its definition (page 255, 667, 673)?

Inside another class, as a sub-class

Why should you use Abstract Data Types (page 98)?

It is reusable code that you can use in a variety of circumstances that can be used for similar purposes.

How is the practice of "information hiding" justified (page 74)?

It makes it easier to change, especially for higher level classes. Hidden information makes it so lower level classes can be regulated differently without having to rewrite all the code above it.

What is a Huffman tree and why would you use it (page 496)?

Like a Binary Search Tree with characters as values sorted by frequency, can be used to decode message

What does including the keyword const in a function header do?

Makes the private data members in the class function unable to be modified

What is a virtual function (page 196)?

Making a function "virtual" enables polymorphism and lets the computer decide at runtime which overloaded function to go into based on the type of the object that is being pointed to, rather than the type of pointer variable.

What is the difference between sets and maps (page 521)?

Maps contain ordered pairs, or a "key" and a "value." Sets are just one value.

How do you determine the next node to insert into a Huffman tree?

Most frequent towards the root, less frequent towards the end

Where does the n term in the O(nlogn) complexity of mergesort (page 593)?

Moving all elements from the input sequence to the input sequence

what is the Big O of a vector insert() function?

O(n)

What is the typical "Big O" of inserting a new value into a linked list?

O(n) if have to traverse, O(1) if has iterator

What is the typical "Big O" of removing a value from a vector?

O(n), fills in spots after removal

What is the typical "Big O" of inserting a new value into a sorted array?

O(n), shifts spots over after insertion

Assume T(n) for a particular function is 0.0003n + 3nlogn + 2n^2 + 300000. What is the "Big O" of this function?

O(n^2), get rid of all constants, look at greatest changing

What is the typical "Big O" of inserting a new value into a binary search tree?

Olog(n)

Given a set of nested loops, determine the Big O notation for the code.

One loop = n Two loops = n^2 Three loops = n^3 etc. Depends on incrementation of i, multiplied is logarithmic

What are the differences between public, private and protected access specifiers (page 78)?

Private: private members can only be accessed by the class or class friends Public: public members can be accessed by all functions outside the class Protected: protected members can be accessed only by the class itself and classes derived from it

What is the Unified Software Life Cycle, and when does testing occur in this model (page 67)?

Requirements, Analysis, Design, Implementation, Testing. Testing happens last.

How do you correct "left right" imbalance on an AVL tree?

Rotate left around the child, then rotate right around the parent

Compare the complexity of inserting at the head or tail of a doubly linked list (page 261)?

Same complexity

How would you implement a balanced binary tree using an array instead of a linked data structure (page 486)?

The first element is the root, second and third are the children, fourth-seventh children of those children...so on

What happens when a function is called but it's preconditions are not met (page 101)?

The function may not operate as intended

What is procedural abstraction (page 73)?

The philosophy that procedure development should separate what is to be achieved by code from the details of how it is to be achieved. Can use in design of code before actually implementing

Where does the logn term in the O(nlogn) complexity of quicksort (page 606)?

The recursive properties of splitting up the array into two different, equal sides

What are the steps to designing a recursive algorithm (page 406)?

There must be one "base case" that is solved directly, split the problem into smaller versions of itself with each recursive case making progress toward the base case, Combine the solutions to the smaller problems in such a way that each larger problem is solved correctly

Show the vector representation of a Heap after insertion (page 487).

Values move up the vector as they move up the heap

What is the difference between sets and vectors (page 517)?

Vectors must specify the location where the item should be inserted, sets do not require this. Vectors can be accessed with subscript, i.e. vector[], but sets cannot be accessed by these

What is a complete binary tree (page 452)?

Has a height h that is filled up to at least h - 1, and at depth h any unfilled nodes are on the right

What is member function overloading (page 194)?

Having two different member functions with the same name but different parameters. Which one is used is determined by what parameters are used when called, situational

Compare the complexity of inserting at the head or tail of a singly linked list (page 258)?

Head = O(1) Tail = O(n)

What data structure would you use to represent a priority queue (page 489)?

Heap

What is the typical "Big O" of removing a value from a doubly linked list?

If no iterator: O(n), traverse dbl linked list to find If iterator: O(1), can use prev to reassign

What is the typical "Big O" of removing a value from a singly linked list?

If no iterator: O(n), traverse linked list to find If iterator: O(n), traverse linked list to find prev

How does an iterator work (page 264)?

Sets a spot as a virtual "marker," can be used to keep track of position in a linked list, can be advanced forward

What is the difference between making a shallow copy or a deep copy in a copy constructor (page 247)?

Shallow copy- Just copies the values, not memory locations Deep copy- copies values as well as memory locations and is a completely independent, new copy

How do you decide what you should use for a key in a map?

Something that can be useful when "mapping" to a specific value

In what order should catch clauses be listed (general to specific or specific to general)?

Specific to general

What data structure would you use to determine if parentheses are balanced?

Stack

What data structure would you use to evaluate a postfix expression?

Stack

What are the relationships between stacks, deques, and queues?

Stacks= LIFO Queues= FIFO Deques= Both sides can be taken out


संबंधित स्टडी सेट्स

Chapter 10: Drug Therapy for Dyslipidemia

View Set

Human Anatomy and Physiology Chapter 8: Joints

View Set

Pharmacology- Medical surgical EAQ

View Set

EASA Part 66 : Mathematics Question4

View Set