Questions
Data Structure 6. Write a recursive routine that will have an integer array and an index...

Data Structure

6. Write a recursive routine that will have an integer array and an index as parameters and will return the count of all odd integers. You may assume that the index starts out at the END of the array.

12. Write the implementation function for ArrayBag in C++, called bagLess, that takes an ItemType of item as parameters and use it count items in the current bag that are less than the item (hint: use toVector)

13. Write a sum function in C++ for LinkedBag of integers (must use pointers to traverse the linked list) that will return a sum of all values.

15. Write a Grammar that starts with a letter or a group of letters (assume uppercase), has an '?' or '!', and ends with a letter or a group of letters (uppercase)

16.

Given: e + f / (a – b) * c

Write out the prefix form

In: Computer Science

Using Java Write a program that reads a file of numbers of type int and outputs...

Using Java

Write a program that reads a file of numbers of type int and outputs all of those numbers to another file, but without any duplicate numbers. You should assume that the input file is sorted from smallest to largest with one number on each line. After the program is run, the output file should contain all numbers that are in the original file, but no number should appear more than once. The numbers in the output file should also be sorted from smallest to largest with one number on each line.

Your program should not assume that there is a fixed number of entries to be read, but should be able to work with any number of entries in both the input and output files.

- Do not use arrays, lists, arraylists, linked lists, sets, maps, trees, or any other multi-element data structure.

program should read in and write out numbers from the input and output files at the same time, eliminating duplicates from the output file as you go.

Your program should obtain both file names from the user. For the original (input) file, create a text file that stores one number per line with several duplicates in sorted order. The output file should be created by your program. When completed, your program should display on the console:

  1. a count of numbers in the input file
  2. a count of the numbers in the output file
  3. and the number of duplicates found in the input file

Sample console dialog, where input from the user is underlined in italics

  Enter input file name or full path: numbers.txt
  Enter output file name or full path: output.txt
  There were 18 numbers input, 10 output, and 8 duplicates.  

In: Computer Science

please provide steps as you solve the question. >>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>

please provide steps as you solve the question.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>>>>>>>>>>>>>>>>>>>>>>>>>>>

Prove that the following languages are not regular using the pumping lemma.

a. ? = {? ?? ?? ? | ?, ? ≥ ?}

b. ? = {? ∈ {?, #} ∗ | ? = ??#??# … #?? ??? ? ≥ ?, ?? ∈ ? ∗ ??? ????? ?, ??? ?? ≠ ?? ??? ????? ? ≠ ?

} Hint: choose a string ? ∈ ? that contains ? #’s.

In: Computer Science

python: modify an image (just show me how to write the two functions described below) 1.One...

python: modify an image (just show me how to write the two functions described below)

1.One way to calculate the contrast between two colours is to calculate the brightness of the top pixel (the average of the red, green and blue components, with all three components weighted equally), and subtract the brightness of the pixel below it. We then calculate the absolute value of this difference. If this absolute value is greater than a threshold value, the contrast between the two pixels is high, so we change the top pixel's colour to black; otherwise, the contrast between the two pixels is low, so we change the top pixel's colour to whiteDevelop a filter named detect_edges that returns a copy of an image, in which the copy has been modified using the edge detection technique described in the preceding paragraphs. This filter has two parameters: an image and a threshold, which is a positive number.

2.As before, we calculate the contrast of two pixels by subtracting the brightness values of the pixels and calculating the absolute value of the difference. We change a pixel's colour to black only if the contrast between the pixel and the one below it is high (i.e., the absolute value of the difference exceeds the filter's threshold attribute) or the contrast between the pixel and the one to the right of it is high. Otherwise, we change the pixel's colour to white.


  1. A simple algorithm for performing edge detection is: for every pixel that has a pixel below it, check the contrast between the two pixels. If the contrast is high, change the top pixel's colour to black, but if the contrast is low, change the top pixel's colour to white. For the bottom row (which has no pixels below it), simply set the pixel to white.

In: Computer Science

In Java...create a class Realestate.java with the following fields: location, price, and description. Create a class...

In Java...create a class Realestate.java with the following fields: location, price, and description. Create a class RealestateFinder.java that reads in real estate data from a CSV file (RealestateList.csv). Then provide the user with the following options: Sort per Price, Sort per Location, and Exit. Use ArrayList and Arrays.sort to perform the sorts and display the data to the user.

In: Computer Science

How many total bits are required for a 1-way set associative cache with 16 KB of...

