Questions
Implement an iterator that produces the moves for the Towers of Hanoi puzzle described in Worked...

Implement an iterator that produces the moves for the Towers of Hanoi puzzle described in Worked Example 11.2. Provide functions has_more_moves and next_move. The next_move function should yield a string describing the next move. For example, the following code prints all moves needed to move five disks from peg 1 to peg 3:

DiskMover mover(5, 1, 3);
while (mover.has_more_moves())
{
   cout << mover.next_move() << endl;
}

Hint: A disk mover that moves a single disk from one peg to another simply has a next_move function that returns a string

Move disk from peg source to target

A disk mover with more than one disk to move must work harder. It needs another DiskMover to help it move the first d – 1 disks. Then next_move asks that disk mover for its next move until it is done. Then the next_move function issues a command to move the dth disk. Finally, it constructs another disk mover that generates the remaining moves.

It helps to keep track of the state of the disk mover:

•BEFORE_LARGEST: A helper mover moves the smaller pile to the other peg.

•LARGEST: Move the largest disk from the source to the destination.

•AFTER_LARGEST: The helper mover moves the smaller pile from the other peg to the target.

•DONE: All moves are done.

In: Computer Science

1. Explain the process used to preserve the verifiable integrity of digital evidence. How does this...

1. Explain the process used to preserve the verifiable integrity of digital evidence. How does this ensure that data is preserved unmodified? How can an analyst show that the original evidence is modified?

2. What are the major principles of risk analysis? List the common steps in developing a risk analysis strategy.

In: Computer Science

C question Using a for-loop: (a) calculate the length of a string, (b) find a word...

C question

Using a for-loop: (a) calculate the length of a string, (b) find a word in a string

In: Computer Science

Create pseudocode for a program for Stumpy's Cell Phone Company that accepts the number of text...

Create pseudocode for a program for Stumpy's Cell Phone Company that accepts the number of text messages for a customer for one month and displays the bill for text messages.

If the user enters a negative number the program should display an error message.

If the user enters number greater than or equal to 0 your program should call a function that given the number of text messages, returns the amount to be charged. The program will then display a message stating the amount of the monthly bill for text messages.

Stumpy's charges customers a basic rate of $5 per month for their text message service. Additional rates are as follows:

The first 60 messages per month, regardless of message length, are included in the basic bill.

An additional five cents is charged for each text message after the 60th message, up to and including 180 messages.

An additional 10 cents is charged for each text message after the 180th message.

Federal, state, and local taxes add a total of 12 percent to each bill.

In: Computer Science

You have been hired by a small company to install a simple LAN for their 18...

You have been hired by a small company to install a simple LAN for their 18 Windows computers. Develop a simple LAN and determine the total cost; that is, select the cables, hubs/switches, and NICs and price them. Assume that the company has no network today and that the office is small enough that you don’t need to worry about cable length. (15).

In: Computer Science

Design a program using pseudocode to produce a report showing recommended sale prices. The program should...

Design a program using pseudocode to produce a report showing recommended sale prices. The program should ask the user to enter the item number, last sale date, number of items on hand, current date, item cost and the regular selling price. The program will output the item number, last sale date, days elapsed, number of item on hand, item cost, regular selling price and sales price. If the item has not been placed on sale for the last 30 days, the discount is 10% If the item has not been placed on sale for the last 31 to 60 days, the discount is 20% If the item has not been placed on sale for the last 61 to 90 days, the discount is 40% If the item has not been placed on sale in over 90 days, the discount is 50%

how can answer this question in the easiest way and simple way possible

In: Computer Science

Write a program in PERL language that does the following: a. Generates 100 random numbers between...

Write a program in PERL language that does the following:

a. Generates 100 random numbers between -17 and +31.

b. Calculates the average of the square of the generated numbers using a function that you implement.

c. Calculates the number of numbers greater than the average using a function that you implement.

d. Prints the results single line separated by spaces using a print function that makes call to the previously defined functions in parts b) and c).

In: Computer Science

Write a java program that prompts user to enter his name and KSU ID using format...

Write a java program that prompts user to enter his name and KSU ID using format name-ID as one value, his gender as char, and his GPA out of 5. Then your program should do the following:

