Questions
Python question Define a function called max_value_length(tree) that takes a Binary Tree object as a parameter...

Python question

Define a function called max_value_length(tree) that takes a Binary Tree object as a parameter and returns an integer that contains the longest character length of all the values in that tree. Use recursion.

For example, the character length of value 123 is 3, because there are three digits. The character length of value “Ruru” is 4, because it has four characters. Further, the max_value_length() function would return 4 if the only node values in the tree were 123 and “Ruru”, because 4 is greater than 3.

Note 1: You must use recursion to answer this question (i.e., not loops).
Note 2: Values in the tree are always treated as strings.

For example:

Test Result
binary_tree = create_tree_from_nested_list([7, [2, [14, None, None], [5, None, None]], [9, None, [144, None, None]]])
print(max_value_length(binary_tree))
3
binary_tree = create_tree_from_nested_list(["Hoiho", ["Kaki", ["Takahe", None, None], None], ["Ruru", None, ["Moa", None, ["Piwaiwaka", None, None]]]])
print(max_value_length(binary_tree))
9
binary_tree = create_tree_from_nested_list([])
print(max_value_length(binary_tree))
0

In: Computer Science

. The file contains information about baseball players in a fictitious league. Here is a sample...

  1. . The file contains information about baseball players in a fictitious league. Here is a sample of the data:

Janet Littleton,6,7,14

Frank Edbrooke,17,9,31

Robert Hovery,25,1,18

Thomas Bingham,21,8,2

Stephen Bruce,7,9,23

For each player it shows:

  1. Her name,
  2. How many doubles she hit,
  3. How many triples she hit,
  4. How many home runs she hit [End of Line]

For example, Janet Littleton hit 6 doubles, 7 triples and 14 home runs. Frank Edbrooke hit 17 doubles, 9 triples and 31 home runs.

Your job is to determine:

  1. How many players there are in the league, and
  2. which players hit more triples than doubles and hit more triples than home runs. There are five players who meet these criteria:

In: Computer Science

5. On the web view each of the following web sites. Write a short summary of...

5. On the web view each of the following web sites. Write a short summary of your understanding of each.

rumkin.com program to test several types of coding. Rate each one on strength.

https://youtu.be/SAAflrIp__E

https://youtu.be/-yFZGF8FHSg

https://youtu.be/uK8DXrTEK-U

BY SEEING THE YOUTUBE LINK VIDEOS WRITE A SHORT SUMMARY OF YOUR UNDERSTANDING FOR ALL THOSE 3 LINKS

In: Computer Science

As stated in the chapter, many different factors affect the running time of an algorithm. Your...

As stated in the chapter, many different factors affect the running time of an algorithm. Your task is to conduct experiments to see how sorting algorithms perform in different environments.


To construct this experiment you must have a program or two programs that sorts sets of data. The program or programs should sort a set of number using a quick sort and using a merge sort. To expedite this, example code that performs a quick sort and a merge sort have been provided.


You should conduct sets of experiments. Categorize your data in two major sections, one for merge sort results, one for quick sort results. Each section can be sub divided into criteria that you used to bench mark the sort.


Conduct benchmarking of quicksort and merge sort several times on the same system - once with as much software turned off a possible, and then with other programs running - Word, Excel, videos, etc. See if you can determine how different software or combinations of software running at the same time slow down the sorting algorithms the most. You might want to include an Internet connection in this test. Just as with the different software, How does a live connection to a network affect the running time of the algorithms?


Use Data Sets Starting at at 10,000,000 randomly generated numbers


All programming projects must have an associated Professional Lab Report submitted with in. A Lab Report must contain the minimum Requirements List Below


Template Workbook for Bench Marking Data

benchmarking.xlsx




Document Formatting

A document header - The Header section should contain your name
A document footer - The footer should contain a page number

Paragraphs Formatting should be formatted

1.5 line spacing
12 points before and after the paragraph

Character Formatting

Body Text should be 12 points
Segment Headers should be boldface

Submit a Project containing the Quick Sort Tool program you created to conduct the research. If the project contains the features of both programs, then only submit one project.

Submit a Project containing the Merge Sort Tool program you created to conduct the research. If the project contains the features of both programs, then only submit one project.

