Practice Test 2 - AP Computer Science Principles

20 questions. Answer them in any order, then submit to see your score and every explanation.

  1. What is the overall significance of the existence of undecidable problems for the field of computer science?
  2. How does this setup differ from a truly fault-tolerant system?
  3. A to-do list of strings starts as ['email boss','wash dishes','study','buy groceries','walk dog']. You mark one task complete by removing it, like crossing a note off a fridge list. The code runs tasks.remove('wash dishes') to delete that task. The remaining tasks stay in their original order. No new tasks are added. Based on the scenario above, how many elements are in the list after the given operations?
  4. Based on the scenario, an online store keeps an array prices of decimal numbers. The program must compute the average price of items that cost at least 10.00. Input: list prices. Output: the average of qualifying prices, or 0 if none qualify. Constraints: nn up to 100,000; one pass preferred; AP-style pseudocode. PROCEDURE AvgAtLeastTen(prices) sum <- 0 count <- 0 FOR EACH p IN prices IF p >= 10.00 sum <- sum + p count <- count + 1 IF count = 0 RETURN 0 RETURN sum / count What is the expected output of the procedure given the input prices = [9.99, 10.00, 12.50, 7.00]?
  5. Which of the following best describes a potential source of bias in this system?
  6. Consider the following code segment: IF(x > 0) { IF(y > 0) { DISPLAY("Quadrant I") } ELSE { DISPLAY("Quadrant IV") } } ELSE { DISPLAY("Not in Quadrant I or IV") } What will be displayed when x = 3 and y = -2?
  7. A programmer includes an external library in their project to manage network communications. While this simplifies development, what is a potential disadvantage of relying on this library?
  8. An online retail company uses an algorithm to set prices for its products. The algorithm detects that a user is accessing the site from a device and location associated with a high-income demographic and displays higher prices than it shows to other users. This practice, known as dynamic pricing, raises ethical concerns related to...
  9. ## Crowdsourcing and Problem-Solving in Computing ### Definition and Core Idea Crowdsourcing is a problem-solving and production strategy in which an organization distributes a task to a large, often online, group of people and then aggregates their contributions. In computing, it functions as a socio-technical system: software platforms coordinate many small inputs into a usable output, such as bug fixes, documentation, or feature proposals. ### Scenario: Open Source Software Development In open source software development, crowdsourcing is embodied by communities that publicly collaborate on shared codebases. For example, the Linux kernel and Mozilla Firefox accept contributions from thousands of developers, testers, and technical writers. Platforms such as GitHub and GitLab provide infrastructure for issue tracking, version control, code review, and automated testing, allowing geographically distributed participants to work asynchronously. ### Benefits for Computing and Society Crowdsourcing can be: - Scalable: more participants can address more issues in parallel. - Diverse: contributors bring varied expertise, devices, languages, and use cases. - Cost-effective: organizations may reduce direct labor costs by leveraging volunteer or part-time effort. These advantages often accelerate iteration: a user reports a defect, another submits a patch, and maintainers merge it after review. ### Impact on Innovation Because many people can propose solutions, open source projects often explore alternative designs rapidly. The passage notes that innovation emerges not only from "breakthrough" features, but also from incremental improvements—performance tuning, security hardening, and accessibility enhancements. ### Drawbacks and Risks Crowdsourcing introduces challenges: - Quality control: not all contributions meet standards; maintainers must review and test. - Coordination overhead: merging changes can create conflicts and delays. - Ethical concerns: unpaid labor, unclear attribution, and unequal influence among contributors may create inequities. ### Real-World Outcomes Successful open source projects typically rely on governance—maintainer roles, contribution guidelines, and code-of-conduct policies—to balance openness with reliability. When governance is weak, projects can suffer from inconsistent quality, contributor burnout, or fragmented "forks" that split effort. Based on the passage, what is a primary benefit of crowdsourcing as described in the passage?
  10. Based on the scenario, a messaging app must remove blocked users from a list. Input: list usernames (strings) and list blocked (strings). Output: a new list containing only usernames not in blocked, preserving original order. Constraints: nn up to 30,000; blocked up to 5,000; do not modify usernames; AP-style pseudocode. A student writes: PROCEDURE FilterBlocked(usernames, blocked) allowed <- [] FOR EACH name IN usernames IF NOT (name IN blocked) APPEND(allowed, name) RETURN allowed What is the expected output of the procedure given the input usernames = ["ava","li","sam","li"] and blocked = ["li"]?
  11. A bank account starts at $100. Using the pseudocode below, what is the value of balance after executing the code? balance <- 100 // starting money deposit <- 40 // money added withdrawal <- 25 // money taken out balance <- balance + deposit // add deposit balance <- balance - withdrawal // subtract withdrawal balance <- balance + 10 // bonus added
  12. To access a secure facility, an employee must swipe a keycard and also place their hand on a palm scanner. These two authentication factors fall into which of the following categories, respectively?
  13. Based on the documentation, which of the following is a valid call to this procedure?
  14. In this shopping cart code, which conditions must be met for a 20% discount? // Online Shopping Cart discount rules IF isMember IF total >= 100 IF isSeasonalSale discount = 20 ELSE discount = 15 ELSE discount = 5 ELSE IF total >= 150 IF isSeasonalSale discount = 10 ELSE discount = 0 ELSE discount = 0
  15. Read the passage. In a streaming service, compression shrinks data so videos load quickly and use less bandwidth. The text explains that lossless compression preserves every bit of information, while lossy compression removes some details to achieve smaller files. For digital media, JPEG commonly compresses photos by discarding subtle image data, and MPEG commonly compresses video by reducing repeated or less-noticeable visual information across frames. This creates a trade-off: smaller files and smoother streaming versus potential blur or blocky artifacts. In contrast, text and program files often use lossless methods such as Huffman coding and LZW, since even a missing character can change meaning. Based on the text, how does MPEG differ from JPEG?
  16. If isMember=true and isSeasonSale=true are true, what is the discount when total=99? // Inputs: isMember, total, isSeasonSale IF isMember IF total >= 100 IF isSeasonSale discount = 0.20 ELSE discount = 0.10 ELSE discount = 0.05 ELSE IF isSeasonSale AND total >= 150 discount = 0.15 ELSE discount = 0.00
  17. At a 24-hour hackathon, a team of four creates a prototype that helps students form study groups. They begin with a fast brainstorming session and settle on a core feature: match students by course and available time. Wei sketches the screen flow; Cam writes the matching logic; Anaya tests each build and notes confusing steps; and Luis manages coordination, keeping a task board updated and reminding the team to commit changes regularly. They rely on short stand-up talks, a shared task list, and late-night voice calls when decisions must be immediate. Near midnight, Wei says, "The sign-up screen is too crowded," while Cam replies, "We don't have time to redesign." Anaya adds, "Testers keep missing the submit button." Luis proposes a compromise: "We'll keep the layout but remove two optional fields and enlarge the button." Cam agrees if the change is small and quick; Wei agrees if the screen remains consistent with the rest of the app. They implement the revision, then Anaya runs the same test steps and reports fewer mistakes. By morning, the prototype works smoothly enough for a live demo, and the judges commend the team's disciplined iteration. In the described project, how did the team resolve the conflict about the crowded sign-up screen during development?
  18. If the AI was trained on the company's hiring data from the past 30 years, during which certain demographic groups were historically underrepresented, what is a likely harmful effect?
  19. A medical research institute develops a sophisticated computer simulation to model the spread of a new virus. What is the primary beneficial reason for using a simulation instead of studying the real-world phenomenon directly?
  20. How does metadata make this task easier?

Practice tests