Print whether the ID is valid or not, where a valid ID should be of length = 9, and should start with 4.
Calculate the GPA out of 100 which is calculated as follows GPA/5 * 100.
Update the name after converting the first letter to uppercase.
Print “Mr.” before name if the gender is ‘M’, and print “Mrs.” before name if the gender is ‘F’. Otherwise print message “invalid gender” without name and GPA. Then print the new GPA.

In: Computer Science

Outcomes: • Write a Java program that implements linked list algorithms can u also show thee...

Outcomes: • Write a Java program that implements linked list algorithms

can u also show thee testing code

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This is the starter code

import java.util.NoSuchElementException;

// Put your prologue comments here

public class LinkedAlgorithms {

  
   private class Node {
       private String data;
       private Node next;

       private Node(String data) {
           this.data = data;
           this.next = null;
       }
   }

   public Node head;
   public int numItems;

   /**
   * Creates the empty list.
   */
   public LinkedAlgorithms() {
   }

   /**
   * Creates a list containing all the elements of the passed array.
   * {@code data[0]} will be the first element of the list, {@code data[1]} will
   * be the second element of the list, and so on.
   *
   * @param data The array of values
   * @throws NullPointerException - data is null
   */
   public LinkedAlgorithms(String[] data) {
   }

   /**
   * Constructs a deep copy of the linked list {@code original}
   *
   * @param original The list to be copied
   * @throws NullPointerException - original is null
   */
   public LinkedAlgorithms(LinkedAlgorithms original) {
   }

   /**
   * Returns array with all the elements.
   *
   * @return Array containing all elements.
   */
   public String[] toArray() {
       return null;
   }

   /**
   * Formats the elements in the list using leading and ending brackets (i.e., []), with the values comma separated.
   * There will be one space between each of these but none at the beginning nor at the end.
   * Some examples:
   * if the list is empty, toString() gives []
   * if the list has these three elements in this order: "hello", "world", "everyone", then the result should be
   * [hello, world, everyone]
   */
   @Override
   public String toString() {
       return null;
   }

   /**
   * Returns the number of items in the list
   *
   * @return Number of items in the list
   */
   public int size() {
       return 0;
   }

   /**
   * Determines if two lists contain exactly the same values, in exactly the same
   * order.
   *
   * @return {@code true} if and only if obj is an list that is equivalent to the
   * incoming list.
   */
   public boolean equalsLinkedList(LinkedAlgorithms obj) {
       return false;
   }

   /**
   * Determines if {@code key} is in the linked list.
   *
   * @param key The value to be found
   * @return true if and only if {@code key} is in the list
   */
   public boolean contains(String key) {
       return false;
   }

   /**
   * Determines the index of {@code key}. -1 is returned if the value is not
   * present in the linked list. If {@code key} is present present more than once,
   * the first index is returned.
   *
   * @param key The value to be found
   * @return The index of the {@code key}
   */
   public int find(String key) {
       return 0;
   }

   /**
   * Returns the value of the first element of the list.
   *
   * @return The first element of the list.
   * @throws NoSuchElementException the list is empty
   */
   public String getFirst() {
       return null;
   }

   /**
   * Returns the value of the last element of the list.
   *
   * @return The last element of the list.
   * @throws NoSuchElementException the list is empty
   */
   public String getLast() {
       return null;
   }

   /**
   * Returns the value of the {@code ith} element of the list (0 based).
   *
   * @param i The target index
   * @return The value of the ith element of the list.
   * @throws IndexOutOfBoundsException {@code i} is illegal
   */
   public String getAt(int i) {
       return null;
   }

   /**
   * Adds {@code data} to the beginning of the list. All other values in the list
   * remain but they are "shifted to the right."
   *
   * @param data The value to add to the list
   */
   public void insertFirst(String data) {
   }

   /**
   * Adds {@code data} to the end of the list. All other values in the list remain
   * in their current positions.
   *
   * @param data The value to add to the list
   */
   public void insertLast(String data) {
   }

