Answers

Answer 1

the technique used is Data Validation


Related Questions

Assume that an O(log2N) algorithm runs for 10 milliseconds when the input size (N) is 32. What input size makes the algorithm run for 14 milliseconds

Answers

Answer:

An input size of N = 128 makes the algorithm run for 14 milliseconds

Explanation:

O(log2N)

This means that the running time for an algorithm of length N is given by:

[tex]F(N) = c\log_{2}{N}[/tex]

In which C is a constant.

Runs for 10 milliseconds when the input size (N) is 32.

This means that [tex]F(32) = 10[/tex]

So

[tex]F(N) = c\log_{2}{N}[/tex]

[tex]10 = c\log_{2}{32}[/tex]

Since [tex]2^5 = 32, \log_{2}{32} = 5[/tex]

Then

[tex]5c = 10[/tex]

[tex]c = \frac{10}{5}[/tex]

[tex]c = 2[/tex]

Thus:

[tex]F(N) = 2\log_{2}{N}[/tex]

What input size makes the algorithm run for 14 milliseconds

N for which [tex]F(N) = 14[/tex]. So

[tex]F(N) = 2\log_{2}{N}[/tex]

[tex]14 = 2\log_{2}{N}[/tex]

[tex]\log_{2}{N} = 7[/tex]

[tex]2^{\log_{2}{N}} = 2^7[/tex]

[tex]N = 128[/tex]

An input size of N = 128 makes the algorithm run for 14 milliseconds

Code an operation class called ArrayComputing that will ask user to enter a serials of integers with a loop until -99 is entered and after the input it will keep and display the greatest, the least, the sum and the average of the data entries (-99 is not counted as the data). And code a driver class called ArrayComputingApp to run and test the ArrayComputing class, separately.
Must use required/meaningful names for fields, variables, methods and classes.
Must use separate methods to perform each of specified tasks as described.
Must document each of your source code

Answers

Answer:

Explanation:

The following is written in Java and creates the ArrayComputing class. It uses the constructor to create the infinite loop that only breaks when the user enters a -99. After every input number it goes adding the correct values to the variables. Once it is done the user can call any of the getter methods to get the variable values as well as calculate the average.

import java.util.Scanner;

class ArrayComputingApp {

   public static void main(String[] args) {

       ArrayComputing arrayComputing = new ArrayComputing();

       System.out.println("Average: " + arrayComputing.getAverage());

       System.out.println("Greatest: " + arrayComputing.getGreatest());

       System.out.println("Least: " + arrayComputing.getLeast());

       System.out.println("Sum: " + arrayComputing.getSum());

   }

}

class ArrayComputing {

   int greatest, least, sum, average;

   int count = 0;

   Scanner in = new Scanner(System.in);

   public ArrayComputing() {

       while (true) {

           System.out.println("Enter a number or -99 to exit: ");

           int num = in.nextInt();

           if (num == -99) {

               break;

           }

           if (num > this.greatest) {

               this.greatest = num;

           }

           if (this.count == 0) {

               this.least = num;

           } else {

               if (num < this.least) {

                   this.least = num;

               }

           }

           this.sum += num;

           this.count += 1;

       }

   }

   public int getAverage() {

       this.average = sum / count;

       return this.average;

   }

   public int getGreatest() {

       return greatest;

   }

   public int getLeast() {

       return least;

   }

   public int getSum() {

       return sum;

   }

}

Write a main function that declares an array of 100 ints. Fill the array with random values between 1 and 100.Calculate the average of the values in the array. Output the average.

Answers

Answer:

#include <stdio.h>

int main()

{

   int avg = 0;

   int sum =0;

   int x=0;

   /* Array- declaration – length 4*/

   int num[4];

   /* We are using a for loop to traverse through the array

    * while storing the entered values in the array

    */

   for (x=0; x<4;x++)

   {

       printf("Enter number %d \n", (x+1));

       scanf("%d", &num[x]);

   }

   for (x=0; x<4;x++)

   {

       sum = sum+num[x];

   }

   avg = sum/4;

   printf("Average of entered number is: %d", avg);

   return 0;

}

