Questions
Java queue linked list /* * Complete the enqueue(E val) method * Complete the dequeue() method...

Java queue linked list

/*
* Complete the enqueue(E val) method
* Complete the dequeue() method
* Complete the peek() method
* No other methods/variables should be added/modified
*/
public class A3Queue {
   /*
   * Grading:
   * Correctly adds an item to the queue - 1pt
   */
   public void enqueue(E val) {
       /*
       * Add a node to the list
       */
   }
   /*
   * Grading:
   * Correctly removes an item from the queue - 1pt
   * Handles special cases - 0.5pt
   */
   public E dequeue() {
       /*
       * Remove a node from the list and return it
       */
       return null;
   }
   /*
   * Grading:
   * Correctly shows an item from the queue - 1pt
   * Handles special cases - 0.5pt
   */
   public E peek() {
       /*
       * Show a node from the list
       */
       return null;
   }
  
   private Node front, end;
   private int length;
   public A3Queue() {
       front = end = null;
       length = 0;
   }
   private class Node {
       E value;
       Node next, prev;
       public Node(E v) {
           value = v;
           next = prev = null;
       }
   }
}

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

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


public class A3Driver {
  
   public static void main(String[] args) {
      
       A3DoubleLL list = new A3DoubleLL<>();
       for(int i = 1; i < 10; i++) {
           list.add(i);
       }
       System.out.println("Before Swap");
       System.out.println(list.printList());
       System.out.println(list.printListRev());
       list.swap(4);
       System.out.println("After Swap");
       System.out.println(list.printList() + ":1,2,3,4,6,5,7,8,9,");
       System.out.println(list.printListRev() + ":9,8,7,6,5,4,3,2,1,");
       System.out.println();
      
       System.out.println("Hot Potatoe");
       A3CircleLL hotPotato = new A3CircleLL();
       hotPotato.playGame(5, 3);
       System.out.println("Correct:");
       System.out.println("Removed Player 4\nRemoved Player 3\nRemoved Player 5\nRemoved Player 2\nWinning player is 1");
       System.out.println();
      
       A3Queue queue = new A3Queue<>();
       queue.enqueue(5);
       queue.enqueue(20);
       queue.enqueue(15);
       System.out.println(queue.peek()+":5");
       System.out.println(queue.dequeue()+":5");
       queue.enqueue(25);
       System.out.println(queue.dequeue()+":20");
       System.out.println(queue.dequeue()+":15");

   }
}

In: Computer Science

1. To keep track of vendors and products they supply, XYZ Corp. uses the table structure...

1. To keep track of vendors and products they supply, XYZ Corp. uses the table structure shown below. Assuming that the sample data are representative, draw a dependency diagram in Visio that shows all functional dependencies including both partial and transitive dependencies. (Hint: Look at the sample values to determine the nature of the relationships.)

PART_CODE

PART_DESC

VEND_NAME

VEND_ADDRESS

VEND_TYPE

PRICE

1234

Logic Chip

Fast Chips

Cupertino

Non-profit organization

25.00

1234

Logic Chip

Smart Chips

Phoenix

Non-profit organization

22.00

5678

Memory Chip

Fast Chips

Cupertino

Profit organization

18.00

5678

Memory Chip

Quality Chips

Austin

Profit organization

15.00

5678

Memory Chip

Smart Chips

Phoenix

Profit organization

19.00

2. Using the initial dependency diagram drawn in question 1, remove all partial dependencies, draw the new dependency diagrams in Visio, and identify the normal forms for each table structure you created.

3. Using the table structures you created in question 2, remove all transitive dependencies, and draw the new dependency diagrams in Visio. Also identify the normal forms for each table structure you created.  If necessary, add or modify attributes to create appropriate determinants or to adhere to the naming conventions.

4. Using the results of question 3, draw the fully labeled Crow's Foot ERD in Visio. The diagram must include all entities, attributes, and relationships. Primary keys and foreign keys must be clearly identified on the diagram.

In: Computer Science

in JAVA please Some of the characteristics of a book are the title, authors, publisher, ISBN,...

in JAVA please

Some of the characteristics of a book are the title, authors, publisher, ISBN, price, and year of publication. Design the class Book so that each object can hold the following information about a book: title, up to four authors, publisher, ISBN, price, and number of copies in stock. To keep track the number of authors, you can add a variable; Including the methods to perform various operations on the objects of book. For example, the usual operations that can be performed on the title are to show the title, set the title, and check whether a title is an actual title of the book. In the similar way, the typical operations that can be performed on the number of copies in stock are to show the number of copies in stock, set the number of copies in stock, update the number of copies in stock, and return the number of copies in stock. Add similar operations for the publisher, ISBN, book price, and authors. Add the appropriate constructors. Write the definitions of the methods of the class Book based on the instruction in a). Write a program that uses the class Book and test various operations on the objects of class Book. Say declare an array of 100 components of the type book. Some the operations that you should perform are to search for a book by its title, search by ISBN, and update the number of copies of a book.