   /**
   * Adds data to a specific spot in the list. The values in the list remain
   * intact but {@code data} is inserted in the list at position {@code i}. When
   * {@code i=0}, the result is the same as {@code insertFirst}.
   *
   * @param i The target index
   * @param data The value to add to the list
   * @throws IndexOutOfBoundsException {@code i} is illegal
   */
   public void insertAt(int i, String data) {
   }

   /**
   * Adds {@code newData} the position immediately preceding {@code existingData}.
   * If the {@code existingData} appears multiple times, only the first one is
   * used.
   *
   * @param newData The value to add to the list
   * @param existingData The value used to control where insertion is to take
   * place
   * @throws NoSuchElementException {@code existingData} is not in the list
   */
   public void insertBefore(String newData, String existingData) {
   }

   /**
   * Adds {@code newData} the position immediately after {@code existingData}. If
   * the {@code existingData} appears multiple times, only the first one is used.
   *
   * @param newData The value to add to the list
   * @param existingData The value used to control where insertion is to take
   * place
   * @throws NoSuchElementException {@code existingData} is not in the list
   */
   public void insertAfter(String newData, String existingData) {
   }

   /**
   * Removes the first element of the list. The remaining elements are kept in
   * their existing order.
   *
   * @return The value removed from the list
   * @throws NoSuchElementException if the list is empty.
   */
   public String removeFirst() {
       return null;
   }

   /**
   * Removes the last element of the list. The remaining elements are kept in
   * their existing order.
   *
   * @return The value removed from the list
   * @throws NoSuchElementException if the list is empty.
   */
   public String removeLast() {
       return null;
   }

   /**
   * Removes the ith element of the list. The remaining elements are kept in their
   * existing order.
   *
   * @param i The target index
   * @return The value removed from the list
   * @throws IndexOutOfBoundsException i does not represent a legal index
   */
   public String removeAt(int i) {
       return null;
   }

   /**
   * Removes the first occurrence of data in the linked list.
   *
   * @param data The value to be removed.
   * @return {@code true} if and only if {@code data} was removed
   */
   public boolean removeFirstOccurrenceOf(String data) {
       return false;
   }

   /**
   * Removes the all occurrence of {@code data} in the linked list.
   *
   * @param data The value to be removed.
   * @return The number of times {@code data} was removed
   */
   public int removeAllOccurrencesOf(String data) {
       return 0;
   }

   /**
   * Reverses the elements in the incoming linked list.
   */
   public void reverse() {
   }

   /**
   * Puts all the elements in the list to uppercase.
   */
   public void toUpper() {
   }

   /**
   * Returns the concatenation of all strings, from left to right. No extra spaces
   * are inserted.
   *
   * @return Concatenation of all string in the list
   */
   public String getConcatenation() {
       return null;
   }

   /**
   * Returns the alphabetically last value in the list.
   *
   * @return The alphabetically last value in the list
   * @throws NoSuchElementException list is empty
   */
   public String getAlphabeticallyLast() {
       return null;
   }

   /**
   * Returns the index where the alphabetically last value value resides. If this
   * value appears multiple times, the first occurrence is used.
   *
   * @return Index value of where maximum value resides
   * @throws NoSuchElementException list is empty
   */
   public int indexOfAlphabeticallyLast() {
       return 0;
   }

   /*
   * Determines if the two list contain elements that have exactly the same
   * value, with the same list sizes, but with the elements perhaps in different order.
   *
   * @returns true only if the two lists are permutations of one another.
   */
   public boolean anagrams(LinkedAlgorithms other) {
       return false;
   }

   public static void main(String[] args) {
       String[] items = { "hello", "world" };
       LinkedAlgorithms LL1 = new LinkedAlgorithms();
       LinkedAlgorithms LL2 = new LinkedAlgorithms(items);
       LinkedAlgorithms LL3 = new LinkedAlgorithms(LL1);
   }
}

In: Computer Science

Build a module (file with pre-defined functions) that allows the following code to work properly. The...

Build a module (file with pre-defined functions) that allows the following code to work properly. The code below should be able to run without any additions or modifications. You may copy and paste it into a file called file_tools_assignment.py and place it in the same directory as the file you will create. The filename of the file you will create should be file_tools.py. The module should contain 2 custom defined functions; get_file_string() and get_file_list(). Download the data.txt file and place it in the same directory with your other two files.

