Logo
  • Home(current)
  • Code(current)
  • About(current)

Explore

Different Categories

C

Definitions

C

Code Sample

C

Sorts

C

Binary Tree

#Definitions

Variable

C C++ Java

A named location in memory.

Recursion

C C++ Java

A function that calls itself.

Valid Identifier

C C++ Java
  1. Only allowed to start with letters & underscores.
  2. It can have as many letters & underscores
  3. Cannot be a keyword( ex: return)

c-string

C C++

A null-terminated character array.

Expression

A term or series of terms separated by operators that evaluate to a single value and that value has a type.

Short Circuit Evaluation

C C++ Java

In a boolean expression if C can determine the value based on the first term, it will stop there. For example in an OR expression, it evaluates as true if the first term is true. In a AND it will evaluate the whole expression as false if the first term is false.

Pre-increment (++x)

It evaluates before the function is executed x. The value of x is incremented.

post-increment (x++)

It evaluates after the function is executed. A copy of the value of x is recorded before we change it and increment .

Pointer

C C++

A variable that stores the memory address of another variable. Pointers are indicated by * (dereferecing operator)

Cast to the known type

Gives context so the program knows the type

Free

Function that takes a pointer to the space in memory that has been allocated and it will deallocate memory.

Casting

Tells the compiler to interpret the memory with a different context.

Struct

C C++

User-defined data type. You can create variables out of that data type.

Vector

A dynamic array. It has size, capacity and data( a data pointer to the array).

Constructor

C++ Java

A constructor is a member function of a class that is called automatically when an object of the class is declared. A constructor must have the same name as the class of which it is a member.

Destructor

C++ Java

A destructor is a special kind of member function for a class. A destructor is called automatically when an object of the class passes out of scope. The main reason for destructors is to return memory to the freestore manager so the memory can be reused.

Copy Constructor

C++ Java

A copy constructor is a constructor that has a single argument that is of the same type as the class. If you define a copy constructor, it will be called automatically whenever a function returns a value of the class type and whenever an argument is plugged in for a call-by-value parameter of the class type. Any class that uses pointers and the operator new should have a copy constructor.

Acessor Function

C++

An accessor function allows access to private data members in C++. It does not modify the data, it only accesses it.

  1. An accessor doesn't need arguments
  2. An accessor has the same type as the retrieved variable
  3. The name of the accessor begins with the get prefix

Mutator function

C++

Modifies a protected data member.

  1. It does not return anything(void)
  2. It needs an argument
  3. The name of the mutator begins with the set prefix

Overloading

C++

When a function has the same name, but different numbers or types of parameters(signature).

Class Level Definitions

C++ Java

private : Hidden from the user. When the programmer labels data members "private," they cannot be accessed and manipulated by member functions of other classes. Accessors allow access to these private data members.

public : The user has access to it.

Member : The member functions have special access to the data of their object.

The Rule of Five

C++

If you have an object that is dynamically allocated and you need to manage the data.

Hello World

Reverse String

Bubble Sort

Starting at the beginning of a list, compare adjacent pair of elements if the pair is out of order swap them, do it n-1 times.

Selection Sort

Sorts the list by repeatedly finding the smallest element from the list starting at i, sort into the i position, do this for all except for the last and putting at the beginning. Remember where the smallest is, then you swap it. Where I starts at 0.

Heap Sort

Heapify the array, remove the max n-1 times. Heapify means call fix down at every node of the tree starting at the back of the array ignoring leaf nodes( Nodes that don’t have children).

Insertion Sort

Using index-1 of an unsorted list as a starting point, increment the starting point through the list insertion each element into its proper location relative to the numbers preceding the starting point.

Shell Sort

Do insertion sort on the list, except comparing elements that are one away, compare elements that are h away.

Binary Tree

Everything in the left subtree is smaller than everything in the right subtree.

Full Tree

A tree in which every node other than the leaves has two children.

Ex:

Complete Tree

The children has all the children that it can have.

Tree Traversal

Trees can be traversed in 3 different ways:

  1. Pre-order (S L R)
  2. used to copy the tree
  3. In-order (L S R)
  4. used to iterate the tree
  5. Post-order (L R S)
  6. used to destroy the tree