Submit an Excel Workbook containing the Bench Marking Data.

Submit a Lab Report for building your project tool.
Submit an Essay Report describing your work, your results, and your conclusions.Essays should follow the same formatting requirements as Lab Reports

In: Computer Science

Write a program that reads the messages contained in the file message_tx.txt into a 640x480 BMP...

Write a program that reads the messages contained in the file message_tx.txt into a 640x480 BMP file named bbc_packet.bmp. Each line in the text file should be treated as a separate message.

#include "dirtyd.h"

#include "GLOWWORM.h"

#include "MyBMP.h"

#define OUT_BMPFILENAME "HW06_PR01.bmp"

#include
#include

#define BBC_PACKET_LENGTH_BYTES (1024)
#define BBC_MESSAGE_LENGTH_BYTES ( 32) // bytes, not bits
#define BBC_CHECKSUM_BITS ( 8) // bits

#define BBC_PACKET_LENGTH_BITS (8 * BBC_PACKET_LENGTH_BYTES)
#define BBC_MESSAGE_LENGTH_BITS (8 * BBC_MESSAGE_LENGTH_BYTES)

#define isSet(c,b) ((c) & (1 << (b)))

#define TASKPRINT (!TRUE)
#define TASK(s) if(TASKPRINT) printf("%s\n", (s))

#define WIDTH (640)
#define HEIGHT (480)

#define fileREAD "message_tx.txt"

//#define DEBUG_ON
#ifdef DEBUG_ON
   #define DEBUG(s) s
#else
   #define DEBUG(s)
#endif

uint8_t *bbc_encode_byte(GLOWWORM *gw, uint8_t *packet, uint8_t c, MyBMP *bmp)
{             
   for (int bit = 7; bit >= 0; bit--)
   {
       uint8_t bitValue = isSet(c, bit);
       uint64_t hash = GLOWWORM_addBit(gw, !!bitValue);
       uint32_t chip = hash % BBC_PACKET_LENGTH_BITS;
       printf("%c[%i] = %u (chip = %u)\n", c, bit, !!bitValue, chip);
       packet[chip] = TRUE;
       if (!!bitValue == 1){
           MyBMP_drawPixel(bmp, chip/WIDTH, chip%WIDTH, 0, 0, 0);
       //   MyBMP_drawPixel(bmp, chip%WIDTH, chip%HEIGHT, 255, 255, 255);
       //   MyBMP_drawCircle(bmp, chip%WIDTH, chip%HEIGHT, 5,
// 0, 0, 0, 1);
           printf("%i and %i\n", chip/WIDTH, chip%WIDTH);
       }else {
           MyBMP_drawPixel(bmp, chip/WIDTH, chip%WIDTH, 255, 255, 255);
       }
       //packet[GLOWWORM_addBit(gw, isSet(c,bit)) % (BBC_PACKET_LENGTH_BITS)] = TRUE;
   }
  
   return packet;
}

uint8_t *bbc_encode(uint8_t *packet, uint8_t *s, MyBMP *bmp)
{
   int byte = 0;

   if (NULL == packet)
   {
       TASK("Create packet (1 byte per bit for convenience)");
       packet = (uint8_t *) malloc(BBC_PACKET_LENGTH_BITS * sizeof(uint8_t));
       if (!packet)
       {
           printf("Failed to allocate packet -- abort!\n");
           exit(EXIT_FAILURE);
       }
       for (int i = 0; i < BBC_PACKET_LENGTH_BITS; i++)
           packet[i] = 0;
   }
  
   TASK("Encode bookend marks");
   packet[0] = TRUE;
   packet[BBC_PACKET_LENGTH_BITS - 1] = TRUE;

   TASK("Create and Initialize Glowworm");
   GLOWWORM *gw = GLOWWORM_new();
   GLOWWORM_init(gw);
  
   TASK("Encode the message");
   while ((byte < BBC_MESSAGE_LENGTH_BYTES) && (NUL != s[byte]))
       bbc_encode_byte(gw, packet, s[byte++], bmp);

   TASK("Encode padding bytes (all zero)");
   while (byte++ < BBC_MESSAGE_LENGTH_BYTES)
       bbc_encode_byte(gw, packet, 0, bmp);

   TASK("Encode checksum bits");
   for (int bit = 0; bit < BBC_CHECKSUM_BITS; bit++)
       packet[GLOWWORM_addBit(gw, 0) % BBC_PACKET_LENGTH_BITS] = TRUE;
  
   GLOWWORM_del(gw);

   return packet;
}

