• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/11

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

11 Cards in this Set

  • Front
  • Back



Declare arrays


Classes

int someArray[5];




classes have public, private, constructor, etc.

Constructor and Destructor

Only initialize values in the constructor


Triangle triangle; if no arguments


Triangle triangle(5); if arguments


Rectangle someRect = new Rectangle();


int* someArray = new int [n];




Destructor:


called naturally unless you allocate memory. then you call delete object or for an array, delete[] someArray

Terminal Commands

g++ -c compile but don't link. output is a .o file




g++ -o test test.o test2.o link the files together in one output file named test

Strings

char greeting[] = "Hello";

Big Omega Big Theta formal definition

f(x) <= cg(x) for all x > k




cg(x) <= f(x) <= dg(x) for all x > k

Binary tree: proper, perfect, complete

proper/full binary tree: each node has 0 or 2 children




perfect binary tree: all have 2 children 2^h-1 nodes




complete: every node except maybe some in the last row is filled. all nodes are at the left. bottom level can have between 1 and 2^h nodes

Heap Invariants

Shape: If there is a node at depth h, then every possible node of depth h–1 exists along with every possible node to the left of depth h




Order: For each node n, the priority of n is no higher than the priority of n's parent

implementing heap with array

children are indices 2i+1 and 2i+2




parent is index (i/2)-1

Make Heap

get arrayfrom floor(n/2)-1 to 0, do trickle down.




this number is the bottom rightmost internal node of a heap.

B Tree General

keys in root: 1 to m-1


keys in other nodes: (m/2)-1 to m-1


if node has k keys, it has either k+1 children or 0


all leaves are same depth


branching factor: number of children at each node

Hashing

load factor: number of keys / number of buckets


also average length of linked list




Seperate Chaining




Open Addressing:


hi(x) = (hash(x) + f(i) mod Tablesize




i starts at 0. f(i) = 0