In: Computer Science

Try to make it as simple as you can and explain as much as it needed....

Try to make it as simple as you can and explain as much as it needed.

  1. What is Trusted Third Party (TTP)? What are the problems with TTP? (3 points)

Ans:

  1. Using Caesar cipher algorithm and key value = 4, encrypt the plain text “Network Security”. Show your work.          (3 points)

Ans:

  1. Let k be the encipherment key for a Caesar cipher. The decipherment key differs; it is 26 - k. One of the characteristics of a public key system is that the encipherment and decipherment keys are different. Why then is the Caesar cipher a classical cryptosystem, not a public key cryptosystem? Be specific.                                                 (3 points)

Ans:

  1. A cryptographer once claimed that security mechanisms other than cryptography were unnecessary because cryptography could provide any desired level of confidentiality and integrity. Ignoring availability, either justify or refute the cryptographer’s claim. (3 points)

Ans:

  1. How can you ensure Authentication using Challenge and Response method? Explain and give an example. (4 points)

Ans:

In: Computer Science

Hi. I'm trying to write a program that uses dynamic memory management to create two arrays....

Hi. I'm trying to write a program that uses dynamic memory management to create two arrays. splice() must create the third array and return a pointer to main(). Main() must capture the pointer returned from the splice() function.

Sol'n so far, I get the results of the first and second array, but it isn't showing the results of the spliced function:

#include <iostream>

using namespace std;

// Function int* splice() inserts the 2nd array into 1st array starting at int numOfElements
int* splice(int *array1, int *array2, int size1, int size2, int numOfElements)
{
   int *result = new int[size1 + size2];
   for (int i = 0; i < numOfElements; i++)
       *(result + i) = *(array1 + i);
   for (int i = 0; i < size2; i++)
       *(result + numOfElements + i) = *(array2 + i);
   //Line 13 will copy ith element of the second element into numOfElements + ith position in the final array.
   for (int i = numOfElements; i < size1; i++)
       *(result + size2 + i) = *(array1 + i);
   system("pause");
   return result;
}

int main()
{

int size1, size2, numOfElements;
   cout << "Enter the size of the first array: ";
   cin >> size1;
   cout << "Enter the size of the second array: ";
   cin >> size2;
   cout << "Enter the number of elements of the first array to be copied before splice: ";
   cin >> numOfElements;

srand(100);
   int *array1 = new int[size1];
   int *array2 = new int[size2];
   for (int i = 0; i < size1; i++)
       *(array1 + i) = rand() % size1;
   for (int i = 0; i < size2; i++)
       *(array2 + i) = rand() % size2;

cout << "The contents of the first array is: " << endl;
   for (int i = 0; i < size1; i++)
   {
       cout << *(array1 + i) << "\t";
       if ((i + 1) % 10 == 0)
           cout << endl;
   }
   cout << endl << "The contents of the second array is: " << endl;
   for (int i = 0; i < size2; i++)
   {
       cout << *(array2 + i) << "\t";
       if ((i + 1) % 10 == 0)
           cout << endl;
   }
   int *array = splice(array1, array2, size1, size2, numOfElements);

cout << "The contents of the spliced array is: " << endl;
   for (int i = 0; i < size1 + size2; i++)
   {
       cout << *(array + i) << "\t";
       if ((i + 1) % 10 == 0)
           cout << endl;
   }

    delete[] array1;
   delete[] array2;
   delete[] array;

   //the values are deleted, but the pointers still exist
}

In: Computer Science

What is BGP? Explain how a network administrator of an upper-tier ISP can implement policy when...

What is BGP? Explain how a network administrator of an upper-tier ISP can implement policy when configuring BGP.

In: Computer Science

1) Provide the type and assembly language instruction for the following binary value: 0000 0010 0001...

1) Provide the type and assembly language instruction for the following binary value: 0000 0010 0001 0000 1000 0000 0010 0000 (two)

2) Provide the type, assembly language instruction, and binary representation of instruction described by the following MIPS fields: op=0, rs=3, rt=2, rd=3, shamt=0, funct=34

3)For the following C statement, write a minimal sequence of MIPS assembly instructions that does the identical operation. Assume $t1 = A, $t2 = B, and $s1 is the base address of C. A = C[0] << 4;