uint32_t chipFromHash(uint64_t hash)
{
   return (uint32_t) (hash % BBC_PACKET_LENGTH_BITS);
}

void printMessagePrefix(uint8_t *message, int bits)
{
   printf("MSG: ");
   for (int i = 0; i < bits; i++)
       printf("%c", message[i]? '1' : '0');
   printf("\n");
}

void printMessage(uint8_t *message)
{
   DEBUG(printMessagePrefix(message, BBC_MESSAGE_LENGTH_BITS);)
  
   char ascii[BBC_MESSAGE_LENGTH_BYTES + 1];
   ascii[BBC_MESSAGE_LENGTH_BYTES] = NUL;
  
   for (int i = 0; i < BBC_MESSAGE_LENGTH_BYTES; i++)
   {
       ascii[i] = 0;
       for (int b = 0; b < 8; b++)
       {
           ascii[i]   <<= 1;
           ascii[i] += message[8*i+b]? 1 : 0;
       }
   }
   printf("MESSAGE: %s\n", ascii);
}

int bbc_decode(uint8_t *packet)
{
   uint8_t msgBits[BBC_MESSAGE_LENGTH_BITS + BBC_CHECKSUM_BITS];

   GLOWWORM *gw = GLOWWORM_new();
   GLOWWORM_init(gw);

   int messages = 0;
   int b = 0;
   int forward = TRUE;
   DEBUG(int trap = 0;)
   while (b >= 0)
   {
       DEBUG
       (
           printf("DEC Bit %03i: ", b);
           printf(" %s ", forward ? "->" : "<-");
           printf(" (%02i) ", trap);
           printMessagePrefix(msgBits, b);
       )
      
       // Pushing down the 0 path
       if ( (forward) && (b < BBC_MESSAGE_LENGTH_BITS + BBC_CHECKSUM_BITS) )  
       {
           msgBits[b++] = 0;
           if (packet[chipFromHash(GLOWWORM_addBit(gw, 0))])
           {
               forward = TRUE;
               DEBUG(trap = 1;)
           }
           else
           {
               GLOWWORM_delBit(gw, msgBits[--b]);
               forward = FALSE;
               DEBUG(trap = 2;)
           }
           continue;
       }
      
       // Message found
       if ( (forward) && (b >= BBC_MESSAGE_LENGTH_BITS + BBC_CHECKSUM_BITS) )
       {
           printMessage(msgBits);
           messages++;
           GLOWWORM_delBit(gw, msgBits[--b]);
           forward = FALSE;
           DEBUG(trap = 7;)
           continue;
       }
      
       // Backtracking from a 0 bit
       if ( (!forward) && (0 == msgBits[b]) )
       {
           if (b < BBC_MESSAGE_LENGTH_BITS)
           {
               msgBits[b++] = 1;
               if (packet[chipFromHash(GLOWWORM_addBit(gw, 1))])
               {
                   forward = TRUE;
                   DEBUG(trap = 3;)
               }
               else
               {
                   GLOWWORM_delBit(gw, msgBits[--b]);
                   forward = FALSE;
                   DEBUG(trap = 4;)
               }
           }
           else
           {
               GLOWWORM_delBit(gw, msgBits[--b]);
               forward = FALSE;
               DEBUG(trap = 5;)
           }
           continue;
       }
      
       // Backtracking from a 1 bit
       if ( (!forward) && (1 == msgBits[b]) )
       {
           GLOWWORM_delBit(gw, msgBits[--b]);
           forward = FALSE;
           DEBUG(trap = 6;)
           continue;
       }
      
       printf("Decoder failed to catch condition.\n");
   }
  
   GLOWWORM_del(gw);
   return messages;
}

int countMarks(uint8_t *packet)
{
   int marks = 0;
  
   for (int i = 0; i < BBC_PACKET_LENGTH_BITS; i++)
       marks += !!packet[i];
      
   return marks;
}

