1.Instead of Build-Max-Heap, we could use Heap-Insert-Max to
build a tree with heap property. Write a pseudocode for that
procedure, also evaluate it’s time complexity.
2. How Insertion sort works on the following array
[16, 12, 3, 27, 9, 4, 5, 7]]
In: Computer Science
explain why using email address as the primary key for Staff is a bad idea
In: Computer Science
(C++)Counting Sort: Write C++ codes for counting sort. The input array is A = {20, 18, 5, 7, 16,
10, 9, 3, 12, 14, 0}
In: Computer Science
Describe how to select various cable media and network interface cards (NIC) options for your own home network configuration. Be sure to discuss what you would want for the optimal situations for your network. Brainstorm with other students to improve upon their optimal situation or provide an alternative idea for their situation.
In: Computer Science
I need this written in Java, it is a Linked List and each of it's Methods. I am having trouble and would appreciate code written to specifications and shown how to check if each method is working with an example of one method being checked. Thank you. public interface Sequence <T> { /** * Inserts the given element at the specified index position within the sequence. The element currently at that * index position (and all subsequent elements) are shifted to the right. * * @param index the index at which the given element is to be inserted * @param x the element to insert * @return {@code true} if and only if adding the element changed the sequence * @throws IndexOutOfBoundsException if the index is invalid {@code (index < 0 || index > size())} * @throws NullPointerException if the given element is {@code null} */ boolean add(int index, T x) throws IndexOutOfBoundsException, NullPointerException; /** * Adds the specified element to the end of the sequence. * * @param x the element to add * @return {@code true} if and only if adding the element changed the sequence * @throws NullPointerException if the given element is {@code null} */ boolean add(T x) throws NullPointerException; /** * Removes all of the elements from the sequence. */ void clear(); /** * Check if the given element belongs to the sequence. * * @param x the element to check for * @return {@code true} if and only if the sequence contains the given element * @throws NullPointerException if the given element is {@code null} */ boolean contains(T x) throws NullPointerException; /** * Returns the element at the given position in the sequence. * * @param index the index of the element to return * @return the element at the given position in the sequence * @throws IndexOutOfBoundsException if the index is invalid {@code (index < 0 || index >= size())} */ T get(int index) throws IndexOutOfBoundsException; /** * Returns the index position of the first occurrence of the given element within the sequence or -1 if it does not * belong. * * @param x the element to search for * @return the index position of the first occurrence of the given element within the sequence or -1 if it does not * belong * @throws NullPointerException if the given element is {@code null} */ int indexOf(T x) throws NullPointerException; /** * Check if the sequence is empty. * * @return {@code true} if and only if the sequence is empty. */ boolean isEmpty(); /** * Removes the element at the given position in the sequence. * * @param index the index position of the element to be removed * @return the element at the given position in the sequence * @throws IndexOutOfBoundsException if the index is invalid {@code (index < 0 || index >= size())} */ T remove(int index) throws IndexOutOfBoundsException; /** * Remove the first occurrence of the given element from the sequence (if present). * * @param x the element to be removed from this list * @return {@code true} if and only if removing the element changed the sequence * @throws NullPointerException if the given element is {@code null} */ boolean remove(T x) throws NullPointerException; /** * Replaces the element at the given position of the sequence with the specified element. * * @param index index of the element to replace * @param x the new element * @throws IndexOutOfBoundsException if the index is invalid {@code (index < 0 || index >= size())} * @throws NullPointerException if the given element is {@code null} */ void set(int index, T x) throws IndexOutOfBoundsException, NullPointerException; /** * Returns the number of elements in this sequence. * * @return the number of elements in this sequence */ int size(); /** * Returns an array containing all of the elements in this sequence (preserving their order). * * @return an array containing all of the elements in this sequence (preserving their order) */ Object[] toArray(); }
In: Computer Science
(C++)Radix Sort: Write C++ codes for radix sort: use counting sort for decimal digits from
the low order to high order. The input array is A = {329, 457, 657, 839, 436, 720, 353}
In: Computer Science
Write a program, called NationalTax, that will simulate calculating a citizen's income tax for the year.
A country uses lettered ID's to identify its citizens. Valid ID's will be either 8 or 9 characters long. All characters entered will be alphabetic characters only (a-z or A-Z).
In: Computer Science
Part 1: Write a program that finds the sum and average of a series of numbers entered by the user. The program will first ask the user how many numbers there are. It then prompts the user for each of the numbers in turn and prints out the sum, average, the list of number from the user. Note: the average should always be a float, even if the user inputs are all ints.
Part 2: Same as part 1 except now the numbers are to
be read in from a file.
File contains a single line of numbers delimited by comma. Example:
8, 39, 43, 1, 2, 3
Part 3: Part 2 but modular ( i.e. using
functions).
Assume the file name is passed to the function as a parameter. The
function then opens the file, reads in the numbers, then computes
and returns the sum and average of the numbers.
In: Computer Science
c++
You will implement a template class with the following members:
Additionally you will need to create a short driver program that demonstrates your template class working with a few different numeric data types.
In: Computer Science
I'm having trouble determining the lines of code for 4-6
#include <stdio.h>
//function prototypes
void initializeArray(int size, int ids[]);
void printArray(int size, int * idPointer);
int main(void) {
// 1. declare an array of 5 integers called ids
int ids[1,2,3,4,5];
// 2. declare an integer pointer called arrayPointer and
// initialize it to point to the array called ids
int *arrayPointer = ids;
// 3. call initializeArray() function sending to it
// 5 for the size and the array called ids
intializeArray(5,ids[]);
// 4. add 3 to the value at where arrayPointer is pointing to
*(arrayPointer + 3);
// 5. add 5 to the value at 2 locations past
// where arrayPointer is pointing to
// 6. call printArray() function sending to it
// 5 for the size and arrayPointer
return 0;
}
// This function initializes an array ids of size "size"
void initializeArray(int size, int ids[]) {
int i;
for (i = 0; i < size; i++) {
ids[i] = i * 100;
}
}
// This function prints an array of size "size". The array is
pointed at by idPointer
void printArray(int size, int * idPointer) {
int i;
for (i = 0; i < size; i++) {
// 7. finish the code for the printf() statement
printf("Element at index %d is %d\n", i);
}
}
In: Computer Science
Create a class named Purchase. Each Purchase contains an invoice number, amount of sale, and amount of sales tax. Include set methods for the invoice number and sale amount. Within the set() method for the sale amount, calculate the sales tax as 5% of the sale amount. Also include a display method that displays a purchase’s details.
Here is the provided code:
import java.util.*;
public class CreatePurchase
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
Purchase purch = new Purchase();
int num;
double amount;
String entry;
final int LOW = 1000, HIGH = 8000;
System.out.println("Enter invoice number");
entry = input.next();
num = Integer.parseInt(entry);
while(num <= LOW || num >= HIGH)
{
System.out.println("Invoice number must be between " +
LOW + " and " + HIGH + "\nEnter invoice number");
entry = input.next();
num = Integer.parseInt(entry);
}
System.out.println("Enter sale amount");
entry = input.next();
amount = Double.parseDouble(entry);
while(amount < 0)
{
System.out.println("Enter sale amount");
entry = input.next();
amount = Double.parseDouble(entry);
}
purch.setInvoiceNumber(num);
purch.setSaleAmount(amount);
purch.display();
}
}
------------------------------------------------------------------------------------------------
Other Class:
_--_____________________________
public class Purchase {
private int invoiceNumber;
private double saleAmount;
private double tax;
private static final double RATE = 0.05;
public void setInvoiceNumber(int num) {
}
public void setSaleAmount(double amt) {
}
public double getSaleAmount() {
}
public int getInvoiceNumber() {
}
public void display() {
System.out.println("Invoice #" + invoiceNumber +
" Amount of sale: $" + saleAmount + " Tax: $" + tax);
}
}
pls help
In: Computer Science
Displaying Content of an XML File Using PHP Script or Code
In this week, you are going to write the PHP script or code to read an XML file and display its content on the screen. The file you will modify is the Products page, which you created in Week 1 Project. Given the following data in XML format, modify the Products page to read and display the information in the Products page:
<Product>
<Item>
<Name>T-Shirt</Name>
<Price>12.5</Price>
</Item>
<Item>
<Name>Pants</Name>
<Price>45</Price>
</Item>
<Item>
<Name>Hat</Name>
<Price>10.5</Price>
</Item>
</Product>
Your end page result needs to show the items, their cost (price) in a table format. Use both PHP script as well as HTML tags to create the dynamic table from the given XML file.
In: Computer Science
**Complete for display digits 0 and 7 only**
A combinational circuit is used to control a seven-segment display of decimal digits, as shown in Figure 11.35. The circuit has four inputs, which provide the four-bit code used in packed decimal representation (010 = 0000,c, 910 = 1001). The seven outputs define which segments will be activated to display a given decimal digit. Note that some combinations of inputs and outputs are not needed. a. Develop a truth table for this circuit. b. Express the truth table in SOP form. c. Express the truth table in POS form. d. Provide a simplified expression.
In: Computer Science
Code in Java
In Chapter 9, we created the CommissionEmployee-BasePlusCommissionEmployee inheritance hierarchy to model the relationship between two types of employees and how to calculate the earnings for each. Another way to look at the problem is that CommissionEmployees and BasePlusCommissionEmployees are each Employees and that each has a different CompensationModel object.
A CompensationModel would provide an earnings method. Classes or subclasses of CompensationModel would contain the details of a particular Employee's compensation:
Each of these classes would contain a toString() method that displays the Compensation Model information as illustrated in the sample output.
This approach is more flexible than our original hierarchy. For example, consider an Employee who gets promoted. With the approach described here, you can simply change that Employee's CompensationModel by assigning the composed CompensationModel reference an appropriate subclass object. With the CommissionEmployee - BasePlusCommissionEmployee hierarchy, you'd need to change the Employee's type by creating a new object of the appropriate class and moving data from the old object to the new one.
Implement the Employee class and CompensationModel hierarchy discussed in this exercise. In addition to the firstName, lastName, socialSecurityNumber and CommisionCompensationModel instance variables, class Employee should provide:
Your code in the subclasses should call methods in the super classes whenever possible to reduce the amount of code in the subclasses and utilize the code already developed in the super classes as in the code demonstrated in Figures 9.10 and 9.11 in the book.
Use the following code in your main function to test your classes, just copy and paste it into your main method:
// Create the two
employees with their compensation models.
CommissionCompensationModel commissionModel = new
CommissionCompensationModel(2000.00, 0.04);
BasePlusCommissionCompensationModel basePlusCommissionModel = new
BasePlusCommissionCompensationModel(2000.00, 0.05, 600.00);
Employee employee1 = new
Employee("John", "Smith", "111-11-1111", commissionModel);
Employee employee2 = new
Employee("Sue", "Jones", "222-22-2222",
basePlusCommissionModel);
System.out.printf("%s%n%s%n", employee1, employee2);
System.out.printf("%s%s%s%s%s%8.2f%n%n", "Earnings for ",
employee1.getFirstName(), " ", employee1.getLastName(), ": ",
employee1.earnings());
// Change the
compensation model for the two employees.
CommissionCompensationModel commissionModelNew = new
CommissionCompensationModel(5000.00, 0.04);
BasePlusCommissionCompensationModel basePlusCommissionModelNew =
new BasePlusCommissionCompensationModel(4000.00, 0.05,
800.00);
// Set the new
compensation models for the employees.
employee1.setCompensation(basePlusCommissionModelNew);
employee2.setCompensation(commissionModelNew);
// Print out the new
information for the two employees.
System.out.printf("%s%n%s%n", employee1, employee2);
The output from your program should look like the following:
run:
John Smith
Social Security Number: 111-11-1111
Commission Compensation with:
Gross Sales of: 2000.00
Commission Rate of: 0.04
Earnings: 80.00
Sue Jones
Social Security Number: 222-22-2222
Base Plus Commission Compensation with:
Gross Sales of: 2000.00
Commission Rate of: 0.05
Base Salary of: 600.00
Earnings: 700.00
Earnings for John Smith: 80.00
John Smith
Social Security Number: 111-11-1111
Base Plus Commission Compensation with:
Gross Sales of: 4000.00
Commission Rate of: 0.05
Base Salary of: 800.00
Earnings: 1000.00
Sue Jones
Social Security Number: 222-22-2222
Commission Compensation with:
Gross Sales of: 5000.00
Commission Rate of: 0.04
Earnings: 200.00
In: Computer Science
In An Introduciton to Programmig Using Visual Basic tenth edition chapter 6 the 4th project program has me using loops. I am having a hard time trying to figure out what the double declining balance methods depreciation value is. It is 2 divided by the items life, but multiplied by the previous years balance. I do not know how to find the previous years balance to use in the depreciation value. Thank you
In: Computer Science