Contents for file_tools_assignment.py:

import file_tools

filename = 'data.txt'

contents = file_tools.get_file_string(filename)
print(contents)

list_of_lines = file_tools.get_file_list(filename)
print(list_of_lines)

(5 points) The get_file_string() function should attempt to get the contents of a file and return it as a string. If no file exists, the return value should be None.

(5 points) The get_file_list() function should return a list where each element in the list corresponds to a line in the file. Note: no newline characters should be present in the elements of the list. Remove those before adding the elements to the list that gets returned. If no file exists, the return value should be an empty list.

Sample output (3 lines in data.txt):

hello world
    I love programming
Python rocks!

['hello world', '    I love programming', 'Python rocks!']

In: Computer Science

Assume all methods in the Stack class are available to you, request from the user a...

Assume all methods in the Stack class are available to you, request from the user a set of numbers (terminated by -1) and print them in reverse order . write code in java.

In: Computer Science

Implement the bubble sort in ML using pattern matching and local function definitions. Show that it...

Implement the bubble sort in ML using pattern matching and local function definitions. Show that it works with a few simple examples. A nice description of the bubble sort can be found on Wikipedia.

A helpful function for the bubble sort is:

(* General function that checks if an int list is sorted *)

fun issorted [] = true  

| issorted [x] = true

| issorted (x::y::t) = x <= y andalso issorted(y::t);

Test your solution and show that it works on the following examples:

  • bubbleSort []; → []  

  • bubbleSort [1]; → [1]  

  • bubbleSort [1,2,3]; → [1,2,3]  

  • bubbleSort [3,1,2]; → [1,2,3]  

bubbleSort [5,4,3,2,1]; → [1,2,3,4,5]

In: Computer Science

Number conversion between hexadecimal and binary. Show the working steps. a) Convert the hexadecimal number E4D2...

Number conversion between hexadecimal and binary. Show the working steps. a) Convert the hexadecimal number E4D2 into binary. b) Convert the binary number 1100010111110011 into hexadecimal

In: Computer Science

Write a java program StudentDriver class to test the methods of the Student class. Use data:...

Write a java program StudentDriver class to test the methods of the Student class.

Use data:
Mary Brown 1234
John Jones 5678
Maty Jones 1234

Note: we are including Mary Jones twice so we can test the "equals" method.
We can test "compareTo", by test student1 and student2, then student2 and student3.

Just submit your driver class as text file.

Make sure you also test addQuiz, getTotalScore, getAverage, and toString. Don't worry about testing all of the sets and gets...

public class Student implements Comparable
{
        //instance variables
        private String lastName;
        private String firstName;
        private String ID;
        private double totalScore;
        private int numQ;
        
        //Constructor
        public Student(String lastName, String firstName, String ID)
        {
                this.lastName = lastName;
                this.firstName = firstName;
                this.ID = ID;
                totalScore = 0;
                numQ = 0;
        }
        
        //instance methods
        
        public void setLast(String lastName)
        {this.lastName = lastName;}
        
        public void setFirst(String firstName)
        {this.firstName = firstName;}
        
        public void setID(String ID)
        { this.ID = ID;}
        
        public void setTotalScore(double total)
        {this.totalScore = total;}
        
        public void setNumQ(int numQ)
        {this.numQ = numQ;}
        
        public String getLast()
        {return this.lastName;}
        
        public String getFirst()
        {return this.firstName;}
        
        public String getID()
        {return this.ID;}
        
        public double getTotalScore()
        {return this.totalScore;}

        public int getNumQ()
        {return this.numQ;}
        
        public void addQuiz(int score)
        { totalScore += score;
          numQ++;}
        
        public double getAverage()
        {return  totalScore/numQ;}
        
        public boolean equals(Student other)
        {return this.ID.equals(other.ID);}
        
        public int compareTo(Student other)
        {return this.lastName.compareTo(other.lastName);}
        
        public String toString()
        {return this.lastName + ", " + this.firstName + "  " + "\n" + this.ID + "\n";}
        
        
        
        
}
        

In: Computer Science

List and explain the three-tiers security in network architecture?

List and explain the three-tiers security in network architecture?

In: Computer Science