void printPacket(uint8_t *packet)
{
   if (BBC_PACKET_LENGTH_BITS <= 64)
   {
       printf(" ");
       for (int i = 0; i < BBC_PACKET_LENGTH_BITS; i++)
           printf("%c", (i%10)? ' ' : '0' + (i/10));
       printf("\n");
       printf(" ");
       for (int i = 0; i < BBC_PACKET_LENGTH_BITS; i++)
           printf("%c", '0' + i%10);
       printf("\n");
   }
   printf("PKT: ");
   for (int i = 0; i < BBC_PACKET_LENGTH_BITS; i++)
   {
       printf("%c", packet[i]? 'X' : '.');
       if ((i > 0) && !(i % 64))
           printf("\n ");
   }

   printf("\n");
}

double percentage(double numerator, double denominator)
{
   return 100.0 * (numerator / denominator);
}

int main(void)
{
   MyBMP *bmp = MyBMP_new(WIDTH, HEIGHT);
   MyBMP_setFilename(bmp, OUT_BMPFILENAME);
   //GLOWWORM_test(2);
  
   FILE *readFILE = fopen("message_tx.txt", "r");
  
   char input[128];
  
   uint8_t *packet = bbc_encode(NULL, (uint8_t *) "Hello World.", bmp);
  
   while( fgets(input, 128, readFILE))
   {
       bbc_encode(packet, (uint8_t *) input, bmp);
   }
  
   DEBUG(printPacket(packet);)

   int marks = countMarks(packet);  
   printf("Marks in packet: %i (%6.2f%% density)\n",
       marks, percentage(marks, BBC_PACKET_LENGTH_BITS));

   printf("Found %i messages in packet\n", bbc_decode(packet));
  
   MyBMP_save(bmp);
   MyBMP_del(bmp);
   return EXIT_SUCCESS;
}

In: Computer Science

What does it mean to say that problem is a function problem? is a decision problem?...

What does it mean to say that problem

is a function problem?

is a decision problem?

is in class NP?

is in class P?

In: Computer Science

Major interviewed (IT specialist) Conducting an informational interview with a professional currently working in a career...

Major interviewed (IT specialist)

Conducting an informational interview with a professional currently working in a career field that interests you. You are not permitted to interview parents or other close family members, but you are welcome to interview family friends/colleagues. Interviews can be done either over-the-phone or in-person, and they should last approximately 20-30 minutes. You are encouraged to consider the questions below, but you will likely need to include additional questions of your own to gather enough information for the assignment.

  • How long have you worked in this field? Where else have you worked? Did you make a career change at any point in your life?
  • What is your educational background? What did you do in college to prepare for the professional world?
  • How did you become interested in this field?
  • What is your current position title, and what do you do in your role? What are the typical work hours, responsibilities, etc.?
  • What skills, abilities, and personal attributes are essential to success in this field?
  • What is something you encountered that you didn't expect when pursuing this career path?
  • What advice would you give your younger self?

Once you have conducted your interview, you will complete a 2-page report (double-spaced, Times New Roman 12 pt. font, and 1-inch margins) that includes two parts:

  • A breakdown of the interview, itself. This can either be in Q&A format or paragraph form. (1-page minimum)
  • Your thoughts following the interview. What did you learn? What piece(s) of information will stick with you the most? Does their position/career path still interest you? Do you have any concerns about following a similar path?

In: Computer Science

For my class the first step of our homework was to make a project known as...

For my class the first step of our homework was to make a project known as "TriangleTester" to input the lengths of a triangle and have them calculate the area and perimeter. Now the 2nd step is to split the project into two classes, where "TriangleTester" asks for the user's input and "Triangle" uses a getInput() method to recieve the input and uses recursion to get the input and do the calculations for the area and perimeter.

This is for java software

Here is the first step code.

