# COMP 272: Data Structures II Assignment 1 solution

\$25.00

Original Work ?

5/5 - (1 vote)

## 1. Lists (20 points)

a. Complete the removeElementsLT method to remove all elements from the list less than the element passed into the method as an argument. Example: running
removeElementsLT(8) would remove elements less than 8 from the list.

## 2. Stacks (40 points) Complete these questions using Stacks (java.util.Stack).

a. Complete the isPalindrome method to check if the input string by a user is a palindrome (a word or sentence that is spelled the same in reverse as it is spelled
straightforward). This method should work irrespective of spaces and casing. Example: the method should return true for “Race Car” and “racecar”. Hint: the
String method .replaceAll() will be helpful.

b. Complete the findLargestK method which takes a stack and an integer K as inputs and then returns the largest index of K in the stack. Example: Given the stack
[5,3,1,4,1] and K=1, the method will return 4.

## 3. Algorithm Analysis 1 (20 points)

Modify the provided System.out.println() statements to print the following for the algorithmAnalysis1 method:
• Mathematical equation for the method: Example: System.out.println(“Math equation is : 5 n log n + 2);
• The time complexity for the algorithmAnalysis2 method, one each for Big-Oh, Big-Omega, and Big-Theta. Example: System.out.println(“O(n log n”);
Note: This question doesn’t have any automated tests in Replit

## 4. Algorithm Analysis 2 (20 points)

Modify the provided tystem.out.println() statements to print the following for the algorithmAnalysis2 method; assume that both input
arrays are of size N:

• Mathematical equation for the method: Example: System.out.println(“Math equations is: 5n log n + 10n + 2”);
• The time complexity for the algorithmAnalysis2 method, one each for Big-Oh, Big-Omega, and Big-Theta. Example: System.out.println(“O(n log n);
Note: This question doesn’t have any automated tests in Replit

Submission:
1. Before submission, make sure your code passes all the JUnit tests. Keep in mind, however, that passing the test cases does not guarantee
that your code is correct or efficient. Your assignment will be graded considering test results, correctness, and efficiency.

2. The submission should be completed in Replit.

3. Include your name and course’s section number as comments at the top of each submitted Java file.