Create a variable in php to store your university information and parse using jQuery Ajax and print your name. The variable must contain information about name, roll no, department and CGPA.

Answers

AnswLab giya j ty dy dio:

Explanation:

9. Which of the following prefixes which relate to bytes are arranged from the smallest to the largest? a) mega, giga, tera, kilo b) meqa tera, giga, kilo c) kilo, mega, giga, tera d) kilo, giga, mega, tera​

Answers

Answer:

Explanation:

C

kilo = 1000

mega = 1,000,000

giga = 1 billion = 1 000 000 000

tera = 1 trillion = 1 000 000 000  000

Write a recursive function that calculates the sum 11 22 33 ... nn, given an integer value of nin between 1 and 9. You can write a separate power function in this process and call that power function as needed:

Answers

Answer:

The function in Python is as follows:

def sumDig(n):

if n == 1:

 return 11

else:

 return n*11 + sumDig(n - 1)

Explanation:

This defines the function

def sumDig(n):

This represents the base case (where n = 1)

if n == 1:

The function returns 11, when it gets to the base case

 return 11

For every other value of n (n > 1)

else:

This calculates the required sum recursively

 return n*11 + sumDig(n - 1)

What is machine learning

Answers

Answer:

machine learning is the ability for computers to develop new skills and algorithms without specific instructions to do so.

Machine learning is a branch of artificial intelligence (AI) and computer science which focuses on the use of data and algorithms to imitate the way that humans learn, gradually improving its accuracy.

Print the two strings in alphabetical order. Assume the strings are lowercase. End with newline. Sample output: capes rabbits import java.util.Scanner: public class OrderStrings { public static void main (String args) { String firstString: String secondString: firstString = "rabbits" secondString = "capes" /*Your solution goes here */ return: } }import java.util.Scanner;public class OrderStrings { public static void main(String[] args) { String firstString; String secondString; firstString = "rabbit"; secondString= "capes"; //String class in java provide string comparison function, use it, and get //your work done may even use brute force i.e using for loop and compare character by // character which will not good for the programming language which already have vast //predefined number of functions if(firstString.compareTo(secondString) < 0){ System.out.println(firstString + " " + secondString); } else{ System.out.println(secondString + " " + firstString); } return; }}

Answers

Answer:

Following are the code to the given question:

import java.util.Scanner;//import package

public class OrderStrings // defining a class OrderStrings  

{

   public static void main(String[] args) //defining a main method

   {

       Scanner scnr = new Scanner(System.in);//defining a Scanner class object  

       String firstString;//defining a String variable

       String secondString; //defining a String variable

       firstString = scnr.next();//input value

       secondString = scnr.next();//input value

       if (firstString.compareTo(secondString) < 0)//use if to compare sting value

           System.out.println(firstString + " " + secondString);//print sting value  

       else//else block

           System.out.println(secondString + " " + firstString);//print sting value

   }

}

Output:

rabbits capes

capes rabbits

Explanation:

In this code a class "OrderStrings" is defined inside the class the main method is defined that declares the two string variable that uses the input method to input the string value and after input, it uses the conditional statement. Inside this compareTo method is declared that compare string value and prints the string value.

We have removed
A
balls from a box that contained
N
balls and then put
B
new balls into that box. How many balls does the box contain now?
Constraints
All values in input are integers.
Input
Input is given from Standard Input in the following format: n a b
Output
Print the answer as an integer.

Answers

There were [tex]N[/tex] balls but we took [tex]A[/tex] balls out, so there are now [tex]N-A[/tex] balls. We add [tex]B[/tex] balls and now we have [tex]N-A+B[/tex] balls.

The program that computes this (I will use python as language has not been specified is the following):

n, a, b = int(input()), int(input()), int(input())

print(f"There are {n-a+b} balls in the box")

# Hope this helps

Fred is a 29 year old golfer, who has been playing for 4 years. He is a 12 handicap. He is considering the Srixon ZX5 or the Mavrik Pro. Talk through major considerations and provide a recommendation that would be well suited for him. Include explanations about forged vs cast features, the look of the club, and overall feel.

Answers

Answer:

oh nice yes good fine I like it

9.18 LAB: Exact change - methods Write a program with total change amount as an integer input that outputs the change using the fewest coins, one coin type per line. The coin types are dollars, quarters, dimes, nickels, and pennies. Use singular and plural coin names as appropriate, like 1 penny vs. 2 pennies. Ex: If the input is:

Answers

Answer:

Explanation:

The following code is written in Java. It asks the user to enter the amount of change needed. This is done as a double since we are dealing with coins and not full dollar values alone. It then makes the necessary calculations to calculate the number of each coin needed and outputs it back to the user. A test case has been provided in the picture below with a sample output.

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       int dollars = 1;

       double quarters = 0.25;

       double dimes = 0.10;

       double nickels = 0.05;

       double pennies = 0.01;

       Scanner in = new Scanner(System.in);

       System.out.println("Enter Change Value: ");

       double change = in.nextDouble();

       int numDollars, numQuarters, numDimes, numNickels, numPennies;

       double newChange;

       numDollars = (int) (change / dollars);

       newChange = change % dollars;

       numQuarters = (int) (newChange / quarters);

       newChange = newChange % quarters;

       numDimes = (int) (newChange / dimes);

       newChange = newChange % dimes;

       numNickels = (int) (newChange / nickels);

       newChange = newChange % nickels + 0.001;

       numPennies = (int) (newChange / pennies);

       newChange = newChange % pennies;

       

       System.out.println("Minimum Num of Coins needed: ");

       if (numDollars != 1) {

           System.out.println(numDollars + " Dollars");

       } else {

           System.out.println(numDollars + " Dollar");

       }

       if (numQuarters != 1) {

           System.out.println(numQuarters + " Quarters");

       } else {

           System.out.println(numQuarters + " Quarter");

       }

       if (numDimes != 1) {

           System.out.println(numDimes + " Dimes");

       } else {

           System.out.println(numDimes + " Dime");

       }

       if (numNickels != 1) {

           System.out.println(numNickels + " Nickels");

       } else {

           System.out.println(numNickels + " Nickel");

       }

       if (numPennies != 1) {

           System.out.println(numPennies + " Pennies");

       } else {

           System.out.println(numPennies + " Penny");

       }

   }

}

