Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FRQ Associations Issue #4

Open
isabelle926 opened this issue Feb 26, 2024 · 1 comment
Open

FRQ Associations Issue #4

isabelle926 opened this issue Feb 26, 2024 · 1 comment

Comments

@isabelle926
Copy link
Owner

FRQ 1:

The first FRQ focused on 1D arrays, 2D arrays, and ArrayLists. Concepts that are tested in this FRQ can be seen when examining the Person.java class:

import java.util.ArrayList;
import java.util.Collection;
import jakarta.persistence.ManyToMany;

...

@ManyToMany(fetch = EAGER)
private Collection<PersonRole> roles = new ArrayList<>();

During the creation of the object, an ArrayList is assigned to the "roles" field so that it can store PersonRole objects. Since the ArrayList is stored as a collection it will be able to store multiple user roles. In our project, we have not yet implemented the different roles that a user can have, but this is a good baseline that we will utilize in Trimester 3.

For my project in particular, which involves dividing users into job-posters, job-seekers, and mentors, ArrayLists would be helpful for determining which user can interact with which functionality.

FRQ 2:

This FRQ was mainly about classes and subtopics dealt with accessing methods within the classes and iteration, among other things. Once again, the PersonRole.java class is very useful in showcasing this:

@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
public class PersonRole {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(unique=true)
    private String name;

    public PersonRole(String name) {
        this.name = name;
    }

    public static PersonRole[] init() {
        PersonRole student = new PersonRole("ROLE_STUDENT");
        PersonRole teacher = new PersonRole("ROLE_TEACHER");
        PersonRole admin = new PersonRole("ROLE_ADMIN");
        PersonRole[] initArray = {student, teacher, admin};
        return initArray;
    }
}

For my project, I created a unique user class which shows whether a user is online or not so that they can be shown on our interview page. To do this, I created a method within the signup function that automatically changed the user's status to online upon registering and whenever they logged in, and in the future I will have a method that will change the user's status to offline after closing the tab or signing out.

FRQ 3

This FRQ was mainly about 2D arrays as well as method and control structures. This can be implemented into our group's final project since one of our plans for the future is to list jobs based on user's interests. Using a 2D array would be crucial for this because a feature that uses this could include showing jobs based on a user's education level or known coding languages.

FRQ 4

This FRQ was also about classes, more specifically with interfacing with classes. Our project currently uses a KNN algorithm to search for relevant users for people who are posting jobs:

package com.nighthawk.spring_portfolio.mvc.knn;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class KNNWorkerHiring {

    // KNN algorithm
    public static Worker findMostRelevantWorker(List<Worker> workers, Worker newWorker, int k) {
        Map<Double, Worker> distanceMap = new HashMap<>();

        // Calculate Euclidean distance for each worker
        for (Worker worker : workers) {
            double distance = calculateDistance(worker, newWorker);
            distanceMap.put(distance, worker);
        }

        // Sort distances and get the top k neighbors
        List<Double> distances = new ArrayList<>(distanceMap.keySet());
        Collections.sort(distances);

        // Return the most relevant worker
        return distanceMap.get(distances.get(0));
    }

    private static double calculateDistance(Worker worker1, Worker worker2) {
        // Simple distance calculation based on preferences
        double langDistance = calculateLanguageDistance(worker1.languagesKnown, worker2.languagesKnown);
        double locationDistance = worker1.preferredLocation.equals(worker2.preferredLocation) ? 0 : 1;

        // Euclidean distance
        return Math.sqrt(Math.pow(langDistance, 2) + Math.pow(locationDistance, 2));
    }

    private static double calculateLanguageDistance(List<String> lang1, List<String> lang2) {
        // Jaccard similarity for language distance
        List<String> union = new ArrayList<>(lang1);
        union.addAll(lang2);

        List<String> intersection = new ArrayList<>(lang1);
        intersection.retainAll(lang2);

        return 1 - ((double) intersection.size() / union.size());
    }
}

Overall Reflection:

Not only did doing the FRQ practice exams help me prepare for the AP exam, it also showed me how many of the topics which are tested on the AP exam are also relevant in constructing fully functional backends for websites and how applicable these skills are in the real world

@vardaansinha
Copy link

GRADING:

Isabelle did a good job of explaining her FRQs - she was concise and to the point and understood all the key algorithms. Her associations were solid, and for the 2D arrays where there was not necessarily an implementation in her current project, she explained how she could implement one in the future for a feature.

CODE: 3.6/3.6
FRQ ASSOCIATION: 3.6/3.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants