Lab 2

Perf: runtime profiling tool

Flat profile usage
>perf record -e cycles:u [normal command line]
>perf report

Call graph usage
>perf record --call-graph dwarf -e cycles:u [normal command line]
>perf report
scp  -r  /complete/source/path/dir/p1folder  [email protected]:/home/egoreli

Revision Control - Git

aka Version Control

Helps keep copies of old commits, so you always have copies of your old code and new code

gitlab.com // private repositories, NOT public

cd ~ // change to current directory
git clone
git add
git commit - m "message"
git push
git pull (pulling repositories from another computer, or from CAEN?)

Complexity Analysis

Theta is an angle?
Big-O: slowest the program will run
Big-Omega: fastest the program will run
Big-Theta: tightest bound, upper and lower bound (same complexity)
  • Only meaningful to state tightest bounds, aka Big-Theta

Project 1 Tips

  • Don't copy anything, INCLUDING indices
  • Only compare indices, NOT strings
  • Keep ONLY ONE copy of the string
  • Inside a nested for loop, don't call other functions
  • Write good comments
  • Loop at Piazza for tips
  • Will easily take more than 10 submits to get desired score, way before deadline

Coding Problem- Merge 2 Sorted vectors

vector<int> combine (const vector<int> &xs, const vector<int> &ys) {
    vector<int> both;
    both.reserve(xs.size() + ys.size());   // resize allows us to push_back in the empty sections
    size_t xi = 0;
    size_t yi = 0;
    while (xi < xs.size() && yi < ys.size())
        if (xs[xi] < ys[yi])  // keep the ordering the same
            both.push_back(xs[xi++]);
        else
            both.push_back(ys[yi++]);
    while (xi < xs.size())  // leftover elts if the other one runs out
        both.push_back(xs[xi++]);
    while (yi < ys.size())  // leftover elts
        both.push_back(ys[yi++]);
    return both;
}

results matching ""

    No results matching ""