The program is an illustration of conditional statements

Conditional statements are used to make decisions

The program in C++ where comments are used to explain each line is as follows

#include<iostream>

using namespace std;

int main() {

// This line declare all the variables

int amount, dollar, quarter, dime, nickel, penny;

// This prompts the user for input (i.e. the amount)

cout<<"Amount: ";

//This gets the amount from the user

cin>>amount;

// This checks if the amount is 0 or less

if(amount<=0)  {

//This prints "No Change"

cout<<"No Change";

}

//If the amount is greater than 0

else {

// These convert the amount to various coins

dollar = amount/100;

amount = amount%100;

quarter = amount/25;

amount = amount%25;

dime = amount/10;

amount = amount%10;

nickel = amount/5;

penny = amount%5;

// The next lines print the coins

if(dollar>=1)  {

if(dollar == 1) {

cout<<dollar<<" dollar\n"; }

else {

cout<<dollar<<" dollars\n"; }

}

if(quarter>=1) {

if(quarter== 1) {

cout<<quarter<<" quarter\n";

}

else {

cout<<quarter<<" quarters\n";

}

}

if(dime>=1) {

if(dime == 1) {

cout<<dime<<" dime\n";

}

else {

cout<<dime<<" dimes\n";

}

}

if(nickel>=1) {

if(nickel == 1) {

cout<<nickel<<" nickel\n";

}

else {

cout<<nickel<<" nickels\n";

}

}

if(penny>=1) {

if(penny == 1) {

cout<<penny<<" penny\n";

}

else {

cout<<penny<<" pennies\n";

}

}

}

return 0;

}

Read more about conditions at:

https://brainly.com/question/15683939

..............is a piece of hardware used to provide data and instructions to a computer used for interaction and control. *
Output device.
Processing.
input device.
All of above. ​

Answers

Answer:

output

Explanation:

it can be seen and touched