4) Consider the following MIPS loop:

LOOP: slt $t2, $0, $t1

beq $t2, $0, DONE

subi $t1, $t1, 1

addi $s2, $s2, 2

j LOOP

DONE:

4a) Assume that the register $t1 is initialized to the value 10. What is the value in register $s2 assuming $s2 is initially zero?

4b) For each of the loops above, write the equivalent C code routine. Assume that the registers $s1, $s2, $t1, and $t2 are integers A, B, i, and temp, respectively.

4c) For the loops written in MIPS assembly above, assume that the register $t1 is initialized to the value N. How many MIPS instructions are executed?

In: Computer Science

Lab #3 – Recursion on Strings Lab Objectives • Be able to write a recursive Java...

Lab #3 – Recursion on Strings Lab Objectives • Be able to write a recursive Java method for Java strings • Be able to make use of exploit natural conversion between strings and integers • Be able to write a driver to call the methods developed for testing Deliverables Submit the report in Word or PDF format with the results of every task listed below. They should show screen capture of your results. The problem String as a sequence of characters for developing recursive method Given a Java string object, we observe that it is a sequence (or ordered list) of characters. Our goal is to employ a very common technique in computer science—namely, dividing the list into its head (it’s first element) and its tail (the remaining list with the first element removed). We can then recurse on the tail, which happens to be smaller. We use this technique for reversing a string, or for checking whether it is a palindrome (reads the same if you read it from left or right). Task #1 Develop a left recursive method to reverse a string Develop a method with the prototype public static String reverseRecursiveLeft (String input) based on selecting the leftmost character as the head and the remaining part of the string as its tail. Here is the recursive design. 1. Base case: The problem is trivial when the string length is 0 or 1. 2. Decomposition: For strings of length > 1: • Extract its head (character) and the tail. You are expected to know the string methods needed to achieve this. • Make a recursive call to obtain the tail reversed. 3. Composition: Append (concatenate) the head to obtain the original string reversed. Task #2 Develop a right recursive method to reverse a string Develop a method with the prototype public static String reverseRecursiveRight (String input) based on selecting the rightmost character as the head and the remaining part of the string on its left as the tail. The only difference in the recursive design is that the reversed tail needs to be appended after the head character. Page 2 of 2 Task #3 Develop a middle recursive method to reverse a string Develop a method with the prototype public static String reverseRecursiveMiddle (String input) This time, instead of extracting one element (character) from left or right, extract two characters simultaneously from both left and right. design. This leads to a drop of 2 in size of the reduced problem. Be careful to take this into account when you design the base case. Should the base case be any different? Consider odd and even size strings Task #4 Develop a method to reverse an integer (as written in decimal form) Develop a method with the prototype public static int reverse (int input) using any of the previous three methods you developed for reversing a string. Note that, • For a negative integer, the result should also be negative with the digits reversed, i.e., your method should return -321 when presented with input -123. • You can make use of the toString() method available to any object. However, wrapper classes are needed for this, while operating on a primitive variable such as int. • The reconversion is easily achieved by the parse family of methods also available in the wrapper class. Task #5 Develop a middle recursive method to check whether a string is palindrome. Develop a method with the prototype public static boolean isPalindrome (String input) to check if a string is a palindrome. Determine which of the three types of recursion (left, right, or middle) maps directly to this problem. Also, overload the isPalindrome() for integer inputs as public static boolean isPalindrome (int input) using the same technique of integer-string inter-conversion. The same rule of reversing applies to negative numbers, i.e., only digits are considered for deciding whether the number is a palindrome. Write a driver to test your program and include screen captures in your report.

In: Computer Science

Looking for code to this stepping stone lab 6 Prompt: In Stepping Stone Lab Five, you...

Looking for code to this stepping stone lab 6

Prompt:

In Stepping Stone Lab Five, you created a Recipe Class. Now, in Stepping Stone Lab Six, you will focus your skills on developing your own driver class including custom methods to access elements of the Ingredient and Recipe classes.

Specifically, you will need to create the following:

 The instance variables for the class (listOfRecipes) 

Accessors and mutators for the instance variable 

Constructors 

Three custom methods: printAllRecipeDetails(), printAllRecipeNames, and addNewRecipe

Guidelines for Submission: This assignment should be submitted as a Java file.

  


Extending This Lab for Your Final Project For your final project submission, you should add a menu item and a method to access the custom method you developed for the Recipe class based on the Steppcing Stone Lab Five.

Code given:

package SteppingStones;

import java.util.ArrayList;

public class SteppingStone6_RecipeBox {
  
