This is a code in C, I need to change the code as much as possible, but on condition to perform the same work as this. Changing the var names and the loops is enough
Q: Question: You are requested to develop a simple java program for a movie theatre. They need to store…
A: Program for the given code :- import java.util.*;import java.io.*; public class Main { public…
Q: For any element in keysList with a value greater than 40, print the corresponding value in…
A: import java.util.Scanner;public class LongestLine {public static void main(String args[]) {final int…
Q: Here you can find the java code and photo of challenge: import java.io.*; import java.math.*;…
A: public static boolean isDAG(int z, boolean [ ] visited, boolean [ ] recursionStack){…
Q: public static void question(ArrayStack s1, ArrayStack s2) { if(s1.isEmpty()…
A: s2 will contain the alternate elements of s1 in the reverse order
Q: sortLecNotes sortsearchassigncodeex1.java sort, search for a specific student package…
A: Answer: our instruction is answer the first three part from the first part and . I have done code in…
Q: JAVA: Fill in the ParsedRequest method in the CustomParser.java file. The point of it is to parse…
A: ANSWER: Java Programming: One of the most generally utilized programming dialects, Java is utilized…
Q: A sparse vector is a vector whose entries are almost all zero, like [1, 0, 0, 0, 0, 0, 3, 0, 0, 0].…
A: a.def sparse_add(vector1, vector2):""" (dict of {int: int}, dict of {int: int} -> dict of {int:…
Q: A 2D matrix can be represented as a list and a column count value in Python. For example, the 3x3…
A: In step 2, you will the Python code. In step 3, you can see the sample output. In step 4, you will…
Q: public static void merge ( int[] arrayA, int sizeA, int[] arrayB, int sizeB, int[] arrayC ) { int…
A: while(aDex < sizeA) // if Index of Array A is less than Size of Array A…
Q: In this problem you are simulating a HOT DOG stand. You will need fill a Queue with the provided…
A: Find the java code attached.
Q: My Arrays.sort is not printing out sorted array ints. It prints out an unsorted list.
A: In the above program you are passing copyArr.length-1 as to index.
Q: Data Structure Add this two methods for the following class
A: Two double arrays are declared and initialized with values for 2 polynomials in PolynomialMain.java…
Q: static int count=0; static void printOutput(ArrayList arr){ count++; int sum=0; for(int i=0;i…
A: The recursive method used in the main method of program is findways (arr, i:1,n); In main function,…
Q: package Q2; import java.io.FileInputStream; import java.io.FileNotFoundException; import…
A: import java.io.FileInputStream;import java.io.FileNotFoundException;import…
Q: CircularArrayQueue represents an array implementation of a queue in * which the indexes for the…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: For any element in keysList with a value smaller than 60, print the corresponding value in…
A: Required: For any element in keysList with a value smaller than 60, print the corresponding value…
Q: Convert this Student Array code into Student Singly LinkedList using java. public class Student {…
A: In this problem, we will convert Student Array code into Student Singly LinkedList using java.
Q: import java.util.ArrayList; public interface PermuteAL { /** * Creates a sequence of numbers. *…
A: Implement this method in the Java language
Q: You are requested to develop a simple java program for a movie theatre. They need to store the…
A: The Complete code is given below with the outputs.
Q: public class PasswordGeneratorAndStorage
A: Here is the answer which is mentioned below: When i ran this code, i did not had any problem,…
Q: package edu.luc.cs.cs271.mazesolver; import java.util.ArrayList; import java.util.Scanner; public…
A: File: maze.py Project 7.9 Determine the solution to a maze problem. Uses a gid to represent…
Q: Given part of the ArrayStack class Java code, implement its pop) operation in Java based on the data…
A: Java program to implement pop () operation in array stack
Q: public class QueueEx public static void method1(ArrayQueue q1, ArrayQueue q2) { Iterator iter1 =…
A: Required: java
Q: import java.io.*; import java.util.stream.*; public class Solution { static class ListCell {…
A: Merge Sort is a Divide and Conquer algorithm. It divides the input array into two halves, calls…
Q: class BinaryImage: def __init__(self): pass def…
A: Actually, python is a easiest programming language. It is a dynamically typed programming language.
Q: Write a class that maintains the top 10 scores for a game application, implementthe add and remove…
A: Singly Linked List · We have seen some applications of the arrays. · Arrays are…
Q: Please use class name: Exercise_01 The implementations of the methods addAll, removeAll, retainAll,…
A: Answer import java.util.*;public class Implementation { public static void main(String[] args) {…
Q: Implement solutions for the following methods: • getCourseSize() – returns the number of students…
A: Given Implement solutions for the following methods: • getCourseSize() – returns the number of…
Q: Write a for loop to print all elements in courseGrades, following each element with a space…
A: Java program to print all the elements stored in the courseGrades. The name of the program is…
Q: implementation in Java
A: Introduction Java is a kind of programming language that provides a large number of applications…
Q: // implement copyToVec such that: // 1) receives three parameters, an array, the array's size, and a…
A: Note: Below is the required program in C++. Programming Approach: Declaring necessary header file…
Q: In java, the Arrays class contains a static binarySearch() method that returns …… if element is…
A: static binarySearch() method returns index of the search key, if it is contained in the array, else…
Q: Add comments in code #include #include /* ADJACENCY MATRIX */…
A: Program Approach: Including a necessary header file Declaring integer variable source, V, E, time,…
Q: Design and implement an insertSorted() method for the MyArrayList class. The method should receive a…
A: Here I am writing program in java language according to question . program contains insertSorted()…
Q: Requirements: Use Java Programming only. Show screenshots of your work. 6. Write…
A: Since you have asked multiple question, we will solve the first question for you. If you want any…
Q: #include usingnamespace std; class Queue { int size; int* queue; public:…
A: Polymorphism is an OOP concept by which we can perform a single action in different ways i.e. using…
Q: Type the program's output ColorSorter.java Color.java import java.util.Scanner; import…
A: The solution to the given problem is below.
Q: (8) Instance method isEqual that accepts a parameter aSet of type Set. The method will return true,…
A: Answer: Our guideline is answer first three subparts form first question. so we have answer in java…
Q: write a program that reads the students.txt file and stores the name of the student and the grade…
A: The java coding is implemented below: All the steps and functions are mentioned in comment so that…
Q: Write a Java class Course for dealing with courses. Your class must have the following features:…
A: Program Approach: 1- As per the assignment requirement, create all the classes as mentioned in the…
Q: Design and implement an insertSorted() method for the MyArrayList class. The method should receive a…
A: public class MyArrayList<E> { private int size; private E[] data;…
Q: Given part or the ArrayStack class Javà code, implement its popO operation Java based on the data…
A: The given problem is to be solved in Java where the interface is implemented in ArrayStack and need…
Q: public class testRun{ public static int find(int[] data, int target,int start, int end) { int[]…
A: Question given: A java program is given of binary search using recursion. Debug this program and…
Q: package Q2; import java.io.FileInputStream; import java.io.FileNotFoundException; import…
A: Code: package Q2; import java.io.FileInputStream; import java.io.FileNotFoundException; import…
Q: import java.util.LinkedList; import java.util.Scanner; import java.util.Arrays; import java.io.File;…
A: import java.util.LinkedList;import java.util.Scanner;import java.util.Arrays;import…
Q: Implement a Menu-Driven program of ArrayList class using the above scenario and perform the…
A: Answer
Q: package Q2; import java.io.FileInputStream; import java.io.FileNotFoundException; import…
A: package Q2;import java.io.FileInputStream;import java.io.FileNotFoundException;import…
Q: In Java: -Using a BST Interface (Binary Search Tree) -Create a class Disk. Disk contains four…
A: Answer: our instruction is answer the first three part from the first part and . I have done code in…
Q: import java.util.*; class Arraylist { public static void main(String args[]) { ArrayList obj = new…
A: Given, Programming language = JAVA Code: import java.util.*; class Arraylist { public static…
Q: static int count=0; static void printOutput(ArrayList arr){ count++; int sum=0; for(int i=0;i…
A: See the image below to understand the flow of the recursion.
void ExtractMinimumWeightPath(int path[MAX], int weights[MAX][MAX], int pathWeights[MAX][MAX], int rowc, int colc)
{
int rowsCount = rowc;
int colsCount = colc;
path[rowsCount];
int col = 0;
int i = 0;
for(i=1;i<colsCount;i++)
{
if(pathWeights[rowsCount-1][i]<pathWeights[rowsCount-1][col])
{
col = i;
}
}
int row = rowsCount-1;
do
{
path[row] = col + 1;
if (col>0 && pathWeights[row-1][col-1] + weights[row][col] == pathWeights[row][col])
{
col = col - 1;
}
else if (col < colsCount-1 && pathWeights[row-1][col+1] + weights[row][col] == pathWeights[row][col])
{
col = col + 1;
}
row--;
}
while(row>0);
path[0] = col + 1;
}
This is a code in C, I need to change the code as much as possible, but on condition to perform the same work as this.
Changing the var names and the loops is enough
Step by step
Solved in 2 steps
- public class testRun{public static int find(int[] data, int target,int start, int end) {int[] stored = sort(data);if (start <= end) {int midPoint = (start + end / 2);if (stored[midPoint] == target) {return midPoint;}if (stored[midPoint] > target) {return find(data, target, start, midPoint - 1);//return first half,exclusive itself}if (stored[midPoint] < target) {return find(data, target, start, midPoint + 1);//return last half,exclusive itself.}}return -1;}public static int[] sort(int[] data){// Find the smallest element in the listfor (int i = 0; i < data.length -1 ; i++){ //generate the index position,not =< b/c goes outer boundint min = i; //assign index position to min in each iterationfor (int j = i + 1; j < data.length ; j++){if (data[j] < data[min]){ //if the element in the second index number smaller than// the element in previous index numbermin = j; // assign j to the smallest number}}swap (data,i,min);// data[i] = min the smallest number assign to…For any element in keysList with a value greater than 40, print the corresponding value in itemsList, followed by a semicolon (no spaces). Ex: If the input is: 32 105 101 35 10 20 30 40 the output is: 20;30; import java.util.Scanner; public class Compare { public static void main(String args[]) {final int SIZE_LIST = 4;int[] keysList = new int[SIZE_LIST];int[] itemsList = new int[SIZE_LIST];int i;Scanner input = new Scanner(System.in); keysList[0] = input.nextInt();keysList[1] = input.nextInt();keysList[2] = input.nextInt();keysList[3] = input.nextInt(); itemsList[0] = input.nextInt();itemsList[1] = input.nextInt();itemsList[2] = input.nextInt();itemsList[3] = input.nextInt(); /* Your code goes here */ System.out.println();} }For any element in keysList with a value smaller than 50, print the corresponding value in itemsList, followed by a space. Ex: If the input is: 32 105 101 35 10 20 30 40 the output is: 10 40 import java.util.Scanner; public class Compare { public static void main(String args[]) { final int SIZE_LIST = 4; int[] keysList = new int[SIZE_LIST]; int[] itemsList = new int[SIZE_LIST]; int i; Scanner input = new Scanner(System.in); keysList[0] = input.nextInt(); keysList[1] = input.nextInt(); keysList[2] = input.nextInt(); keysList[3] = input.nextInt(); itemsList[0] = input.nextInt(); itemsList[1] = input.nextInt(); itemsList[2] = input.nextInt(); itemsList[3] = input.nextInt(); //answer// System.out.println(); } }
- Retrieving a value using its associated key can be accomplished using anindexer, which works just like an indexer for an array. A key is passed in asthe index value, and the value associated with the key is returned, unless thekey doesn’t exist, in which a null is returned.Write short code segment demonstrates how this technique works:package Q2;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.util.ArrayList;import java.util.Scanner;public class Question2 {public static void main(String[] args) throws FileNotFoundException {/*** Part a* Finish creating an ArrayList called NameList that stores the names in the file Names.txt.*/ArrayList<String> NameList = new ArrayList<String>();/*** Part b* Replace null on the right-hand-side of the declaration of the FileInputStream object named inputStream* so that it is initialized correctly to the Names.txt file located in the folder specified in the question description*/FileInputStream inputStream = new FileInputStream("Names.txt");Scanner scnr = new Scanner(inputStream); //Do not modify this line of code/*** Part c* Using a loop and the Scanner object provided, read the names from Names.txt* and store them in NameList created in Part a.*/while (scnr.hasNext()) {//reading each string from text file and adding to…Please help me fix this code Make it run out like the picture import java.util.ArrayList; import java.util.Random; import java.util.Scanner; public class FrogListApp { public static void main(String[] args) { final int MIN_WEIGHT = 1; final int MAX_WEIGHT = 25; // Step 3: Create an array list to store Frog objects ArrayList frogsList = new ArrayList<>(); // Step 4: Create a Scanner object Scanner scanner = new Scanner(System.in); // Step 5: Read an integer as the number of frogs // using prompt "Enter the number of frogs: " System.out.print("Enter the number of frogs: "); int numberOfFrogs = scanner.nextInt(); // Step 6: Read an integer as the random generator seed // using prompt…
- Complete the method loadBuses(String bfile) that reads information bus information from afile (bfile contains the filename) . Each row in the file should trigger the creation of aninstance of bus or an appropriate subclass, according to the data in table 1. All buses createdshould be added to an arraylist. LoadBuses should return the populated arraylist. public ArrayList<Bus> loadBuses(String bfile ) { Scanner bscan = null; ArrayList<Bus> blist = new ArrayList<Bus>(); return blist; }public ArrayList<Bus> loadBuses(String bfile) { ArrayList<Bus> buses = new ArrayList<>(); try { Scanner scanner = new Scanner(new File(bfile)); while (scanner.hasNextLine()) { String[] line = scanner.nextLine().split(" "); if (line.length < 4 || line.length > 7) { throw new IllegalArgumentException("Invalid input format"); } String name = line[1]; int size = Integer.parseInt(line[1]); int price = Integer.parseInt(line[2]); int level = Integer.parseInt(line[3]); Ministry ministry = null; if (line.length > 5) { ministry = new Ministry(line[5]); } int competitorArea, numSecurity, barArea; Bus bus; SportsBus sportsBus; PartyBus partyBus;…public class ShoppingListDriver{ public static void main(String[] args){ ShoppingList sl=new ShoppingList(3);sl.insert(null);sl.insert(new Item("Bread", "Carb Food", 2, 2.99));sl.insert(new Item("Seafood","Sea Food", -1, 10.99));sl.insert(new Item("Rice", "Carb Food",2, 19.99));sl.insert(new Item("Salad Dressings","Dessing", 2, 19.99));sl.insert(new Item("Eggs", "Protein",2, 3.99));sl.insert(new Item("Cheese","Protein", 2, 1.59));sl.insert(new Item("Eggs", "Protein",3, 3.99));sl.printNames();sl.print(); System.out.println("After removing Eggs:");sl.remove(new Item("Eggs","Protein",0,0));sl.printNames();sl.print(); }}
- public class DynamicArray { private int array[]; private int count; private int size; public DynamicArray() { array = new int[1]; count = 0; size = 1; } public void add(int data) { if (count == size) { growSize(); // make array size double } array[count] = data; count++; } public void growSize() { int temp[] = null; if (count == size) { temp = new int[size * 2]; { for (int i = 0; i < size; i++) { temp[i] = array[i]; } } } array = temp; size = size * 2; } public void shrinkSize() { int temp[] = null; if (count > 0) { temp = new int[count]; for (int i = 0; i < count; i++) { temp[i] = array[i]; } size = count; array =…import java.util.Scanner; public class ContactList { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); ContactNode head = null; ContactNode current = null; // Read the name and phone number for three contacts and build a linked list. for (int i = 1; i <= 3; i++) { System.out.print(" " + i + ": "); String name = scnr.next(); System.out.print(" " + i + ": "); String phoneNumber = scnr.next(); ContactNode newContact = new ContactNode(name, phoneNumber); if (head == null) { head = newContact; current = head; } else { current.insertAfter(newContact); current = newContact; } } // Output each contact. current = head; for (int i = 1; current != null; i++) { System.out.print("Person " + i + ": "); current.printContactNode();…class BinaryImage: def __init__(self): pass def compute_histogram(self, image): """Computes the histogram of the input image takes as input: image: a grey scale image returns a histogram as a list""" hist = [0]*256 return hist def find_otsu_threshold(self, hist): """analyses a histogram it to find the otsu's threshold assuming that the input hstogram is bimodal histogram takes as input hist: a bimodal histogram returns: an optimal threshold value (otsu's threshold)""" threshold = 0 return threshold def binarize(self, image): """Comptues the binary image of the the input image based on histogram analysis and thresholding take as input image: an grey scale image returns: a binary image""" bin_img = image.copy() return…