Select the correct statement(s) regarding 4B5B encoding.
a. 4B5B is used to map four codeword bits into a five bit data word
b. 4B5B information bit rate is 80% of the total (information plus overhead) bit rate
c. 4B5B information bit rate is 20% of the total (information plus overhead) bit rate
d. all statements are correct

Answers

Answer:

b. 4B5B information bit rate is 80% of the total information plus overhead bit rate.

Explanation:

4B5B bit rate encoding means there is 80% of the bit rate which included all the information plus the overheads. There is 20% of lack in bit rate due to encoding code words which converts data into smaller bits.

What is the default return type of a method in Java language?

A.Void

B.Int

C.None

D.Short

Answers

Answer:

The default return data type in function is int

Answer: Option (b)

Explanation:

The default return data type in a function is int. In other words commonly if it is not explicitly mentioned the default return data type of a function by the compiler will be of an integer data type.

If the user does not mention a return data type or parameter type, then C programming language will inevitably make it an int.

mark me brainlist

im sure its option b!!

how much is this worth in dollars​

Answers

Answer:

This is worth 50 dollars.

Explanation:

١ - one

٢ - two

٣ - three

٤ - four

٥ - five

٦ - six

٧ - seven

٨ - eight

٩ - nine

٠ - zero

What you see above is the ten digits in Arabic.

Both 5 (٥) and 0 (٠) appear here, thus representing 50.


1. What is memory mapped I/O?

Answers

Answer:

Memory-mapped I/O and port-mapped I/O are two complementary methods of performing input/output between the central processing unit and peripheral devices in a computer. An alternative approach is using dedicated I/O processors, commonly known as channels on mainframe computers, which execute their own instructions.

Indicate whether the following actions are the actions of a person who will be a victim, or will not be a victim, of phishing attacks.

Replying to an e-mail requesting your user ID and password Phishing victim Not a phishing victim

Answers

Answer:

Phishing Victim

Explanation:

Replying to this email could make you a victim of a phishing scam. Phishing attacks are common challenges on security that internet users are faced with. It could lead to others getting hold of sensitive information like your password or bank details. email is one way the hackers used to get this information. replying to such an email could lead one to an unsecure website where information could be extracted

From which panel can you insert Header and Footer in MS Word?​

Answers

Answer:

Insert tap is the answer

the answer is ..

insert tab

You've arrived on site to a WAN installation where you will be performing maintenance operations. You have been told the WAN protocol in use allows multiple Layer 3 protocols and uses routers that use labels in the frame headers to make routing decisions. What WAN technology is in use

Answers

Answer:

The answer is "MPLS".

Explanation:

The MPLS stands for Multiprotocol Label Switching. This packet switching method facilitates the generation of easier personal backbones using a less physical channel, which sends information from one source to its destination with labels rather than IP addresses. Many of these WAN services are sold through huge companies. It is also a technology for data transfer that boosts speed and regulates network traffic flow. The information is directed with this technology via a label rather than needing complicated surveys at every stop in a route cache.

Your network has four Hyper-V hosts, which are running three domain controllers and about 10 member servers. Three of the member servers named HR1, HR2, and HR3 are running on a Windows Server 2012 R2 Hyper-V host; the others are running on Windows Server 2016 Hyper-V hosts. All VMs are running Windows Server 2016. You are currently running an enterprise human resources application on the HR1, HR2, and HR3 servers. You are considering upgrading this application to a new version that was recently released. Before you proceed with the upgrade, you set up a test environment consisting of a Windows Server 2016 Hyper-V host and three VMs. You haven't been using checkpoints on any of your VMs, but you want to start doing so as an extra form of disaster recovery in the event of VM corruption or errors introduced by updates. On your test environment, you want to use checkpoints while you are testing the new application. What type of checkpoints should you use throughout your live network and test network? Explain.

Answers

Answer:

Explanation:

Draw a Card. Write a program to simulate drawing a card. Your program will randomly select one card from a deck of 52 playing cards. Your program should display the rank (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King) and suit (Clubs, Diamonds, Hearts, Spades) of the card. Here is a sample run of the program: in The card you picked is Jack of Heart The program should use at a minimum: sequence, selection, arrays, and random numbers.

