4) In each below, a segment of Java code is given. Draw a picture that shows the final result of the execution of the code segment. The picture must indicate the value of every declared variable and the value of every field in every node. The first is done for you as an example. Node p = new Node(2); p.next = p; to 2. Node p, q. r; p=new Node(2); q-new Node(3); r- new Node(5); p.next = q; q.next = r; r.next - q: Node r, p, qi p=new Node(2); 1= new Node(1); p.next = r; q- new Node(3); p.next = q; q.next = p.next; Node p, q, r; p- new Node(5); p.next = null; q- new Node(10); q.next = null; p.next - q: r-p; I.next - null;
Q: 2) Consider a class for a node of a doubly linked list: class node{ String name; String city; node…
A: class node{ String name; String city; node llink, rlink; node(String name , String city){…
Q: rite a program Java to search for the key element from the give list and display its location using…
A: Below is the given code-
Q: 3. Write a Java program that generates randomly a list of N integers, sorts the generated list using…
A: Created two different programs to illustrate merge sort and quick sort. Integer…
Q: Consider the doubly linked list below to answer the following: A) Write Java statements to delete…
A: 1. To delete the node with info 30 : - Node temp = Location; // the address of…
Q: The task for this part is to implement max heap as a class in java. The class should be named…
A: Implement Max-Heap in JAVA
Q: The task for this part is to implement max heap as a class in java. The class should be named…
A: Java program to build HeapMax class that can insert and remove element from the heap, and can also…
Q: You have probably heard about the deque (double-ended queue) data structure, which allows for…
A: Given
Q: 4. What are the contents of the stack pile after the following statements execute Assume that…
A: NOTE Below is the answer for the given question. Hope you understand it well. If you have any…
Q: and perform the following function on that queue. Enqueue: Add an element to the end of the…
A: QUEUE A Queue follows First in First out order. In the queue, insertion is done at the rear end.…
Q: Consider the following code class Node String name; Node next; public Node(String name) this.name…
A: The following are the correct answers to be filled in the blanks: p1; p2;
Q: Please, help me to do this in Java. Create a program to view the waiting list. The list (5 entries)…
A: The program is written in java to get the output as mentioned
Q: You have probably heard about the deque (double-ended queue) data structure, which allows for…
A: Given
Q: a: create abstract class and / or interface for the juke box code as below: import…
A: It is defined as a high-level programming language.Java runs on a variety of platforms, such as…
Q: I'm getting the errors in this image for the below code: class Node: def __init__(self,…
A: In this python code we have to fix the python code error to get the code which can pass all the test…
Q: Programming in Java. What would the difference be in the node classes for a singly linked list,…
A: Instructions:The node class can add two constructors for the three of them one with no augments and…
Q: The following is a class definition of a linked list Node: class Node { int info; Node next; }…
A: Primitive data type gets memory in stack area. When values are not assigned to primitive data type,…
Q: Write a java program using for loop. Take 5 user inputs for name and age and push it into a queue.…
A: import java.util.LinkedList;import java.util.Queue;import java.util.Scanner;class Citizen {…
Q: Analyse the case study given in chapter 3 Linked list Answer the following questions from…
A: 1. The different class names with class keyword 2. The different methods using public and private…
Q: Consider class IntArrayStack that has two instance variables: int[] data and int top. Implement an…
A: As per our policy the programming language is not mentioned so i am providing the solution in Java.…
Q: onsider the Person class in Problem 1. Implement the interface PersonPriorityQueueInterface provided…
A: class is a group of objects which have common properties. It is a template or blueprint from which…
Q: Java Programming In your program, you will demonstrate an understanding of all these concepts by…
A: A program for Huffman coding to encrypt the data using priority queue, array, linked list and binary…
Q: Q# In Java, if you see a class name followed by “”, as in List, what does this mean? Group of answer…
A: List<T>: In java, we are using List for making the collection of objects. The idea of…
Q: Computer Science * must be done in java write a copy constructor for the following member variables…
A: INTRODUCTION: A copy constructor is a member function that uses another object of the same class to…
Q: Write a C++ program that creates and prints a linked list of classes. Base this program on what you…
A: Below is the C++ program: - Explanation: - Defining the header file and the namespace. Defining…
Q: Consider the doubly linked list below to answer the following: A) Write Java statements to delete…
A: NOTE: Answering only the first 3 subparts as per the guidelines. First, we will create the doubly…
Q: J Jane B Bill S Sam B1 Bob B2
A: We need to write a java code for build map object.
Q: Part B: Page I Your task for this assignment is to investigate some of the properties of queues. You…
A: Solution: Providing solution for your part b assignment:
Q: ** In Java please, This is the assignment, I have my classes working the place I am running into…
A: The code is given below:-
Q: 1S15 Suermarket rimalation) Write a program that simulates a check-cut line at supermarket. The line…
A: Program Plan Intro Program Plan- Include header files and declare required namespaces. Declare…
Q: Write a c++ program to simulate a coffee shop or a Mcdonald's drive-thru where different customers…
A: "#include <iostream> #include <queue> using namespace std; class Customer {…
Q: IN c++ See the specification of the HugeInt class. Complete the implementation of this class.…
A: HugeInt.h #ifndef HUGEINT_H_ #define HUGEINT_H_ enum SignType {PLUS, MINUS}; class HugeInt{…
Q: Given the UML diagram below implement the code in NetBeans. Account Main -ID: int -name: String…
A: public class Main { public static void main(String[] args) { Account a = new Account(1234,…
Q: rage Part B: Your task for this assignment is to investigate some of the properties of queues. You…
A: ANSWER:-
Q: Write a java program that reads a line of text input by the user and places each word in a TreeSet.…
A: TreeSet is an implementation of the Set interface that stores data in a tree. The objects are…
Q: Question 6 Identify the time complexity of the following code. def printColors(colorlist,…
A: This question comes from Algorithm which is a paper of Computer Science. Let's discuss it in the…
Q: 1. Write a Java program to create a new tree set, add colors ["RED","GREEN","BLACK","WHITE","PINK"]…
A: As per our company guidelines, we are not supposed to answer more than three subparts of post and…
Q: ava code Objectives •Use an abstract data type for a list •Use a method that contains an Object…
A: It is defined as the programs can be asked from control statements, array, string, oops etc. Java…
Q: In java The following is a class definition of a linked list Node: class Node { int info; Node…
A: Java program to implement linked list 5,7,9 and delete node with 5 and print remining linked list…
Q: can you help me to draw the flowchart for this java code:
A: circle is represent start of flow chart rounded rectangle represents end of flowchart diamond…
Q: Write a class that implements a card from a deck of cards. Use enum for suit and rank. Write a class…
A: Note :- As per our guidelines we are supposed to answer only one question. Next time please kindly…
Q: PROBLEM STATEMENT: Return a sublist of a given list from the range of the two integer inputs from,…
A: We need to define a java method FindSublistFromRange that returns a list of numbers between a…
Q: Use stacks from the STL to implement a video game library functionality. In this implementation,…
A: the code is an given below : #include<bits/stdc++.h>using namespace std; class…
Q: Java design a Queue with O(1) lookup time of the Maximum element. You will implement this…
A: Answer is given below:
Q: Java (Sort, IComparable) The librarian wants to sort the media in the ArrayList by title. For this…
A: Start Take the array of elements Sort that elements. Array list will be search for one element.…
Q: How do I implement a file with sets of numbers, such as 0 4 2 6 0 9 1 5 to an adjacency matrix
A: An adjacency matrix is a V x V binary matrix A (a binary matrix is a matrix in which the…
Q: Add the following method in the BST class that returns aniterator for traversing the elements in a…
A: 1. First create a class which will implement the iterator. 2. Implement the methods. 3. Set its…
Q: Which one is NOT an example of software reuse? A I have an abstract class Game, I will define…
A: Software reuse also known as Code reuse is the use of current software, or software information,…
Q: SCREEN 11 --- 3858888 888sasassssss 8888888 888ss8888s888 8888888 888S888888s8s 20 Example Input…
A: # Pre-requisites: Imports os,sys,logging libraries and inputParser program. # Loosely based on…
JAVA- PLZ HELP
Step by step
Solved in 2 steps with 3 images
- Course: Data Structure and Algorithims Language: Java Kindly make the program in 2 hours. Task is well explained. You have to make the proogram properly in Java and attach output screen with program: Restriction: Prototype cannot be change you have to make program by using given prototype. TAsk: classBSTNode { Node left; Node right; int data; publicBSTNode(int _data);// assign data to_data and assign left and right node to null } class BST { BSTNoderoot; public BST();// assign root to null void insert(int data);// this function insert the data in tree which maintain property of BST boolean Search(int key); this function search the data in bst and return true if key is found else return false public void EvenPrint(Node n)// this function only print the data which are even, make this function resursive public void OddPrint(Node n)// this function only print the data which are odd, make this function resursive public void PrimePrint(Node n)// this function only…IN JAVA Alice and Bob are playing a board game with a deck of nine cards. For each digit between 1 to 9, there is one card with that digit on it. Alice and Bob each draw two cards after shuffling the cards, and see the digits on their own cards without revealing the digits to each other. Then Alice gives her two cards to Bob. Bob sees the digits on Alice’s cards and lays all the four cards on the table in increasing order by the digits. Cards are laid facing down. Bob tells Alice the positions of her two cards. The goal of Alice is to guess the digits on Bob’s two cards. Can Alice uniquely determine these two digits and guess them correctly? Input The input has two integers p,q (1≤p<q≤9) on the first line, giving the digits on Alice’s cards. The next line has a string containing two ‘A’s and two ‘B’s, giving the positions of Alice’s and Bob’s cards on the table. It is guaranteed that Bob correctly sorts the cards and gives the correct positions of Alice’s cards. Output If Alice can…Java Code: In this assignment, we are going to start working on the parser. The lexer’s job is to make “words”, the parser’s job is to make sure that those tokens are in an order that makes sense and create a data structure in memory that represents the program. The Tokens are in a 1-dimensional structure (array or list). The parser’s output will be a 2-dimensional tree. The parser works using recursive descent. We are encoding the rules into the structure of the program. There are a few simple rules that we will follow in writing our parser: Each function represents some “phrase” in our language, like “if statement” or “assignment statement”. Each function must either succeed or fail: On success, remove Tokens from the list and output a tree node On failure, leave the list unchanged and return null. When there are alternatives, the function must call each alternative’s function until it finds one that is not null. Create a Parser class (does not derive from anything). It must…
- Course: Data Structure and Algorithims Language: Java Kindly make the program in 2 hours. Task is well explained. You have to make the proogram properly in Java: Restriction: Prototype cannot be change you have to make program by using given prototype. TAsk: Create a class Node having two data members int data; Node next; Write the parametrized constructor of the class Node which contain one parameter int value assign this value to data and assign next to null Create class LinkList having one data members of type Node. Node head Write the following function in the LinkList class publicvoidinsertAtLast(int data);//this function add node at the end of the list publicvoid insertAthead(int data);//this function add node at the head of the list publicvoid deleteNode(int key);//this function find a node containing "key" and delete it publicvoid printLinkList();//this function print all the values in the Linklist public LinkListmergeList(LinkList l1,LinkList l2);// this function…Student: Michael Reyes 2. Write a Java program that would resemble a payroll system. An input window that will accept the employee number and the number of days of rendered work. A 2d-ArrayList that contains the employee number and the rate per day is to be searched and used to compute the gross salary. Gross salary is computed by multiplying the number of days of rendered work by the rate per day of the particular employee. If the gross salary computed is greater than 100,000 the tax is 20% of the gross salary, otherwise, the tax is 10%. Deduct the tax from the gross salary to get the net pay. Display the employee number, gross salary, tax deduction, and net pay in an output window. Design your own input/output windows. (USE OOP CONCEPT JFRAME)Tour.java Create a Tour data type that represents the sequence of points visited in a TSP tour. Represent the tour as a circular linked list of nodes, one for each point in the tour. Each Node contains two references: one to the associated Point and the other to the next Node in the tour. Each constructor must take constant time. All instance methods must take time linear (or better) in the number of points currently in the tour. To represent a node, within Tour.java, define a nested class Node: private class Node { private Point p; private Node next; } Your Tour data type must implement the following API. You must not add public methods to the API; however, you may add private instance variables or methods (which are only accessible in the class in which they are declared). public class Tour // Creates an empty tour. public Tour() // Creates the 4-point tour a→b→c→d→a (for debugging). public Tour(Point a, Point b, Point c, Point d) // Returns the number of points in this tour. public…
- Maze Runner Function - Implementation of this function is done in a1_partd.py We describe a maze as having row x col cells. For example if row was 3, and col was 4, then we would have a grid of cells as follows. We describe a wall by the two cell numbers the wall separates. If every single wall existed, there would be (row-1)(col) + (col-1)(row) walls. 0 | 1 | 2 | 3 4 | 5 | 6 | 7 8 | 9 | 10 | 11 A Maze class (which you do not need to implement) describes a maze as mentioned above. This class is defined in maze.py. It has methods that you can use to travel through the maze (i.e. figure out where you are, find a neighbour cell etc.) use a recursive maze runner function: def find_path(maze, from_cell, to_cell); The find_path function will find a path from cell number from_cell to cell number to_cell and will return it as a list containing all the cell numbers along the path, from the from_cell to the to_cell. You are allowed to use this function as a wrapper to a recursive function that…Assume class LinkedQueue has been deńned using the implementation in your textbook that myQueue has been initialized so it is empty. Type the EXACT output of the following code segment. You may assume that the code compiles and executes without errors. LinkedQueue myQueue; int i - 1; int j = 2; int k = 3; int n = 4; myQueue.enqueue (n); myQueue.enqueue (); i = myQueue.peekFront (); myQueue.dequeue (); myQueue.enqueue (k); n = myQueue.peekFront (); myQueue.dequeue (); myQueue.enqueue (); myQueue.enqueue (n); while (ImyQueue.isEmpty ()) { i = myQueue.peekFront (); myQueue.dequeue (); cout << i<< " ": cout << endl;Write in C++ Alice is trying to monitor how much time she spends studying per week. She going through her logs, and wants to figure out which week she studied the least, her total time spent studying, and her average time spent studying per week. To help Alice work towards this goal, write three functions: min(), total(), and average(). All three functions take two parameters: an array of doubles and the number of elements in the array. Then, they make the following computations: min() - returns the minimum value in the array sum() - returns the sum of all the values in the array average() - returns the average of all the values in the array You may assume that the array will be non-empty. Function specifications: Function 1: Finding the minimum hours studied Name: min() Parameters (Your function should accept these parameters IN THIS ORDER): arr double: The input array containing Alice's study hours per week arr_size int: The number of elements stored in the array Return Value:…
- 3. Card Flipper: You walk into a room, and see a row of n cards. Each one has a number x; written on it, where i ranges from 1 to n. However, initially all the cards are face down. Your goal is to find a local minimum: that is, a card i whose number is less than or equal to those of its neighbors, xj-1 = X; <= Xj+1. The first and last cards can also be local minima, and they only have one neighbor to compare to. There can be many local minima, but you are only responsible for finding one of them. Obviously you can solve this problem by turning over all n cards, and scanning through them. However, show that you can find such a minimum by turning over only O(log n) cards.C++ in visual studio: Implement it completely with copy constructor, overloaded assignment operator and destructor. Then, in main, type an application that creates 2 numbers, sums them, and assigns the result to a new number. for example ; Number 1 (18,32) Number 2 (15.09) - - - - - - - - - - - + Number 3 ( 33,41)Write Java Program Mr. Patrick is fond of reading books he is looking for a computerized way to keep record of his book collection, you have been given the responsibility to meet up his following requirements. (Use appropriate data structure to accomplish your task), develop following methods: 1. Add(): adds a new book to the list ( A book contains name of the book, author name) NOTE: every new book will have access to its neighboring books (previous and next) 2. Remove():in case any book is removed from the pile update your list 3. countBooks(): displays the total number of books 4. search(): returns true if the given book is present in the list else returns false 5. display(): shows the book collection