This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef AVL_TREE_H | |
#define AVL_TREE_H | |
#include "dsexceptions.h" | |
#include <algorithm> | |
#include <iostream> | |
using namespace std; | |
template <typename Comparable> | |
class AvlTree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef BINARY_SEARCH_TREE_H | |
#define BINARY_SEARCH_TREE_H | |
#include "dsexceptions.h" | |
#include <algorithm> | |
using namespace std; | |
template <typename Comparable> | |
class BinarySearchTree | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef LIST_H | |
#define LIST_H | |
#include <algorithm> | |
using namespace std; | |
template <typename Object> | |
class List | |
{ | |
private: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef VECTOR_H | |
#define VECTOR_H | |
#include <algorithm> | |
#include <iostream> | |
#include <stdexcept> | |
#include "dsexceptions.h" | |
template <typename Object> | |
class Vector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "IntCell.h" | |
IntCell::IntCell( int initialValue ) : storedValue{ initialValue } | |
{ | |
} | |
int IntCell::read( ) const | |
{ | |
return storedValue; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct node heada, headb; | |
link t, u, x, a = &heada, b; | |
for ( i = 0, t = a; i < N; i++ ) | |
{ | |
t->next = malloc( sizeof *t ); | |
t = t->next; t->next = NULL; | |
t->item = rand() % 1000; | |
} | |
b = &headb; b->next = NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
const int NOT_FOUND = -1; | |
template <typename Comparable> | |
int binarySearch( const vector<Comparable> & a, const Comparable & x ) | |
{ | |
int low = 0, high = a.size( ) - 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int search( int a[], int v, int l, int r ) | |
{ | |
int i; | |
for ( i = l; i <= r; i++ ) | |
if ( v == a[ i ] ) return i; | |
return -1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define N 10000 | |
main() | |
{ | |
int i, j, p, q, id[ N ], sz[ N ]; | |
for ( i = 0; i < N; i++ ) | |
{ | |
id[ i ] = i; sz[ i ] = 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define N 10000 | |
main() | |
{ | |
int i, p, q, t, id[ N ]; | |
for ( i = 0; i < N; i++ ) id[ i ] = i; | |
while ( scanf( "%d %d\n", &p, &q ) == 2 ) | |
{ |