Answers

Answer:

Explanation:

The following code is written in Java. It is a function that creates a Random object to generate random values, then uses those values to choose a random rank and suit using switch statements. It then saves the rank and suit into a String variable in the correct format and finally prints the card that was picked to the screen. The function was called 4 times in the main method and the output can be seen in the attached image below.

public static void randomCardGenerator() {

       Random rand = new Random();

       int rank = rand.nextInt(14)+1;

       int suit = rand.nextInt(4)+1;

       String chosenCard = "";

       switch (rank) {

           case 1: chosenCard += "Ace"; break;

           case 2: chosenCard += "1"; break;

           case 3: chosenCard += "2"; break;

           case 4: chosenCard += "3"; break;

           case 5: chosenCard += "4"; break;

           case 6: chosenCard += "5"; break;

           case 7: chosenCard += "6"; break;

           case 8: chosenCard += "7"; break;

           case 9: chosenCard += "8"; break;

           case 10: chosenCard += "9"; break;

           case 11: chosenCard += "10"; break;

           case 12: chosenCard += "Jack"; break;

           case 13: chosenCard += "Queen"; break;

           case 14: chosenCard += "Kind"; break;

           default: System.out.println("Wrong Value");

       }

       chosenCard += " of ";

       switch (suit) {

           case 1: chosenCard += "Clubs"; break;

           case 2: chosenCard += "Diamonds"; break;

           case 3: chosenCard += "Hearts"; break;

           case 4: chosenCard += "Spades"; break;

           default: System.out.println("Invalid Suit");

       }

       System.out.println(chosenCard);

   }

Explain the following terms.
a) Explain Final keyword with example. b) Define Static and Instance variables

Answers

Answer:

A.

the final keyword is used to denote constants. It can be used with variables, methods, and classes. Once any entity (variable, method or class) is declared final , it can be assigned only once.

B.

Static variables are declared in the same place as instance variables, but with the keyword 'static' before the data type. While instance variables hold values that are associated with an individual object, static variables' values are associated with the class as a whole.

Write a java program that reads a list of integers and outputs those integers in reverse. The input begins with an integer indicating the number of integers that follow. For coding simplicity, follow each output integer by a comma, including the last one. Assume that the list will always contain fewer than 20 integers.


Ex: If the input is:


5 2 4 6 8 10

the output is:


10,8,6,4,2,

To achieve the above, first read the integers into an array. Then output the array in reverse.

Answers

Answer:

Explanation:

using namespace std;

#include <iostream>

int Go()

{

 

int N;

int A[20];

 

 

cout << " How many integers do you have ??? :>";

cin >> N;

if (N>20) { N=20; }

 

for (int iLoop=0; iLoop<N; iLoop++)

{

 

 cout << "Input integer # " << (iLoop+1) << " :>";  

  cin >> A[iLoop];  

 

}

 

for (int iLoop=N-1; iLoop>=0; iLoop--)

{

 cout << A[iLoop] << " ";

}

cout << endl;

 

 

}

int main()

{

Go();

}

A Java program that reads a list of integers and outputs them in reverse is written as,

import java.util.Scanner;

public class ReverseList {

   public static void main(String[] args) {

       Scanner scnr = new Scanner(System.in);

       

       // Read the number of integers

       int numIntegers = scnr.nextInt();

       

       // Create an array to store the integers

       int[] integers = new int[numIntegers];

       

       // Read the integers into the array

       for (int i = 0; i < numIntegers; i++) {

           integers[i] = scnr.nextInt();

       }

       

       // Output the integers in reverse order

       for (int i = numIntegers - 1; i >= 0; i--) {

           System.out.print(integers[i]);

           

           // Add comma unless it's the last integer

           if (i > 0) {

               System.out.print(",");

           }

       }

       

       System.out.println(); // Add a new line at the end

   }

}

Given that,

Write a Java program that reads a list of integers and outputs those integers in reverse.

Here, The input begins with an integer indicating the number of integers that follow.

For coding simplicity, follow each output integer by a comma, including the last one.