import java.util.Scanner;
public class TriangleTester {
public static void main(String[] args)
{
double side1,side2,side3;
Scanner input = new Scanner(System.in);

System.out.print("Enter lengths of sides of the triangle: ");

side1 = input.nextDouble();

side2 = input.nextDouble();

side3 = input.nextDouble();


if ((checkValidity(side1, side2, side3))==1) {

double perimeter = side1 + side2 + side3;
double area = 0;
double s = (side1 + side2 + side3)/2;
  
area = Math.sqrt(s*(s - side1)*(s - side2)*(s - side3));

System.out.println("The perimeter of the triangle is " + perimeter

+ ".");
System.out.println("The Area of the triangle is " + area + ".");

} else {

System.out.println("Those sides do not specify a valid triangle.");

}

input.close();
}
// Function to calculate for validity

private static int checkValidity(double a, double b, double c)
{

// check condition

if (a + b <= c || a + c <= b || b + c <= a)

return 0;

else

return 1;
}

}

In: Computer Science

Create a Java class file for an Account class. In the File menu select New File......

  1. Create a Java class file for an Account class.
    1. In the File menu select New File...
    2. Under Categories: make sure that Java is selected.
    3. Under File Types: make sure that Java Class is selected.
    4. Click Next.
    5. For Class Name: type Account.
    6. For Package: select csci1011.lab8.
    7. Click Finish.
    8. A text editor window should pop up with the following source code (except with your actual name):
    1. csci1011.lab8;

      /**
      *
      * @author Your Name
      */
      public class Account {

      }
  1. Implement the Account class.
    1. Add a public enum called ACCOUNT_TYPE with two values CHECKING, SAVING
    2. Add the following private instance variables to the Account class:
      • An instance variable called aType of type Enum ACCOUNT_TYPE.
      • An instance variable called accountOwner of type String.
      • An instance variable called interestRate of type double.
      • An instance variable called balance of type double
    3. Add getters and setters for the four instance variables of item (b) to the Account class:
    4. Add the following methods to the Account class:
      • A void method called initialize that takes a parameter of type ACCOUNT_TYPE, a String, two doubles and uses those arguments to set the values of the accountType, accountOwner, interestRate, and balance instance variables.
      • A void method called display that displays the account information.
      • A void method called deposit with one parameter of double that adds the given parameter to the balance instance variable.
      • A void method called withdraw with one parameter of double that deduct the given parameter from the balance instance variable. This method prints an error message when the given parameter is greater than the balance. In this case no money should be withdrawn from the account.
  • In the main method of your main class, create two Account objects and perform the following:
    • Initialize the first account objects with SAVING as the accountType and other parameters of your own choice.
    • Initialize the first account objects with CHECKING as the accountType and other parameters of your own choice.
    • Display both accounts.
    • Deposit $200 from the first account
    • Withdraw $500 from the second account
  • Display both accounts.
  • Run the main program to see if the tests were successful.
    • Here is a sample output of the program.

Account Type: SAVING

Account Owner: Customer B

Interest Rate: 1.1

Balance: 500.0

Account Type: CHECKING

Account Owner: Customer A

Interest Rate: 1.2

Balance: 200.0

Cannot withdraw more than account balance

Account Type: SAVING

Account Owner: Customer B

Interest Rate: 1.1

Balance: 700.0

Account Type: CHECKING

Account Owner: Customer A

Interest Rate: 1.2

Balance: 200.0

In: Computer Science

Write a java program that adds up the squares and adds up the cubes of integers...

Write a java program that adds up the squares and adds up the cubes of integers from 1 to N, where N is entered by the user:

Upper Limit:

5

The sum of Squares is 55

The sum of Cubes is 225

Do this by using just one loop that generates the integers. DO NOT USE ANY FORMULAS.

In: Computer Science

Data Structures in Java In the following Singly Linked List implementation, add the following methods, and...

Data Structures in Java

In the following Singly Linked List implementation, add the following methods, and write test cases in another java file to make sure these methods work.

- Write a private method addAfter(int k, Item item) that takes two arguments, an int argument k and a data item, and inserts the item into the list after the K-th list item.

- Write a method removeAfter(Node node) that takes a linked-list Node as an argument and removes the node following the given node.

- Write a method deleteKth that takes an int argument k and deletes the kth element in a linked list, if it exists.

Notice: Please do not modify the other methods in SLList class, just add the methods above.

public class SLList {
   private Node first;
   private Node last;
   private int n; // size of the list

   // helper node class
   private class Node {
      Item item;
      Node next;
   }

   // constructor: initializes an empty list
   public SLList() {
      first = last = null;
      n = 0;
   }