   /**
   * Declare instance variables:
   * a private ArrayList of the type SteppingStone5_Recipe named listOfRecipes
   *
   */
  
   /**
   * Add accessor and mutator for listOfRecipes
   *
   */

   /**
   * Add constructors for the SteppingStone6_RecipeBox()
   *
   */
     
   /**
   * Add the following custom methods:
   *
   * //printAllRecipeDetails(SteppingStone5_Recipe selectedRecipe)
   *        This method should accept a recipe from the listOfRecipes ArrayList
   *        recipeName and use the SteppingStone5_Recipe.printRecipe() method
   *        to print the recipe
   *       
   * //printAllRecipeNames() <-- This method should print just the recipe
   *        names of each of the recipes in the listOfRecipes ArrayList
   *
   * //addRecipe(SteppingStone5_Recipe tmpRecipe) <-- This method should use
   *        the SteppingStone5_Recipe.addRecipe() method to add a new
   *        SteppingStone5_Recipe to the listOfRecipes
   *
   */
  
  
   /**
   * A variation of following menu method should be used as the actual main
   *       once you are ready to submit your final application. For this
   *       submission and for using it to do stand-alone tests, replace the
   *       public void menu() with the standard
   *           public static main(String[] args)
   *       method
   *
   */
  
   public void menu() {
   // Create a Recipe Box
      
       //SteppingStone6_RecipeBox myRecipeBox = new SteppingStone6_RecipeBox(); //Uncomment for main method
Scanner menuScnr = new Scanner(System.in);
  
      
       /**
       * Print a menu for the user to select one of the three options:
       *
       */
      
       System.out.println("Menu\n" + "1. Add Recipe\n" + "2. Print All Recipe Details\n" + "3. Print All Recipe Names\n" + "\nPlease select a menu item:");
while (menuScnr.hasNextInt() || menuScnr.hasNextLine()) {
System.out.println("Menu\n" + "1. Add Recipe\n" + "2. Print All Recipe Details\n" + "3. Print All Recipe Names\n" + "\nPlease select a menu item:");
int input = menuScnr.nextInt();
  
           /**
           * The code below has two variations:
           *    1. Code used with the SteppingStone6_RecipeBox_tester.
           *   2. Code used with the public static main() method
           *
           * One of the sections should be commented out depending on the use.
           */
          
           /**
           * This could should remain uncommented when using the
           * SteppingStone6_RecipeBox_tester.
           *
           * Comment out this section when using the
           *       public static main() method
           */
          
           if (input == 1) {
newRecipe();
} else if (input == 2) {
System.out.println("Which recipe?\n");
String selectedRecipeName = menuScnr.next();
printAllRecipeDetails(selectedRecipeName);
} else if (input == 3) {
  
              
               for (int j = 0; j < listOfRecipes.size(); j++) {
System.out.println((j + 1) + ": " + listOfRecipes.get(j).getRecipeName());
}
} else {
System.out.println("\nMenu\n" + "1. Add Recipe\n" + "2. Print Recipe\n" + "3. Adjust Recipe Servings\n" + "\nPlease select a menu item:");
}
  
           /**
           * This could should be uncommented when using the
           *        public static main() method
           *
           * Comment out this section when using the
           *        SteppingStone6_RecipeBox_tester.
           *      
          
          
           if (input == 1) {
myRecipeBox.newRecipe();
} else if (input == 2) {
System.out.println("Which recipe?\n");
String selectedRecipeName = menuScnr.next();
myRecipesBox.printAllRecipeDetails(selectedRecipeName);
} else if (input == 3) {      
               for (int j = 0; j < myRecipesBox.listOfRecipes.size(); j++) {
System.out.println((j + 1) + ": " + myRecipesBox.listOfRecipes.get(j).getRecipeName());
               }
} else {
System.out.println("\nMenu\n" + "1. Add Recipe\n" + "2. Print Recipe\n" + "3. Adjust Recipe Servings\n" + "\nPlease select a menu item:");
}
          
           *
           */
          
           System.out.println("Menu\n" + "1. Add Recipe\n" + "2. Print All Recipe Details\n" + "3. Print All Recipe Names\n" + "\nPlease select a menu item:");
       }
      
  
   }

}


/**
*
* Final Project Details:
*
* For your final project submission, you should add a menu item and a method
*       to access the custom method you developed for the Recipe class
*        based on the Stepping Stone 5 Lab.
*
*/

In: Computer Science

Given C++ Stack Code, Modify the code to work like a Queue.(First in First out) Stack...

Given C++ Stack Code, Modify the code to  work like a Queue.(First in First out) 