So, A Java program that reads a list of integers and outputs them in reverse:

import java.util.Scanner;

public class ReverseList {

   public static void main(String[] args) {

       Scanner scnr = new Scanner(System.in);

       

       // Read the number of integers

       int numIntegers = scnr.nextInt();

       

       // Create an array to store the integers

       int[] integers = new int[numIntegers];

       

       // Read the integers into the array

       for (int i = 0; i < numIntegers; i++) {

           integers[i] = scnr.nextInt();

       }

       

       // Output the integers in reverse order

       for (int i = numIntegers - 1; i >= 0; i--) {

           System.out.print(integers[i]);

           

           // Add comma unless it's the last integer

           if (i > 0) {

               System.out.print(",");

           }

       }

       

       System.out.println(); // Add a new line at the end

   }

}

Read more about java programming language at:

brainly.com/question/2266606

#SPJ4

When implementing a 1:1 relationship, where should you place the foreign key if one side is mandatory and one side is optional? Should the foreign key be mandatory or optional?

Answers

Answer:

When implementing a 1:1 relationship, the foreign key should be placed on the optional side if one side is mandatory and one side is optional.  

When this is implemented, the foreign key should be made mandatory.

Explanation:

A foreign key (FK) is a primary key (PK) in relational databases.  It is used to establish a relationship with a table that has the same attribute with another table in the database.  A mandatory relationship exists when the foreign key depends on the parent (primary key) and cannot exist without the parent.  A one-to-one relationship exists when one row in a data table may be linked with only one row in another data table.

1. Write the CSS for an id with the following characteristics: fixed position, light grey background color, bold font weight, and 10 pixels of padding

Answers

Answer:

#element

{

position: fixed;

background-color: RGBA(211, 211, 211, 1);

font-weight: bold;

padding: 10px;  

}

Write a program that uses a stack to test input strings to determine whether they are palindromes. A palindrome is a sequence of characters that reads the same as the sequence in reverse; for example, noon.

Answers

Answer:

Here the code is given as follows,

Explanation:

def isPalindrome(x):

   stack = []

   #for strings with even length

   if len(x)%2==0:

       for i in range(0,len(x)):

           if i<int(len(x)/2):

               stack.append(x[i])

           elif stack.pop()!=x[i]:

               return False

       if len(stack)>0:

           return false

       return True

   #for strings with odd length    

   else:

       for i in range(0,len(x)):

           if i==int(len(x)/2):

               continue

           elif i<int(len(x)/2):

               stack.append(x[i])

           elif stack.pop()!=x[i]:

               return False

       if len(stack)>0:

           return false

       return True  

def main():  

   while True:  

       string = input("Enter a string or Return to quit: ")  

       if string == "":  

           break  

       elif isPalindrome(string):  

           print("It's a palindrome")  

       else:  

           print("It's not a palindrome")  

if __name__ == '__main__':  

   main()

Transformative Software develops apps that help disabled people to complete everyday tasks. Its software projects are divided into phases in which progress takes place in one direction. The planning, delivery dates, and implementation of the software under development are emphasized. Which software development methodology is the company most likely using:_________.

Answers

Answer: Cascading

Explanation:

The software development methodology that the company is most likely using is Cascading.

Cascading model is a sequential design process, that is used in software development, whereby progress flows downward from the conception phase, initiation phase, till it gets to the maintenance phase.

Given main(), complete the Car class (in file Car.java) with methods to set and get the purchase price of a car (setPurchasePrice(), getPurchasePrice()), and to output the car's information (printInfo()).
Ex: If the input is:
2011
18000
2018
where 2011 is the car's model year, 18000 is the purchase price, and 2018 is the current year, the output is:
Car's information:
Model year: 2011
Purchase price: 18000
Current value: 5770
Note: printInfo() should use three spaces for indentation.

Answers

Answer and Explanation:

public class Main {

int Carmodel;

int Purchaseprice;

int Currentyear;

Public void setPurchasePrice(int Purchaseprice){

this.Purchaseprice=Purchaseprice;

}

Public void getPurchasePrice(){

return Purchaseprice;

}

static void printInfo(int Carmodel int Currentyear ){

this.Carmodel=Carmodel;

this.Currentyear=Currentyear;

System.out.println(getPurchasePrice() Carmodel Currentyear);

}

}

