summaryrefslogtreecommitdiff
path: root/AlgoDesignAndTechniqueEdxJava
AgeCommit message (Collapse)Author
2018-12-17Coin change Dynamic Programming done!Haidong Ji
Easy implementation of the algorithm described in course slide. It helped that I named variables according to the pseudo code. Getting array indexing right is always a bit tricky so pay attention.
2018-12-15Closest Pair done!Haidong Ji
Yay, so much fun. Breaking things down into small, actionable items, and doing it, this never fails! Persist! Glad that my org-mode Emacs TODO helps making it happen.
2018-12-09Organizing lottery done!Haidong Ji
Pretty challenging and fun exercise. Once again, persistence is the key. Don't give up, and it is a lot of fun.
2018-11-27Inversion count done!Haidong Ji
Pretty challenging but a lot of fun and very satisfying. Decided to implement MergeSort first without worrying about inversion count, then went from there. Lesson learned: use the debugger! :) Also passing by reference in Java can be convenient.
2018-11-23Improved QuickSort done!Haidong Ji
Once again, a lot of fun. PythonTutor's visualization was extremely helpful!
2018-10-30Majority Element done!Haidong Ji
Oh yeah, I had so much fun with this one! It really worked my brain and gave me better appreciation of Divide and Conquer and Merge Sort! Philip Guo's PythonTutor site is amazing! It really helped me in debugging my recursive function. Fun fun fun!
2018-10-05Binary search recursive approachHaidong Ji
The grader showed that it took less time, but more space. There might be some sampling issues, since I ran both approach only once.
2018-10-05Binary search done.Haidong Ji
I chose to use an iterative method, instead of recursion, to avoid function stacks. Perhaps I should try recursive approach and compare the results.
2018-10-02Maximize salary done!Haidong Ji
The compare algorithm provided by bytwigorlimerick was so clever and elegant! https://courses.edx.org/courses/course-v1:UCSanDiegoX+ALGS200x+2T2017/discussion/forum/course/threads/5a427dbf44a15008cd000701
2018-10-02Checking in for pulling from laptop.Haidong Ji
Maximize salary close to done. Still some bugs. Will likely fix it on my laptop.
2018-09-28Max num of prize places done!Haidong Ji
Eclipse (I'm currently using Photon) "the type integer is invisible" error is really annoying. I adjusted Java compiler to version 10, which appeared to fix, but it came back. (10 is the version from command line "java --version") Hopefully a restart will take care of it for good.
2018-09-26Covering Segments done!Haidong Ji
Pretty challenging and interesting. I'm glad I worked out the algo in Python first for this problem. Good review of the comparable interface. Good feeling of stream and lambda functions. Eclipse's erronous reporting of errors is annoying.
2018-09-22Check in for my Wisconsin marathon tripHaidong Ji
2018-09-07Max Dot Product done.Haidong Ji
I wasn't just a little surprised how simple it is.
2018-09-07Fractional Knapsack done!Haidong Ji
Very rewarding, lots of fun. I'm glad I wasn't lazy, and did the work of stress testing, which really didn't put much stress, but helped me pinpoint the bug. Plus I think stress testing will be useful down the road, very good technique.
2018-09-07Stress tested according to week 1 pdf, found and fixed bug!Haidong Ji
The bug was simple: I picked the index of the sortedAscendingIndex, not its value in weight comparison.
2018-09-05Buggy FractionalKnapsack for now. Work on a python version first.Haidong Ji
I may need to do an exhaustive testing.
2018-09-02Changing Money Greedy Algo done.Haidong Ji
2018-08-29Last digit of partial sum done!Haidong Ji
Interesting challenge again. Once I figured out that the result should be SumFn-SumFm-1, things started falling into place :)
2018-08-27Last digit of sum of Fibs done!Haidong Ji
User of spreadsheet really helped here. I should have thought of adding rows earlier.
2018-08-26Improved the code by getting rid of fib calculation!Haidong Ji
Following the same change I made to Python earlier.
2018-08-24Improved fib by getting rid of arrayHaidong Ji
Huge improvement in terms of both time and memory consumption.
2018-08-23Done!Haidong Ji
Reinplemented so that fib is of type BigInteger. With this I was able to get big Fib(n) mod m working. In this particular case, it felt easier with Python, since it is dynamic, not strongly typed.
2018-08-19Least Common Multiple done!Haidong Ji
Learned two interesting things: 1. Use GCD to get LCM https://www.idomaths.com/hcflcm.php#formula 2. To make a literal of numbers long, add L at the end of the number!
2018-08-19GCD done!Haidong Ji
Interesting. The original code was like this: public static int getGCD(int a, int b) { if (b == 0) { return a; } if (b > a) { return getGCD(b, b % a); } else { return getGCD(b, a % b); } } And it failed the test of 14159572, 63967072. After chaning the code to: public static int getGCD(int a, int b) { if (b == 0) { return a; } if (b > a) { return getGCD(b, a); } else { return getGCD(b, a % b); } } It worked! I guess it's important to do a pretty exhaustive testing to find this subtle bug
2018-08-14Last digit of fib and some renaming refactoring!Haidong Ji
2018-08-12Fibonacci naive recursive and 1st optimization done!Haidong Ji
It was kinda tricky to get it right, with array indexing and how many I needed to calculate. Good thing I was using TDD, which helped quite a bit in getting it done!
2018-08-07Made FastScanner a static class member instead of an independent class.Haidong Ji
Appear to consume a bit of more memory.
2018-08-07Used FastScanner. Had to change "static class" to "final class"Haidong Ji
2018-08-06Maximum Pairwise Product done!Haidong Ji
2018-07-28Initial commitHaidong Ji