Questions
Briefly describe the process/technology used by dye-based optical storage devices/media (e.g., DVD-R) to write content to...

Briefly describe the process/technology used by dye-based optical storage devices/media (e.g., DVD-R) to write content to a disc.

In: Computer Science

Data structure program Implement (your own) the Radix Sort using single linked list java language

Data structure program Implement (your own) the Radix Sort using single linked list

java language

In: Computer Science

Write assembly code to implement the expression A = (B + C - D) x (D...

Write assembly code to implement the expression A = (B + C - D) x (D + E x F) on three-, two-, one-, and zero-address machines (do not change the values of the operands). Refer to Chapter 5 Slides 25-28 for the syntax.

In: Computer Science

this code is about implementing stacks , I want for someone to rewrite it totally in...

this code is about implementing stacks , I want for someone to rewrite it totally in different way

#include <iostream>
#include <stdexcept>
#include <vector>
#include <cstdlib>
using namespace std;

class Stack {
    public:
        bool isEmpty();
        // returns true if stack has no elements stored

        int top();
        // returns element from top of the stack
        // throws runtime_error("stack is empty")

        int pop();
        // returns element from top of the stack and removes it
        // throws runtime_error("stack is empty")

        void push(int);
        // puts a new element on top of the stack

    private:
        vector<int> elements;
};

//member function definitions
bool Stack::isEmpty()
{
    return elements.empty();
}

int Stack::top()
{
    if(isEmpty())
        throw runtime_error("stack is empty");
    return elements.back();
}

int Stack::pop()
{
    if(isEmpty())
        throw runtime_error("stack is empty");
    int item = elements.back();
    elements.pop_back();
    return item;
}

void Stack::push(int item)
{
    elements.push_back(item);
}
//member functions definitions end

int main()
{
    string line, cmd;
    int val;
    Stack stack;

    cout << "stack> ";
    //read line by line
    while(getline(cin, line))
    {
        //get the command

        //trim leading whitespace
        if(line.find_first_not_of(" \t") == string::npos)
        {
            // empty line
            cout << "stack> ";
            continue;
        }
        line = line.substr(line.find_first_not_of(" \t"));
        cmd = line.substr(0, line.find(" "));
        if(cmd == "push")
        {
            // remaining string
            line = line.substr(line.find(" ") + 1);
            if(line.size() == 0
                    || ( (line[0] == '-' || line[0] == '+') && line.find_first_of("0123456789") > 1)
                    || line.find_first_not_of("0123456789+-") == 0)
            {
                cout << "error: not a number" << endl;
            }
            else
            {
                val = atoi(line.c_str());
                stack.push(val);
            }
        }
        else if(cmd == "pop")
        {
            try
            {
                val = stack.pop();
                cout << val << endl;
            }
            catch(runtime_error& e)
            {
                cout << "error: " << e.what() << endl;
            }
        }
        else if(cmd == "top")
        {
            try
            {
                val = stack.top();
                cout << val << endl;
            }
            catch(runtime_error& e)
            {
                cout << "error: " << e.what() << endl;
            }
        }
        else if(cmd == "list")
        {
            Stack s2;
            bool first = true;
            cout << "[";
            /* pop repeatedly and store in another stack */
            while(! stack.isEmpty())
            {
                val = stack.pop();
                s2.push(val);
                if(!first)
                    cout << ",";
                cout << val;
                first = false;
            }
            cout << "]" << endl;
            /* restore original stack */
            while(! s2.isEmpty())
            {
                stack.push(s2.pop());
            }
        }
        else if(cmd == "end")
        {
            break;
        }
        else
        {
            cout << "error: invalid command" << endl;
        }

        cout << "stack> ";
    }

    cout << endl;
}

In: Computer Science

2.2.1 cLL The class is described according to the simple UML diagram below: 2cLL<T> -head:item<T> *...

2.2.1
cLL
The class is described according to the simple UML diagram below:
2cLL<T>
-head:item<T> *
-size:int
------------------------
+cLL()
+~cLL()
+isEmpty():bool
+getSize():int
+push(newItem: item<T>*):void
+pop():item<T>*
+removeAt(x:T):item<T> *
+printList():void
The class variables are as follows:
• head: The head pointer for the linked list.
• size: The current size of the circular linked list. It starts at 0 and grows as the list
does.
The class methods are as follows:
• cLL: The constructor. It will set the size to 0 and initialise head as null.
• ∼cLL: The class destructor. It will iterate through the circular linked list and
deallocate all of the memory assigned for the items.
• isEmpty: This function returns a bool. If the circular linked list is empty, then it
will return true. Otherwise, if it has items then it will return false.
• getSize: This returns the current size of the circular linked list. If the list is empty
the size should be 0.
• push: This receives a new item and adds it to the circular linked list. It is added to
the front of the list. The front in this case refers to the head.
• pop: This receives, and returns, the first element in the list. The first element is
removed from the list in the process. If the list is empty, return null. The first
element referring to the head pointer in this case.
• removeAt: This will remove an item from the linked list based on its value. If
the value is not found, nothing should be removed. Also note that in the event of
multiple values being found, the first one in the list, from head, should be removed.
Note that nothing is deleted. Instead the node must be removed through relinking
and then returned.
• printList: This will print out the entire list from head onwards. The output consists
of a single comma delimited line, with a newline at the end. For example:
1,2,3,4,5
32.2.2
item
The class is described according to the simple UML diagram below:
item <T>
-data:T
-------------------
+item(t:T)
+~item()
+next: item*
+getData():T
The class has the following variables:
• data: A template variable that stores some piece of information.
• next: A pointer of item type to the next item in the linked list.
The class has the following methods:
• item: This constructor receives an argument and instantiates the data variable with
it.
• ∼item: This is the destructor for the item class. It prints out ”Item Deleted” with
no quotation marks and a new line at the end.
• getData: This returns the data element stored in the item.

In: Computer Science

haskell : write a function that reverse the first three element of a list, but not...

haskell :

write a function that reverse the first three element of a list, but not the rest.
example [1,2,3,4,5,6] == [3,2,1,4,5,6]

In: Computer Science

Create a program that implements a singly linked list of Students. Each node must contain the...

Create a program that implements a singly linked list of Students.

Each node must contain the following variables:

  • Student_Name
  • Student_ID

In main():

  1. Create the following list using addHead(). The list must be in the order shown below.

Student_ID

Student_Name

00235

Mohammad

00662

Ahmed

00999

Ali

00171

Fahad

  1. Print the complete list using toString() method.
  2. Create another list using AddTail(). The list must be in the order shown below.

Student_ID

Student_Name

00236

Salman

00663

Suliman

00998

Abdulrahman

  1. Print the complete list using toString() method.
  2. Delete head note from both list.
  3. Print the both list using toString() method.

in java

In: Computer Science

Using python Create a function that inputs a list of numbers and outputs the median of...

Using python

Create a function that inputs a list of numbers and outputs the median of the numbers.
sort them and them show the output.

In: Computer Science

Show how circular linked list can be useful to implement Circular Queue (CQ) ADT (Abstract Data...

Show how circular linked list can be useful to implement Circular Queue (CQ) ADT (Abstract Data Type). Compare and contrast with array based implementation. Which one would you recommend to implement CQ and why

In: Computer Science

Write a Java program to implement a double-linked list with addition of new nodes at the...

Write a Java program to implement a double-linked list with addition of new nodes at the end of the list. Add hard coded nodes 10, 20, 30, 40 and 50 in the program. Print the nodes of the doubly linked list.

In: Computer Science

(Computer Network Question)Answer the following questions when the two nodes with a point-to-point connection are communicating...

(Computer Network Question)Answer the following questions when the two nodes with a point-to-point connection are communicating with a link with a bandwidth of 8 Mbps and a one-way radio delay of 2 mssec. (The header overhead, i.e. header length, is ignored in the performance calculation process.)

a)Draw a sliding window of 1KB (8000bit) frames with a size of 1KB (KB) when sending in a sliding window with a size of 2 transmission window, the process of operation if no error occurs. What is the link utilization rate when the link is said to be long-term communication in a communication environment like this? Calculate the utilization with the base of the utilization coefficient calculation (assume that the receiving node immediately sends the ACK and the length of the ACK is negligible).

b)To maintain link utilization of 80% or more in the same communication environment, what should be the minimum size of the transmission window? Figure out the transmission process of the proposed answer and calculate the transmission efficiency.