   public boolean isEmpty() {
      return first == null;
   }

   // return the size of the list
   public int size() {
      return n;
   }

   // insert an item at the front of the list
   public void addFirst(Item item) {
      if (isEmpty()) { // first & last refer to the same node
         first = last = new Node();
         first.item = last.item = item;
      } else {  //first refers to the new node
         Node oldFirst = first;
         first = new Node();
         first.item = item;
         first.next = oldFirst;
      }
      n++; // increment size after insertion
   }

   // insert item at the end of the list
   public void addLast(Item item) {
      if (isEmpty()) { // first & last refer to the same node
         first = last = new Node();
         first.item = last.item = item;
      } else { // last.next refers to the new node
         last = last.next = new Node();
         last.item = item;
      }
      n++; // increment size after insertion
   }

   // remove & return the first item in the list
   public Item removeFirst() {
      if (isEmpty()) {
         throw new RuntimeException("Empty List");
      }
      Item removedItem = first.item;  // retrieve the data item being removed
      if (first == last) {             // if there's only one node in the list
         // update both first & last references
         first = last = null;
      }
      else   { // otherwise, update first only
         first = first.next;
      }
      n--; // decrement size after removal
      return removedItem;
   }


   // remove & return the last item in the list
   public Item removeLast() {
      if (isEmpty()) throw new RuntimeException("empty list");
      Item removedItem = last.item;   // retrieve the data item being removed
      if (first == last) { // if there's only one node in the list,
         // update both first & last references
         first = last = null;
      }
      else {  // iterate through the list to locate the last node
         Node current = first;
         while (current.next != last) {
            current = current.next;
         }
         last = current;
         current.next = null;
         // ...  current is the new last node
         //

      } // end else
      n--; // decrement size after removal
      return removedItem;
   }

   // A String representation of this list, so that clients can print it
   // (There's no need to change it, but you can, if you'd like.)
   @Override
   public String toString() {
      StringBuilder s = new StringBuilder();
      Node current = first;
      while (current != null) {
         s.append(current.item + " -> ");
         // s.append(current.item + " ");
         current = current.next;
      }
      s.append("null");
      //s.append("\n");
      return s.toString();
   }
   private Node getNode(int index) {
      Node current = first;
      for (int i = 0; i < index; i++) {
         current = current.next;
      }
      return current;
   }

   public Item get(int index) {
      if (index < 0 || index >= n) {
         throw new IndexOutOfBoundsException("out of bounds");
      }
   return getNode(index).item;
   }

   public Item set(int index, Item item) {
      if (index < 0 || index >= n) {
         throw new IndexOutOfBoundsException("out of bounds");
      }
      Node target = getNode(index);
      Item oldItem = target.item;
      target.item = item;
      return oldItem;
   }

}

In: Computer Science

public class Book{     public String title;     public String author;     public int year;    ...

public class Book{

    public String title;
    public String author;
    public int year;
    public String publisher;
    public double cost;
      
    public Book(String title,String author,int year,String publisher,double cost){
       this.title=title;
        this.author=author;
        this.year=year;
        this.publisher=publisher;
        this.cost=cost;
    }

    public String getTitle(){
        return title;
    }
  
