Changes

From Genome Analysis Wiki
Jump to navigationJump to search
no edit summary
Line 51: Line 51:  
* Problem Set 1 : Due on January 20th, 2011 -- [[Media:Biostat615-homework1.pdf | (Problem Set 1 - PDF)]]
 
* Problem Set 1 : Due on January 20th, 2011 -- [[Media:Biostat615-homework1.pdf | (Problem Set 1 - PDF)]]
 
* Problem Set 2 : Due on February 2nd, 2011 -- [[Media:Biostat615-homework1.pdf | (Problem Set 2 - PDF)]]
 
* Problem Set 2 : Due on February 2nd, 2011 -- [[Media:Biostat615-homework1.pdf | (Problem Set 2 - PDF)]]
** [[Media:Shuf-1M.txt.gz| (Example data - shuf-1M.txt.gz)]]
+
** [[Media:Shuf-1M.txt.gz| (Example data - shuf-1M.txt.gz)]] 1,000,000 randomly shuffled data (gzipped)
 +
** [[Media:Rand-1M-3digits.txt.gz| (Example data - Rand-1M-3digits.txt.gz)]] 1,000,000 random data from 1 to 1,000]] (gzipped)
 +
** [[Media:Rand-50k.txt.gz | (Example data - Rand-50k.txt.gz)]] 50,000 random data from 1 to 1,000,000)]] (gzippd)
 +
** Source code from Problem 3
 +
#include <iostream>
 +
#include <vector>
 +
#include <ctime>
 +
#include <fstream>
 +
#include <set>
 +
#include "mySortedArray.h"
 +
#include "myTree.h"
 +
#include "myList.h"                                           
 +
 
 +
int main(int argc, char** argv) {
 +
  int tok;
 +
  std::vector<int> v;
 +
  if ( argc > 1 ) {
 +
    std::ifstream fin(argv[1]);
 +
    while( fin >> tok ) { v.push_back(tok); }
 +
    fin.close();
 +
  }
 +
  else {
 +
    while( std::cin >> tok ) { v.push_back(tok); }
 +
  }                                           
 +
  mySortedArray<int> c1;
 +
  myList<int> c2;
 +
  myTree<int> c3;
 +
  std::set<int> s;
 +
 
 +
  clock_t start = clock();
 +
  for(int i=0; i < (int)v.size(); ++i) {
 +
    c1.insert(v[i]);
 +
  }
 +
  clock_t finish = clock();
 +
  double duration = (double)(finish-start)/CLOCKS_PER_SEC; 
 +
  std::cout << "Sorted Array (Insert) " << duration << std::endl;
 +
 
 +
  start = clock();
 +
  for(int i=0; i < (int)v.size(); ++i) {
 +
    c2.insert(v[i]);
 +
  }
 +
  finish = clock();
 +
  duration = (double)(finish-start)/CLOCKS_PER_SEC; 
 +
  std::cout << "List (Insert) " << duration << std::endl;
 +
 
 +
  start = clock();
 +
  for(int i=0; i < (int)v.size(); ++i) {
 +
    c3.insert(v[i]);
 +
  }
 +
  finish = clock();
 +
  duration = (double)(finish-start)/CLOCKS_PER_SEC; 
 +
  std::cout << "Tree (Insert) " << duration << std::endl;
 +
 
 +
  start = clock();
 +
  for(int i=0; i < (int)v.size(); ++i) {
 +
    s.insert(v[i]);
 +
  }
 +
  finish = clock();
 +
  duration = (double)(finish-start)/CLOCKS_PER_SEC; 
 +
  std::cout << "std::set (Insert) " << duration << std::endl;
 +
 
 +
  start = clock();
 +
  for(int i=0; i < (int)v.size(); ++i) {
 +
    c1.search(v[i]);
 +
  }
 +
  finish = clock();
 +
  duration = (double)(finish-start)/CLOCKS_PER_SEC; 
 +
  std::cout << "Sorted Array (Search) " << duration << std::endl;
 +
 
 +
  start = clock();
 +
  for(int i=0; i < (int)v.size(); ++i) {
 +
    c2.search(v[i]);
 +
  }
 +
  finish = clock();
 +
  duration = (double)(finish-start)/CLOCKS_PER_SEC; 
 +
  std::cout << "List (Search) " << duration << std::endl;
 +
 
 +
  start = clock();
 +
  for(int i=0; i < (int)v.size(); ++i) {
 +
    c3.search(v[i]);
 +
  }
 +
  finish = clock();
 +
  duration = (double)(finish-start)/CLOCKS_PER_SEC; 
 +
  std::cout << "Tree (Search) " << duration << std::endl;
 +
 
 +
  start = clock();
 +
  for(int i=0; i < (int)v.size(); ++i) {
 +
    s.find(v[i]);
 +
  }
 +
  finish = clock();
 +
  duration = (double)(finish-start)/CLOCKS_PER_SEC; 
 +
  std::cout << "std::set (Search) " << duration << std::endl;
 +
}
 +
 
    
== Office Hours ==
 
== Office Hours ==

Navigation menu