How many total bits are required for a 1-way set associative cache with 16 KB of data and 8-word blocks, assuming a 32-bit address?

In: Computer Science

Please no plagiarism. Must be in your own words. Do you feel that countries and companies...

Please no plagiarism. Must be in your own words.

Do you feel that countries and companies need explicit strategies for technology development, given the tremendous amount of largely spontaneous creativity that occurs today, often in areas where new technologies are not expected to exert a great influence? Why or why not?

In: Computer Science

There are threats all around us, so it is essential to have a robust plan in...

There are threats all around us, so it is essential to have a robust plan in place to help mitigate the damage to a business from these threats. Select any one of the threats that have been covered in the Business Continuity Chapter of the text and develop a Disaster Recovery Plan (DRP). The plan at a minimum should include a summary of the threat, a risk assessment, a mitigation strategy, how you will restore the IT resource, and contingencies. The DRP should be no longer then 500-750 words.

In: Computer Science

WRITE THIS JAVA CODE IN PSEUDOCODE!! import java.util.Scanner; public class License { public static void main(String[]...

WRITE THIS JAVA CODE IN PSEUDOCODE!!

import java.util.Scanner;

public class License {

    public static void main(String[] args) {

        char correctAnswers[] = {'B', 'D', 'A', 'A', 'C', 'A', 'B', 'A', 'C', 'D', 'B', 'C', 'D', 'A', 'D', 'C', 'C', 'B', 'D', 'A'};
        char userAnswers[] = new char[correctAnswers.length];


        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < userAnswers.length; i++) {

            String answer = "";
            System.out.printf("Question #%d. Enter your answer( A, B, C or D): ", i + 1);
            do {
                answer = scanner.nextLine();
                if (!(answer.equals("A") || answer.equals("B") || answer.equals("C") || answer.equals("D"))) {
                    System.out.print("You didnt enter it A, B, C or D. Enter again: ");
                }

            } while (!(answer.equals("A") || answer.equals("B") || answer.equals("C") || answer.equals("D")));

            userAnswers[i] = answer.charAt(0);
        }

        int correctlyAnswered = getCorrectAnswerCount(correctAnswers, userAnswers);
        System.out.printf("\nYou answered %d questions correctly.\n", correctlyAnswered);
        System.out.printf("You answered %d questions incorrectly.\n\n", userAnswers.length - correctlyAnswered);

        if (correctlyAnswered != userAnswers.length) {
            displayIncorrectlyAnsweredQuestions(correctAnswers, userAnswers);
        }
        if(correctlyAnswered>=15) System.out.println("You have cleared the exam. Congratulations.");
        else System.out.println("You have failed the exam. Sorry!");

    }

    private static void displayIncorrectlyAnsweredQuestions(char[] correctAnswers, char[] userAnswers) {
        System.out.print("Questions Wrongly Answered: ");
        for (int i = 0; i < correctAnswers.length; i++) {
            if (correctAnswers[i] != userAnswers[i]) System.out.print((i + 1) + " ");
        }
        System.out.println();
    }

    private static int getCorrectAnswerCount(char[] correctAnswers, char[] userAnswers) {
        int count = 0;
        for (int i = 0; i < correctAnswers.length; i++) {
            if (correctAnswers[i] == userAnswers[i]) count += 1;
        }
        return count;
    }
}

In: Computer Science

Clearly in an environment of the internet of things and the fog of the internet, traditional...

Clearly in an environment of the internet of things and the fog of the internet, traditional firewalls and traditional cyber security methodology is insufficient to protect critical infrastructure and industry from cyber-attacks. In a substantive post (at least 250 words or greater) Develop your model of what a successful cyber defense should be, and substantiate your argument.

In: Computer Science

Assume that you have a linked list of records. Assume that you have a head, a...

Assume that you have a linked list of records. Assume that you have a head, a current, and a tail pointer. Write an algorithm that DELETES the node BEFORE the current node. You can use pseudo-code, English or drawing to describe your solution.( this was, and remains to be, a popular technical interview question)

In: Computer Science

using java with proper header and comments: This exercise will give you a review of Strings...

using java with proper header and comments:

This exercise will give you a review of Strings and String processing. Create a class called MyString that has one String called word as its attribute and the following methods: Constructor that accepts a String argument and sets the attribute. Method permute that returns a permuted version of word. For this method, exchange random pairs of letters in the String. To get a good permutation, if the length of the String is n, then perform 2n swaps. Use this in an application called Jumble that prompts the user for a word and the required number of jumbled versions and prints the jumbled words. For example, Enter the word: mixed Enter the number of jumbled versions required: 10 xdmei eidmx miexd emdxi idexm demix xdemi ixdme eximd xemdi xdeim Notes: 1. It is tricky to swap two characters in a String. One way to accomplish this is to convert your String into an array of characters, swapping the characters in the array, converting it back to a String and returning it. char[] chars = word.toCharArray(); will convert a String word to a char array chars. String result = new String(chars); converts a char array chars into a String. p 6 2. Use Math.random to generate random numbers. (int)(n*Math.random()) generates a random number between 0 and n-1

In: Computer Science

Fill in the code for the following C functions. Function srl performs a logical right shifting...

Fill in the code for the following C functions. Function srl performs a logical right shifting using arithmetic right shift (given by value xsra), followed by other operations not including right shifts or division. Function sra performs an arithmetic right shift using a logical right shift (given by value xsrl), followed by other operations not including right shift or division. you may use the computation 8*size of (int) to determine w, the number of bits in data type int. The shift amount k can change from 0 to w-1.

unsigned srl (unsigned x, int k){

unsigned xsra = (int) x>> k;

.

.

.

}

int sra (int x, int k){

int xsrl = (unsigned) x >> k;

.

.

.

}

In: Computer Science

Please Fix Syntax Error import java.util.Scanner; public class SalaryCalc {    double Rpay = 0, Opay...

Please Fix Syntax Error

import java.util.Scanner;

public class SalaryCalc {
   double Rpay = 0, Opay = 0;

   void calPay(double hours, double rate) {
       if (hours <= 40) {
           Rpay = hours * rate;
           Opay = 0;
       } else {
           double Rhr, Ohr;
           Rhr = 40;
           Ohr = hours - Rhr;
           Rpay = Rhr * rate;
           Opay = Ohr * (1.5 * rate);
       }
   }

   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       String name;
       int shift = 0;
       Double rate, hours;
       System.out.println("Pay Calculator");
       String ch = "";
       //added loop here to take the inputs repetedly
       do {
           System.out.println("Enter Your Name");
           name = sc.next();
           System.out.println("Enter Your Shift, Enter 0 for Day, Enter1 for Night");
           System.out.println("0=Day, 1= Night");
           shift=sc.nextInt();
           System.out.println("Enter Number of Hours Worked");
           hours = sc.nextDouble();
           System.out.println("Enter Hourly Pay");
           rate = sc.nextDouble();
           SalaryCalc c = new SalaryCalc();
           c.calPay(hours, rate);
           Double Tpay = c.Rpay + c.Opay;
           System.out.println();
           System.out.println("Calculate Pay");
           System.out.println("Employee Name: " + name);
           System.out.println("Employee Regular Pay: " + c.Rpay);
           System.out.println("Employee Overtime Pay: " + c.Opay);
           System.out.println("Employee Total Pay: " + Tpay);
           if (shift == 0) {
               System.out.println("Employee PayPeriod is Friday");
           } else {
               System.out.println("Employee PayPeriod is Saturday");
           }
           //asking user if they want to continue to enter another employee data
           System.out.println("Press Y to continue.Other key to exit ");
           ch=sc.next();
       } while (ch.equalsIgnoreCase("y"));
   }
}

In: Computer Science

Project Outcomes: Develop a python program that uses:  decision constructs  looping constructs  basic...

Project Outcomes:
Develop a python program that uses:
 decision constructs
 looping constructs
 basic operations on an list of objects (find, change, access all elements)
 more than one class and has multiple objects
Project Requirements:
1. Develop a simple Hotel program. We will have two classes, a Hotel class
representing an individual hotel and a Room class. The Hotel class will contain several
Room objects and will have several operations. We will also have a driver program to test
the Hotel class.
2. Build a Hotel class that will store information about a Hotel. It will include a name and
location. It should also include a list of class Room to hold information about each
room. It will also have a int called occupiedCnt that keeps track of how many rooms in
the hotel are occupied.
Specific Requirements for the Hotel Class:
1. The Hotel class has two constructors
1. __init__ function, will read in the hotel name and location from hard-coded
values in the tester class, such as Beach Marriot Pensacola, it will also assign
numOfRooms to zero.  numOfRooms indicates how many rooms are in the hotel.
It will create a 10 element array.

2. The Hotel will have an addRoom method that will create each room with the required
information: room number, bed type, smoking/non-smoking, and the room rate. Create at
least 5 rooms with different characteristics. Each room will also have a boolean field
called occupied attribute that will be set to false when the room is created. Don&#39;t forget
to increment the numOfRooms instance variable.  Example values for the rooms are:
101 queen s 100
102 king n 110
103 king n 88
104 twin s 100
105 queen n 99
3. The UML class diagram for the Hotel class will look like this:

Hotel

theRooms: Array Room[]
name: String
location: String
occupiedCnt: int
numOfRooms: int

def __init(self)__(String,String)
def isFull(self) : boolean
def isEmpty(self) : boolean
def addRoom(self ,roomnumber,bedtype,smoking,price)
def addReservation(self,occupantName ,smoking,
bedtype)
def cancelReservation(self,occupantName)
def findReservation(self,occupantName):
def printReservationList(self)
def getDailySales(self) :
def occupancyPercentage(self) :
Setters and getters methods for name and location.


4. isFull() – returns a boolean that is true if all the rooms in the hotel are occupied.
5. isEmpty() – returns a boolean that is true if all the rooms in the hotel are unoccupied.
6. The addReservation() method takes three parameters: the occupant’s name
(String), smoking or non-smoking request (char), and the requested bed type (String).
When this method is called, the hotel will search the list of its rooms for one that matches
the bed type and smoking/non-smoking attributes. If an unoccupied room with the correct
attributes is found, the renter&#39;s name will be set and the occupied attribute will be set
to true. In either case a message will be printed that will state whether or not the
reservation was made.
7. When the cancelReservation() method executes, the hotel will search for the
name of the visitor in each room. If it is found, the occupied attribute will be set to false.
In either case a message will state whether or not the reservation was cancelled. This
method calls the private utility method findReservation()to scan the list of rooms
looking for a guest by name. It will return the index of the room in the Array of rooms
or NOT_FOUND if the room is not found, which will be declared as:
NOT_FOUND = -1;
8. findReservation() will take in a String representing the occupant’s name and
search the occupied rooms for a reservation with that person’s name. It will return the
index of the room or NOT_FOUND if not found.
9. printReservationList() will scan through all the rooms and display all details
for only those rooms that are occupied. For example:

Room Number: 102
Occupant name: Pinto
Smoking room: n
Bed Type: king
Rate: 110.0
Room Number: 103
Occupant name: Wilson
Smoking room: n
Bed Type: king
Rate: 88.0
10. getDailySales() will scan the room list, adding up the dollar amounts of the room
rates of all occupied rooms only.
11. occupancyPercentage() will divide occupiedCnt by the total number of rooms to
provide an occupancy percentage.
12. __str__ – returns a nicely formatted string giving hotel and room details (by calling
the __str__ in the Room class) for all the rooms in the hotel. For example:
Hotel Name : Beach Marriot
Number of Rooms : 5
Number of Occupied Rooms : 1

Room Details are:

Room Number: 101
Occupant name: Not Occupied
Smoking room: s
Bed Type: queen
Rate: 100.0
Room Number: 102
Occupant name: Coffey
Smoking room: n
Bed Type: king
Rate: 110.0
Room Number: 103
Occupant name: Wilson
Smoking room: n
Bed Type: king
Rate: 88.0
Room Number: 104
Occupant name: Not Occupied

Smoking room: s
Bed Type: twin
Rate: 100.0
Room Number: 105
Occupant name: Not Occupied
Smoking room: n
Bed Type: queen
Rate: 99.0


13. The Room class diagram will look like this:

Room

roomNum: int
bedType: String
rate: double
occupantName: String
smoking: char
occupied: boolean
def __init__(int,String,char,double)
def getBedType(): String
def getSmoking(): char       
def getRoomNum(): int
def getRoomRate(): double
def getOccupant(): String
def setOccupied(boolean)
def setOccupant(String)
def setRoomNum(int)
def setBedType(String)
def setRate(double)
def setSmoking(char)
def isOccupied(): boolean

1. The __init__() for a Room takes an int (room number), String (bed type), char (s or n for
smoking or non-smoking)), and a double (room rate).
2. isOccupied() method returns true if the room is occupied, false otherwise.

3. __str__() provides all the details of a room - room number, name of guest(if
occupied) , bed type, smoking/non-smoking, rental rate. This should all be formatted
nicely with one attribute on each line using the &#39;\n&#39; escape character. See example above.
4. Several accessor and mutator methods for the Room class.

# Use list to store the room details.
You have to store required data in the list/database. You can store hotel name, address, and
all rooms. Customer data in database tables.

In: Computer Science