View on GitHub

Chenxin's Individual Work (Tri 3)

This github page is a source and version control for my replit with code from Tech Talk challenges and OO assignments. It also stores my notes and questions from Tech Talks, as well as my plan for preparing for the upcoming AP CSA exam.

Home/Review Tech Talk Notes AP Test Prep FRQ Code

Chenxin Individual Work (Tri 3)

Showcases my replit work from Tech Talks and projects assigned by OO

Table of Contents

Week 4 (Cross-over Partner)

Final Review Ticket

Challenge was to create a data structure in cross-over partner’s repository, linked here

POJO Data Structure: Stands for Plain Old Java Object, which is just a class with constructor and methods. Created a Gravity.java POJO that calculates and returns the force of gravity between Earth and a (user-inputted) planet in our solar system. image

**Show runtime: ** image

Week 3 (Sort algorithms)

Week 3 Review Ticket

Data Spreadsheet

Bubble Sort (in BubbleSort.java): Compares adjacent elements and swaps them if they are in the wrong number. Since the code uses two for loops that iterates through the list, big o notation for the worst case scenario would be O(n * n) = O(n^2). image

Selection Sort (in SelectSort.java): Splits the list into a sorted array and unsorted array. Each time we iterate through the unsorted array, we find the minimum value and add it to the sorted array. Since in the worst case scenario the code iterates through the array n times (once again two for loops), big o notation is O(n * n) = O(n^2).

image

Insertion Sort (in InsertSort.java): Iterates through each element and compares it to the previous values until it is no longer smaller than the previous value. Since in the worst case scenario we iterate through the array n times, big o notation is also O(n * n) = O(n^2).

image

Merge Sort (in MergeSort.java): Recursively splits the array in two until each array contains one value, then compare and combine the smaller lists together until entire sorted list is recreated. Since the array is first divided then sorted, merge sort is a combination of binary and linear search, so big o notation for the worst case scenario is O(n * log n)

image

Analytics: By comparing the compare count, swap count, and time, merge sort is the best algorithm for large data sets because it has the lowest average for all of these statistics. Additionally, as shown by the graph, its big o notation of O(n * log n) is smaller than O(n^2) that the other algorithms have

image

Week 2 (Calculator function)

Week 2 Review Ticket

Challenge 1 (in Calculator.java): Code rpnToResult method to calculate expression from Reverse Polish Notation image

Used for loop to iterate through rpn, and used if loops to perform operation on the top two entries in stack, then pushed answer back into stack. Only one entry would remain at the end of for loop, which was the final result. image

Challenge 2 (also in Calculator.java): Code for a Power (^) operator. Power operator had more precedence than other operators image

Also had to edit tokensToReversePolishNotation and rpnToResult method to include power operator

image image

Week 1 (Stacks & Queues)

Week 1 Review Ticket

Challenge 1 (in Queue.java): Wrote the delete method for queue by setting new head and connecting tail as node image

Difficulty printing out the queues so I changed addList and coded deleteList in QueueManager image

Challenge 2 (in Merge.java): Created merge method to combine and sort two queues image

Difficulty merging the entire queue because next() method of QueueIterator skipped over data

Challenge 3 (in Stack.java): Created stack class that follows the last in first out principle with methods push and pop image

Difficulty testing the stack to reverse a queue (didn’t finish in time)

Week 0 (Data Structures)

Week 0 Review Ticket

Challenge 1 (in Main.java): Used Hashmap data structure in order to dynamically create and store options image

Used try and catch method in order to print “Please enter a number listed in the menu.” instead of causing error if the input isn’t in the menu. image

Challenge 2 (in IntByReference.java): Java can only call by value for parameters in a method, but variable “value” can be changed since the method is called within the object a. For object b, parameter “what” has to be updated using a method in order to change the reference. image

toString() method returns the integer variable “value” as a String.

image

Challenge 3 (in Matrix.java): toString() method iterates over the 2d array using enhanced for loops in order to return the 2d array as a String image