Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/binary_search_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace alg {
class BST {
private:
/**
* binary search tree definiton.
* binary search tree definition.
*/
struct treeNode {
KeyT key; // key
Expand Down
2 changes: 1 addition & 1 deletion include/dijkstra.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace alg {
// all vertices
Graph::Adjacent * a;
list_for_each_entry(a, &g.list(), a_node){
dist[a->v.id] = LARGE_NUMBER; // set inital distance to each vertex to a large number
dist[a->v.id] = LARGE_NUMBER; // set initial distance to each vertex to a large number
(*previous)[a->v.id] = UNDEFINED; // clear path to UNDEFINED
visited[a->v.id] = false; // all vertices are not visited
Q.push(LARGE_NUMBER, a->v.id); // push all vertices to heap
Expand Down
2 changes: 1 addition & 1 deletion include/hash_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace alg {
typedef _HashCode hash_code_fn;
private:
/**
* definiton of Key-Value pair.
* definition of Key-Value pair.
*/
struct HashKV {
key_type key; // 32-bit key
Expand Down
4 changes: 2 additions & 2 deletions include/merge_sort.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* and right part.
* Example: Say the input is -10 32 45 -78 91 1 0 -16 then the left part will be
* -10 32 45 -78 and the right part will be 91 1 0 6.
* (2) Sort Each of them seperately. Note that here sort does not mean to sort it using some other
* method. We already wrote fucntion to sort it. Use the same.
* (2) Sort Each of them separately. Note that here sort does not mean to sort it using some other
* method. We already wrote function to sort it. Use the same.
* (3) Then merge the two sorted parts.
*
* ------------
Expand Down
2 changes: 1 addition & 1 deletion include/priority_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace alg {
list_add(&n->node, &m_head);
m_count++;
} else {
// sequentially find the apropriate position
// sequentially find the appropriate position
PQNode * pos;
bool found = false;
list_for_each_entry(pos, &m_head, node) {
Expand Down
2 changes: 1 addition & 1 deletion include/skiplist.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace alg {
if(x == NULL || x->key != key) {
int lvl = random_level(); // random promotion

// for nodes higer than current max level
// for nodes higher than current max level
// make 'header node' as it's prev
if(lvl > m_level) {
for(int i = m_level + 1; i <= lvl; i++) {
Expand Down
6 changes: 3 additions & 3 deletions include/suffix_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SuffixTree
SuffixTree(string str):test_str(str), root(test_str), active_point(&root, 0, 0), remainder(0), pos(0), active_e(0), ls() {}
int construct(void);

// return -1 if no such sub exist, return the beginning postion of this substring in thr original string if it exist
// return -1 if no such sub exist, return the beginning position of this substring in thr original string if it exist
int search(string sub);

// return the length of the longest prefix of sub which can be matched in suffix tree
Expand Down Expand Up @@ -257,7 +257,7 @@ class SuffixTree
int remainder;
// how many characters inserted?
unsigned int pos;
unsigned int active_e; // the beginnig position of suffixes need to be inserted
unsigned int active_e; // the beginning position of suffixes need to be inserted
char get_ele(int i) { return test_str[i]; }
// insert a char from pos to suffix tree
int insert();
Expand All @@ -266,7 +266,7 @@ class SuffixTree
int print_node(Node* node, int level);


Node* seperate_edge(Node * node, Edge* edge);
Node* separate_edge(Node * node, Edge* edge);

// check if we can change active node
bool check_active_node(void)
Expand Down
2 changes: 1 addition & 1 deletion include/universal_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace alg {
}

/**
* hash an arbitary length integer.
* hash an arbitrary length integer.
* len, number of 32-bit integer, max len is 32
*/
static uint32_t uhash_bigint(const struct UHash * params, uint32_t * key, uint32_t len) {
Expand Down
6 changes: 3 additions & 3 deletions src/suffix_tree_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int SuffixTree::construct(void)
ls.ins_link(node);
break;
}
Node *newnode = seperate_edge(node, a_edge);
Node *newnode = separate_edge(node, a_edge);
Edge* newedge = new Edge(pos, numeric_limits<unsigned int>::max(), test_str);
newnode->add_edge(newedge);
ls.ins_link(newnode);
Expand All @@ -106,7 +106,7 @@ int SuffixTree::construct(void)

SuffixTree::Node* SuffixTree::seperate_edge(Node * node, Edge* a_edge)
{
cout << "seperate the old edge here: " << (*a_edge) << endl;
cout << "separate the old edge here: " << (*a_edge) << endl;
int new_begin = a_edge->begin + get_active_length();
int new_end = a_edge->end;

Expand Down Expand Up @@ -175,7 +175,7 @@ using namespace std;

int main()
{
cout << "Begining" << endl;
cout << "Beginning" << endl;
SuffixTree st("mississippi");

cout << "Constructing..." << endl;
Expand Down