The above java program defines a class that has three methods, a get method that returns purchase price of the object, a set method that sets purchase price of the object, and a print method that print out the information about the car object(model, year, price). The print method also takes arguments and assigns values of the arguments/parameters to the object, then prints all.

what is the characteristics of computer?dicuss any 5 of them​

Answers

Answer:

speed

accuracy

diligence

versatility

reliabiility

memory

speed: a computer works with more higher speed compared to humans when performing mathematical calculations

accuracy: computer perform calculations with 100% accuracy

dilligence:a computer can perform calculations with the same consistentcy and accuracy

versatility:refers to the capability of a computer to perform different kind of works with same accuracy and efficiencies

reliability

Answer:

speed

accuracy

diligent

versatile

storage and communication

3. Circular, array-backed queue In the following class, which you are to complete, the backing array will be created and populated with Nones in the __init__ method, and the head and tail indexes set to sentinel values (you shouldn't need to modify __init__). Enqueuing and Dequeuing items will take place at the tail and head, with tail and head tracking the position of the most recently enqueued item and that of the next item to dequeue, respectively. To simplify testing, your implementation should make sure that when dequeuing an item its slot in the array is reset to None, and when the queue is emptied its head and tail attributes should be set to -1.

Answers

Answer:

#Implementation of Queue class

class Queue

   #Implementation of _init_

   def _init_(self, limit=10):

       #calculate the self.data

       self.data = [None] * limit

       self.head = -1

       self.tail = -1

   #Implementation of enqueue function

   def enqueue(self, val):

       #check self.head - self.tail is equal to 1

       if self.head - self.tail == 1:

           raise NotImplementedError

       #check len(self.data) - 1 is equal to elf.tail

       if len(self.data) - 1 == self.tail and self.head == 0:

           raise NotImplementedError

       #check self.head is equal to -1

       if self.head == -1 and self.tail == -1:

           self.data[0] = val

           self.head = 0

           self.tail = 0

       else:

           #check len(self.data) - 1 is equal to self.tail

           if len(self.data) - 1 == self.tail and self.head != 0:

               self.tail = -1

           self.data[self.tail + 1] = val

           #increment the self.tail value

           self.tail = self.tail + 1

   #Implementation of dequeue method

   def dequeue(self):

       #check self.head is equal to self.tail

       if self.head == self.tail:

           temp = self.head

           self.head = -1

           self.tail = -1

           return self.data[temp]

   

       #check self.head is equal to -1

       if self.head == -1 and self.tail == -1:

           #raise NotImplementedError

          raise NotImplementedError

       #check self.head is not equal to len(self.data)

       if self.head != len(self.data):

           result = self.data[self.head]

           self.data[self.head] = None

           self.head = self.head + 1

       else:

          # resetting head value

           self.head = 0

           result = self.data[self.head]

           self.data[self.head] = None

           self.head = self.head + 1

       return result

   #Implementation of resize method

   def resize(self, newsize):

       #check len(self.data) is less than newsize

       assert (len(self.data) < newsize)

       newdata = [None] * newsize

       head = self.head

       current = self.data[head]

       countValue = 0

       #Iterate the loop

       while current != None:

           newdata[countValue] = current

           countValue += 1

           #check countValue is not equal to 0

           if countValue != 0 and head == self.tail:

               break

           #check head is not equal to

           #len(self.data) - 1

           if head != len(self.data) - 1:

               head = head + 1

               current = self.data[head]

           else:

               head = 0

               current = self.data[head]

     self.data = newdata

       self.head = 0

       self.tail = countValue - 1

   #Implementation of empty method

   def empty(self):

       #check self.head is equal to -1

       # and self.tail is equal to -1

       if self.head == -1 and self.tail == -1:

           return True

       return False

   #Implementation of _bool_() method

   def _bool_(self):            

       return not self.empty()

   #Implementation of _str_() method        

   def _str_(self):

       if not (self):

           return ''

       return ', '.join(str(x) for x in self)

   #Implementation of _repr_ method

   def _repr_(self):

       return str(self)

   #Implementation of _iter_ method

   def _iter_(self):

       head = self.head

       current = self.data[head]

       countValue = 0

       #Iterate the loop

       while current != None:

           yield current

           countValue += 1

           #check countValue is not equal to zero

           #check head is equal to self.tail

           if countValue != 0 and head == self.tail:

               break

           #check head is not equal to len(self.data) - 1

           if head != len(self.data) - 1:

               head = head + 1

               current = self.data[head]

           else:

               head = 0

               current = self.data[head

Explanation:-

Output:

Other Questions
which of the following represents 10 on a number line There is a circle with a center of 0,0 on a coordinate plane. There is one point on the circle's circumference in which the x:y ratio is 3:1. What is a possible coordinate? Blade Breeze Company manufactures ceiling fans and uses an activity-based costing system. Each ceiling fan has 20 separate parts. The direct materials cost is $70, and each ceiling fan requires 2.50 hours of machine time to manufacture. Additional information is as follows: Activity Allocation Base Predetermined Overhead Allocation Rate Materials handling Number of parts $ 0.08 Machining Machine hours 7.20 Assembling Number of parts 0.35 Packaging Number of finished units 2.80What is the cost of machining per ceiling fan? (Round any intermediate calculations and your final answer to the nearest cent.) A) $18.00 B) $70.00 C) $144.00 D) $196.00 What is happening with Unemployment of Indonesia over the past 2 or 3 years? Help me please In the graph above, which vertical line (V) and horizontal line (H) can be used to graph point A?A) V: x = 1; H: y = 4B) V: x = 4; H: y = 1C) V: y = 4; H: x = 1D) V: x = 1; H: y = 4 This happens because the.....particles are most likely to escape from the liquid, causing the temperature of the liquid to..... IT will be shown as hypertension if the blood pressure of an individual is ______a)120/80b)130/70c)140/90d)100/80 A chef is going to use a mixture two different brands of Italian dressing the first spring and days 5% vinegar the second brain contains 15% vinegar the sheriff wants to make 390$ ml addressing that is 9% vinegar how much of each brand should she use Which health decisions can decrease the risk of non-communicable diseases Help help help help help through: (3, - 3); slope = 2/3 Jeremy is buying a new car. The total cost, including tax, is $18275. If the tax rate is 7.5% , what is the sticker price of the car? 18The length of a rectangle is twice as long as the width of the rectangle.The area of the rectangle is 32 cm.Draw the rectangle on the centimetre grid..454B2%I did it wrong can someone help me Define electric current and drift velocity. Give reason. Mosquitoes and housefly are placed in the phylum arthropoda Which answer below uses atransitional word or phrase?A. I hope we can go to the store later -- we need to keepcleaning the house.B. I hope we can go to the store later; in the meantime, weneed to keep cleaning the house.C. We need to keep cleaning the house, I hope we can go tothe store later.Copyright 2021 Acelus Corporation. All Rights R A pendulum's height is modeled by the function h(t) = 4 cos(pi/4*t) + 8 where h is themeasure of the pendulum's height in feet and t is the number of seconds since themaximum height. How many seconds does it take the pendulum to complete onefull swing? A student designed an experiment to demonstrate the interaction between Earth systems. The steps of the experiment are given belowFill three-fourths of a glass jar with water. Add a teaspoon of liquid dish soap and a teaspoon of vinegar to water.Tighten the lid and shake the jar to mix the ingredients. Swirl the jar in a circular motion and watch the spinning motion of the liquid inside.The student's experiment demonstrates the formation ofblizzard due to the interactions between the hydrosphere and geospherehurricanes due to the interactions between the geosphere and atmosphere tornadoes due to the interactions between the hydrosphere and atmosphere thunderstorms due to the interactions between the hydrosphere and cryosphere(Just took the test, it's C) A researcher collects demographic data on the marital status of the study subjects. The variable is measured as married/divorced/separated/widowed/never married/cohabitating. What would be the most appropriate measure of central tendency