     public String getAuthor(){
        return author;
    }
    public int getYear(){
        return year;
    }
    public String getPublisher(){
        return publisher;
    }
    public double getCost(){
        return cost;
    }
    public String toString(){
        return "Book Details: " + title + ", " + author + ", " + year + ", " + publisher + ", " + cost;
    }
}

public interface MyQueue {
   public abstract boolean enQueue(int v);
   public abstract int deQueue();
   public abstract boolean isFull();
   public abstract boolean isEmpty();
   public abstract int size();
   public abstract int peek();
}

public interface MyStack {
   public abstract boolean isEmpty();
   public abstract boolean isFull();
   public abstract boolean push(T v);
   public abstract T pop();
   public abstract T peek();
  
}

public class MyQueueImpl implements MyQueue {
   private int capacity;
   private int front;
   private int rear;
   private int[] arr;
   public MyQueueImpl(int capacity){
       this.capacity = capacity;
       this.front = 0;
       this.rear = -1;
       this.arr = new int[this.capacity];
   }
   @Override
   public boolean enQueue(int v) {      
           if(this.rear == this.capacity - 1) {
               //Perform shift
               int tempSize = this.size();
               for(int i=0; i < tempSize; i++) {
                   arr[i] = arr[front];
                   front++;
               }
               front = 0;
               rear = tempSize - 1;
           }
           this.rear ++;
           arr[rear] = v;
           return true;
   }
   @Override
   public int deQueue() {
       return arr[front++];
      
   }
   public String toString() {
       String content = "Queue :: ";
      
       for(int i=front; i<= rear; i++) {
           content += "\n" + arr[i];
       }
       return content;
   }
   @Override
   public boolean isFull() {
       return (this.size() == this.capacity);
   }
   @Override
   public int size() {
       return rear - front + 1;
   }
   @Override
   public boolean isEmpty() {
       // TODO Auto-generated method stub
       return (this.size() == 0);
   }
   @Override
   public int peek() {
       // TODO Auto-generated method stub
       return this.arr[this.front];
   }
}

import java.lang.reflect.Array;
public class MyStackImpl implements MyStack {
   // TODO write your code here
  
  
   @Override
   public boolean isEmpty() {
       // TODO Auto-generated method stub
       return false;
   }

   @Override
   public boolean isFull() {
       // TODO Auto-generated method stub
       return false;
   }
  
   @Override
   public boolean push(T v) {
       // TODO write your code here
      
       return true;
   }

   @Override
   public T pop() {
       // TODO write your code here
      
       return null;
      
   }
  
   public String toString() {
       // TODO write your code here
      
      
      
       return "";
   }

   @Override
   public T peek() {
       // TODO Auto-generated method stub
       return null;
   }

}

make test classs   

write your code here
        Create a queue object.
        insert 5 Books in the Queue
        Create a stack object.
        Use the stack to reverse order of the elements in the queue.

In: Computer Science

Using Matlab do the following Write a program that will accept a number from the user...

Using Matlab do the following

Write a program that will accept a number from the user and:

  1. Check if the number between 50 and 100both inclusive. If yes print a comment. If not print a warning.
  2. The program sums the inserted values
  3. This process continues until the user inserts the number 999 . At this point the program quits and prints the result of (2)

In: Computer Science

Java Question: What is exception propagation? Give an example of a class that contains at least...

Java Question:

What is exception propagation? Give an example of a class that contains at least two methods, in which one method calls another. Ensure that the subordinate method will call a predefined Java method that can throw a checked exception. The subordinate method should not catch the exception. Explain how exception propagation will occur in your example.

In: Computer Science

Given: struct Person { int id;     int stats[3] }; Which is the correct way to...

Given:

struct Person
{
int id;
    int stats[3]
};

Which is the correct way to initialise an array of Persons?

1.

struct Person persons[2] = {7, "8,9,3", 8, "2,5,9"};

2.

struct Person persons[2] = "7, {8,9,3}, 8, {2,5,9}";

3.

struct Person persons[2] = "7, "8,9,3", 8, "2,5,9";

4.

struct Person persons[2] = {7, {8,9,3}, 8, {2,5,9}};

Which of the following is not a primitive type in the C language?

1.

string

2.

int

3.

long

4.

char

Given:

struct Person
{
int id;
    int stats[3]
};

Which is the correct way to access the 2nd member of stats in an instance named John?

1.

John.stats[2]

2.

John->stats[2]

3.

John->stats[1]

4.

John.stats[1]

Given:

struct Person
{
int id;
    int stats[3]
};

Which is the correct way to initialise an instance of Person?

1.

struct Person John = "5,{4,5,6}";

2.

struct Person John = {"5", "4,5,6"};

3.

struct Person John = {5, {4,5,6}};

4.

Person John = {5, {4,5,6}};

Instead of using parallel arrays with a key and value array, we can create a derived type with members that represent the key – value pair.

True

False

A derived type is a collection of other types.

True

False

Given:

struct Person
{
int id;
    int stats[3]
};

*John.stats[0]; will retrieve the fist element of stats in a Person instance named John.

True

False

What is the key word used to create a user defined (derived) type in the C language?

1.

class

2.

object

3.

collection

4.

struct

In: Computer Science