In: Computer Science

IN PYTHON Develop a program in python that includes a number of functions for the multi-server...

IN PYTHON

Develop a program in python that includes a number of functions for the multi-server queue. The program accepts arrival and services rates and the number of servers and calls your functions to output the average number of customers and average waiting time in the system.

In: Computer Science

Implement a class named Complex that represents immutable complex numbers. Your class needs two private final...

Implement a class named Complex that represents immutable complex numbers.

  • Your class needs two private final fields of type double to store the real and imaginary parts.
  • Try to use constructor chaining to implement 2 of the 3 required constructors.
  • If you cannot complete one or more of the methods, at least make sure that it returns some value of the correct type; this will allow the tester to run, and it will make it much easier to evaluate your code. For example, if you are having difficulty with toString then make sure that the method returns some String (such as the empty string "").

Code Given:

import java.util.Arrays;
import java.util.List;

/**
* A class that represents immutable complex numbers.
*
* @author EECS2030 Fall 2019
*
*/
public final class Complex {

  
  
   /**
   * Initializes this complex number to <code>0 + 0i</code>.
   *
   */
   public Complex() {
      
   }

   /**
   * Initializes this complex number so that it has the same real and
   * imaginary parts as another complex number.
   */
   public Complex(Complex other) {
      
   }

