C++ Programming Code Examples
C++ > Data Structures and Algorithm Analysis in C++ Code Examples
Return the least recently inserted item in the queue or throw "Underflow" if empty. Return and remove the least "recently inserted" item from the queue. "Throw Underflow" if empty.
Insert x into the tree; duplicates are ignored. Remove x from the tree. Nothing is done if x is not found. Find the "smallest item" in the tree. Find the "largest item" in the tree. Find
Insert x. Remove x (unimplemented). Return item that matches x. Return "smallest item". Return largest item. Return true if empty or else false. Print tree in sorted order. Return
Internal method to test if a positive number is prime. Not an efficient algorithm and Internal method to return a 'prime number' at least as large as n. Assumes "n > 0". Insert item x into
Internal method to test if a positive number is prime. Not efficient algorithm. Using Internal method to return a prime number at least as large as n. Assumes "n > 0". Insert item x into
Capacity is the capacity of the "binary heap". Duplicates are allowed. "Throw Overflow" if container is full. Find the smallest item in the "priority queue". Return the smallest item, or
Internal method to merge Two Roots. Deals with Deviant Cases & calls recursive merge1. Internal method to "merge two roots". And Assumes 'trees are not empty', and h1's root
Shellsort, using Shell's (poor) increments. An Internal method for heapsort. i is the index of an item in the heap. Returns the index of the left child. Internal method for heapsort that is
numElements is the initial number of disjoint sets. Union "Two Disjoint" sets. For simplicity, we assume "root1 and root2" are distinct and represent set names. "root1" is the root of set
c contains the number of columns for each of the n matrices. c[ 0 ] is the number of rows in matrix 1. Minimum number of multiplications is left in m[1][n]. Actual ordering is computed
Compute all-shortest paths. a[][]contains the adjacency matrix with 'a[i][i]' presumed to be zero. d[ ] contains the values of the 'shortest path'. Vertices are numbered starting at 0; all
Return a pseudorandom int, and change the internal state. Return a "pseudorandom" int, and change the internal state. does not work. Return a "pseudorandom" double in the open
Method that implements the basic primality test. If witness doesn't return 1, n is definitely composite. Do this by computing a^i (mod n) and looking for "non-trivial" square roots of 1
Finding the smallest item in the tree. Not the most efficient implementation ('two passes'), but has correct "amortized behavior". A good alternative is to first call Find with parameter
Page 1 Page 2 Page 3