Stack
#ifndef STACK_H
#define STACK_H

#include "Node.h"


 
 template
 class Stack {
 private:
    
     Node* top;

 public:
     // Constructor
     Stack() {
      
         top = nullptr;
     }

    
    

    
     void push(Object ab) {
         
         if (top != nullptr) {
            
             Node* newNode = new Node(ab, *top);
   
             top = newNode;
         } else {
             
             Node* newNode = new Node(ab);
            
             top = newNode;
         }
     }

     
     Object pop() {
        
         if (top != nullptr) {
             Node *returnVal = top;
            
             top = top->getNext();
             Object returnObject = returnVal->getItem();
             
             delete returnVal; 
             return returnObject;
         } else {
            
             return Object();
         }
     }

    
     bool isThere(Object a) {
         Node* Copy = top;
        
         while (Copy != nullptr) {
             if (Copy->getItem() == a) {
                 
                 return true;
             }
             
             Copy = Copy->getNext();
         }
        
         return false;
     }


    
 };


#endif //STACK_H

In: Computer Science

Given the message m = 1011110, what will be the actual message sent with the appropriate...

Given the message m = 1011110, what will be the actual message sent with the appropriate parity bits included?

Number of bits in the given message (size of m)

No of parity bits required as per Hamming’s algorithm (size of r)

The final message that is transferred along with parity bits (Final Answer)

In: Computer Science

Language C++ Student-Report Card Generator: create a class called student and class called course. student class...

Language C++

Student-Report Card Generator:

create a class called student and class called course.

student class

this class should contain the following private data types:

- name (string)

- id number (string)

- email (s)

- phone number (string)

- number of courses (int)

- a dynamic array of course objects. the user will specify how many courses are there in the array.

the following are public members of the student class:

- default constructor (in this constructor, prompt the use enter values for all the private data members of student class)

- argument constructor

- display method to display the student information in a proper and acceptable format.make sure to overload the insertion operator for this purpose.

course class:

this class should contain the following private data types:

- course code (string)

- course title (string)

- course grade (double)

- course credits (int)

the following are public members of the course class:

- default constructor (in this constructor, prompt the use enter values for all the private data members of course class) [show me how you will manage this situation]

- argument constructor

- average method to calculate and return the average of the student grades.

- display method to display the grades in a proper and acceptable format.make sure to overload the insertion operator for this purpose.

Testing:

test your classes by creating 2 objects of student, one using the default constructor and the other one using the argument constructor. make sure to display the data of each object.

In: Computer Science

Write a program that takes two command line arguments at the time the program is executed....

Write a program that takes two command line arguments at the time the program is executed. Both arguments are to be numerical values restricted to 22-bit unsigned integers. The input must be fully qualified, and the user should be notified of any errors with the input provided by the user. The first argument is to be considered a data field. This data field is to be is operated upon by a mask defined by the second argument. The program should display a menu that allows the user to select different bit- wise operations to be performed on the data with the mask. The required operations are: Set, Clear and Toggle. Both data and mask should be displayed in binary format. And they must be displayed such that one is above the other so that they may be visually compared bit by bit. If data and mask are both less than 256, then the binary display should only show 8 bits. If both values are less the 65536, then the binary display should only show 16 bits. The menu must also allow the user to re-enter a value for data and re-enter a value for the mask. Use scanf() to read data from the user at runtime and overwrite the original values provided at execution time. All user input must be completely qualified to meet the requirements above (up to 22-bit unsigned integer values). Printing binary should be done with shifting and bitwise operations.

In: Computer Science

sonia uses noon websites to buy various items.If the total cost of the ordered items, at...

sonia uses noon websites to buy various items.If the total cost of the ordered items, at one time is 1000AED or more then the shipping is free; otherwise the shipping will cost 10aed per item. write a C++ program to prompt sonia to enter the number of items ordered and the price of each one of them. output the total billing amount. use for loop.

In: Computer Science

Write a PHP script that: 1) Has an associative array with 10 student names and test...

Write a PHP script that:

1) Has an associative array with 10 student names and test scores (0 to 100). ie. $test_scores('John' => 95, ... );

2)Write a function to find the Average of an array. Input is an array, output is the average. Test to make sure an array is inputted. Use ARRAY_SUM and COUNT.

3)Output the test scores highest to lowest, print scores above the average in Green. Find a PHP Sort function for associative arrays, high to low. <font color='green'>text</font>

4)Output the test scores lowest to highest, print scores below the average in Red. Find a PHP Sort function for associative arrays, low to high. <font color='red'>text</font>

In: Computer Science