2017 Fall CIS200 Lab 7 Release date: November 1, 2017 Due date: November 8, 2017
ID: 3607087 • Letter: 2
Question
2017 Fall CIS200 Lab 7 Release date: November 1, 2017 Due date: November 8, 2017 Submission based on Turn-In template so need to perform file exist and empty file cheeks in your programs Program 1: Let n array of n elements. Write a template function, minMaxFunc(...), which takes an maximray of type as an input parameter and if you want the minimum or dh value. Using TWO stacks to determine the minimum or maximum value and return that is atack I (LINKED LIST) holds values in ascending/descending order, stack 2 (ARRAY) A be element ( eess you must also print the values in the stack. Assume the operators are defined for stored in a data file (data.dat): 4 11332 porary" work stack as you insert values to keep them in order). Once all values have been In this question, you may hardcode n-5. You must write all functions you call (PUSH, PEEK, ISFULL ISEMPTY), and also need to write a main) to test the following data arrays 1.1 4.1 8.1 5.2 2.3 In addition, the results should be printed out in main() routine to the screen and to an output file (out.txt). Reminder of how templates are defined/work: template void functionMethod(T inData) coutExplanation / Answer
public class DiscreteLogarithm { public static final long NO_SOLUTION = -1; private static final HashMap set = new HashMap(); private DiscreteLogarithm() { } private static final long pow(long a, long x, long p) { if (x == 0) return 1; if (x == 1) return a % p; if (x % 2 != 0) return (a * pow(a, x - 1, p)) % p; final long temp = pow(a, x / 2, p) % p; return (temp * temp) % p; } private static final long getDiscreteLogarithm(HashMap set, long s, long a, long p) { for (long i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.