   /**
   * Initializes this complex number so that it has the given real
   * and imaginary components.
   */
   public Complex(double re, double im) {
      
   }

   /**
   * A static factory method that returns a new complex number whose real part
   * is equal to re and whose imaginary part is equal to 0.0
   */
   public static Complex real(double re) {
      
       return null;
   }

   /**
   * A static factory method that returns a new complex number whose real part
   * is equal to 0.0 and whose imaginary part is equal to im
   */
   public static Complex imag(double im) {
      
       return null;
   }

   /**
   * Get the real part of the complex number.
   */
   public double re() {
      
       return 0.0;
   }

   /**
   * Get the imaginary part of the complex number.
   */
   public double im() {
      
       return 0.0;
   }

   /**
   * Add this complex number and another complex number to obtain a new
   * complex number. Neither this complex number nor c is changed by
   * this method.
   */
   public Complex add(Complex c) {
      
       return null;
   }

   /**
   * Multiply this complex number with another complex number to obtain a new
   * complex number. Neither this complex number nor c is changed by
   * this method.
   */
   public Complex multiply(Complex c) {
      
       return null;
   }

   /**
   * Compute the magnitude of this complex number.
   */
   public double mag() {
      
       return 0.0;
   }

   /**
   * Return a hash code for this complex number.
   */
   @Override
   public int hashCode() {
      
       return 0;
   }

   /**
   * Compares this complex number with the specified object. The result is
   * <code>true</code> if and only if the argument is a <code>Complex</code>
   * number with the same real and imaginary parts as this complex number.
   */
   @Override
   public boolean equals(Object obj) {
      
       return true;
   }

   /**
   * Returns a string representation of this complex number.
   */
   @Override
   public String toString() {
      
       return "";
   }

   /**
   * Returns a complex number holding the value represented by the given
   * string.
   */
   public static Complex valueOf(String s) {
       Complex result = null;
       String t = s.trim();
       List<String> parts = Arrays.asList(t.split("\\s+"));
      
       // split splits the string s by looking for spaces in s.
       // If s is a string that might be interpreted as a complex number
       // then parts will be a list having 3 elements. The first
       // element will be a real number, the second element will be
       // a plus or minus sign, and the third element will be a real
       // number followed immediately by an i.
       //
       // To complete the implementation of this method you need
       // to do the following:
       //
       // -check if parts has 3 elements
       // -check if the second element of parts is "+" or "-"
       // -check if the third element of parts ends with an "i"
       // -if any of the 3 checks are false then s isn't a complex number
       // and you should throw an exception
       // -if all of the 3 checks are true then s might a complex number
       // -try to convert the first element of parts to a double value
       // (use Double.valueOf); this might fail in which case s isn't
       // a complex number
       // -remove the 'i' from the third element of parts and try
       // to convert the resulting string to a double value
   // (use Double.valueOf); this might fail in which case s isn't
       // a complex number
       // -you now have real and imaginary parts of the complex number
       // but you still have to account for the "+" or "-" which
       // is stored as the second element of parts
       // -once you account for the sign, you can return the correct
       // complex number
      
      
      
       return result;
   }
}

In: Computer Science

The process of reviewing the recording procedures for an accounting information system should include three areas....

The process of reviewing the recording procedures for an accounting information system should include three areas. What are they

Why is it necessary to introduce an AIS and how does recorded data contribute to problem-solving processes and to continuous improvement of products and service delivery? Discuss in 150–180 words.

In: Computer Science

How can I identify products and their characteristics that resemble the alpha, beta and chi models?...

How can I identify products and their characteristics that resemble the alpha, beta and chi models? Thanks in advance.

FOR EXAMPLE: 1. Microsoft’s Office Products which resembles chi;

2. AMAZON -- at one point, Amazon considered cloud services to be its beta product;

3. Mondalez’s Oreo cookies could be an alpha.

In: Computer Science