Questions
Suppose THREE packets, each of length, L = 20 bits arrive at a router at the...

Suppose THREE packets, each of length, L = 20 bits arrive at a router at the same time. Assume that there are no packets being transmitted or queued at the router. Let the router's transmission rate, R = 5 bit/seconds.

1.What is the queuing delay for each of these 3 packets?

2.What is the average queuing delay for the 3 packets?

3.Suppose the speed of propagation is s m/s, the distance between A and B is d meters, and the transmission rate of the link between A and B is R bps.Consider sending two packets of size L1 bits and L2 bits from A to B.

What is the total delay of sending these two packets from A to B in terms of L1, L2, R, d and s? Ignore the processing delay.

In: Computer Science

Complete the PA7_incomplete.py program (posted below) for an infinite interactive loop to process a dictionary. The...

Complete the PA7_incomplete.py program (posted below) for an infinite interactive loop to process a dictionary. The program starts by asking an input file name where the dictionary entries are stored. This file will be assumed be present and to contain two items in each line as key and value pairs separated by a comma, like the example.txt file (posted below). The file could be possibly empty. The program reads the contents of this file into a dictionary, closes the file and presents user with the following menu choices in an infinite loop: Add an entry Show value for a key Delete an entry Save the file Print the current dictionary Quit Complete rest of the program to process the dictionary interactively with the user. The following appropriate actions should be taken for each one of them and then the menu should be shown again unless the user quits. Add an entry: Ask the user for the key and value, and make an entry, if the key already exists then prompt the user whether to overwrite its value. Show value for a key: Ask the user for the key and show the corresponding value, point out if the key does not exist.


def main():
d = {} # dictionary

# Read the file's contents in the dictionary d
filename = input("Give the file name: ")
file = open(filename,"r")
for line in file:
# read key and value
key, value = line.split(",")
# remove whitespaces before and after
key = key.lstrip()
key = key.rstrip()
value = value.lstrip()
value = value.rstrip()
# insert entry in the dictionary
d[key] = value
file.close()

loop=True # continue looping if true

while (loop):
print("\n\nEnter one of the following menu choices:")
print("1 Add an entry")
print("2 Show value for a key")
print("3 Delete an entry")
print("4 Save the file")
print("5 Print the current dictionary")
print("6 Quit")
choice = input("Choice 1-6: ")
print("\n\n")

if (choice=="1"): # Add an entry
k = input("Give the key: ")
v = input("Give its value: ")
# complete the rest
elif (choice=="2"): # Show value for a key
k = input("Give the key: ")
# complete the rest
elif (choice=="3"): # Delete an entry
k = input("Give the key to delete the entry: ")
# complete the rest
elif (choice=="4"): # Save the file
print("Saving the file")
# complete the rest
elif (choice=="5"): # Print the current dictionary
l = list(d.keys()) # get all the keys
l.sort() # sort them
# complete the rest
elif (choice=="6"): # Quit
loop=False
# complete the rest
else :
print("Incorrect choice")

Delete an entry: Ask the user for the key and delete the entry, point out if the key does not exist Save the file: Save to the same file name in the same comma-separated format (do not worry about the order of entries), make sure to close the file Print the current dictionary: show value entries of the current dictionary on the screen (in alphabetical order of the keys). End the program. If the dictionary has been modified since the last save, then prompt the user whether it should be saved before quitting.

In: Computer Science

C++ mainDisplay.cpp Write the function displayAt that receives the two STL lists; vList and pList. The...

C++ mainDisplay.cpp

Write the function displayAt that receives the two STL lists; vList and pList. The function should display the elements in vList that are in positions specified by pList. For example, if pList has the elements (2, 5, 6, 8) then the elements in positions 2, 5, 6, and 8 in vList are displayed. Use only the public STL container operations.

In: Computer Science

Assignment Extend the Game of Life assignment to load its configuration from a file. Functional Requirements...

Assignment

Extend the Game of Life assignment to load its configuration from a file.

Functional Requirements

  1. MUST load the initial state from text file
  2. MUST load the number of rounds to play from text file
  3. COULD load the grid size from the file

CODE I HAVE:

#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include "life.h"

int main(int argc, char *argv[]) {

int board[XSIZE][YSIZE];

int rounds = DEFAULTROUNDS;

initBoard(board);

board[5][5] = ALIVE;

board[5][6] = ALIVE;

board[5][7] = ALIVE;

board[6][6] = ALIVE;

printf("Playing %d rounds.\n\n", rounds);

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

printf("Round: %d\n", i + 1);

printBoard(board);

playRound(board);

sleep(1);

}

return 0;

}

void initBoard(int vBoard[][YSIZE]) {

/* write this functions */

for (int i = 0; i < XSIZE; i++)

for (int j = 0; j < YSIZE; j++)

//Sets it to dead values on the board

vBoard[i][j] = DEAD;

}

void playRound(int vBoard[][YSIZE]) {

int tmpBoard[XSIZE][YSIZE];

initBoard(tmpBoard);

// perform the algorithm on vBoard, but update tmpBoard

// with the new state

for (int x = 0; x < XSIZE; x++) {

for (int y = 0; y < YSIZE; y++) {

int numNeighbors = neighbors(vBoard, x, y);

// If a cell is alive

if (vBoard[x][y] == ALIVE) {

//If it has less than two living neighbors, it dies.

if (numNeighbors < 2)

//SETS TO DEAD

tmpBoard[x][y] = DEAD;

//Else if it has two or three living neighbors, it lives and continues to the next generation

else if (numNeighbors <= 3)

//SETS TO ALIVE

tmpBoard[x][y] = ALIVE;

//Else if it has more than three living neighbors, it dies becuase of overpopulation

else

//SETS TO DEAD

tmpBoard[x][y] = DEAD;

}

//Else if a cell is dead

else {

// if it has exactly three living neighbors, it becomes alive due to reproduction.

if (numNeighbors == 3)

//Sets to ALIVE

tmpBoard[x][y] = ALIVE;

}

}

}

// copy tmpBoard over vBoard

for (int x = 0; x < XSIZE; x++) {

for (int y = 0; y < YSIZE; y++) {

vBoard[x][y] = tmpBoard[x][y];

}

}

}

int onBoard(int x, int y) {

if (x < 0 || x >= XSIZE)

return 0;

else if (y < 0 || y >= YSIZE)

return 0;

else

return 1;

}

int neighbors(int vBoard[][YSIZE], int x, int y) {

int n = 0;

int xp1 = x + 1;

int xm1 = x - 1;

int yp1 = y + 1;

int ym1 = y - 1;

if (onBoard(xm1, y) && vBoard[xm1][y] == ALIVE)

n++;

if (onBoard(xm1, yp1) && vBoard[xm1][yp1] == ALIVE)

n++;

if (onBoard(x, yp1) && vBoard[x][yp1] == ALIVE)

n++;

if (onBoard(xp1, yp1) && vBoard[xp1][yp1] == ALIVE)

n++;

if (onBoard(xp1, y) && vBoard[xp1][y] == ALIVE)

n++;

if (onBoard(xp1, ym1) && vBoard[xp1][ym1] == ALIVE)

n++;

if (onBoard(x, ym1) && vBoard[x][ym1] == ALIVE)

n++;

if (onBoard(xm1, ym1) && vBoard[xm1][ym1] == ALIVE)

n++;

return n;

}

void printBoard(int vBoard[XSIZE][YSIZE]) {

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

for (int j = 0; j < YSIZE; j++) {

//prints dead characters as - and alive chracters as O

printf("%c ", vBoard[i][j] ? 'O' : '-');

}

//prints space to keep rounds seperate

printf("\n");

}

}

In: Computer Science

C++ Using your completed LinkedList template class, developed in homework and lab, write a program that...

C++

Using your completed LinkedList template class, developed in homework and lab, write a program that implements and properly tests the following functions (these functions are not member functions of the class, you will write these function in mainTest.cpp )

1. Function compare that receives two LinkedList objects and compares the data in the nodes of the two lists to check if they are the same. The lists are equal only if they have the same number of nodes and corresponding nodes contain the same data. The function returns true or false to main.

2. Function mergeLists that receives two LinkedList objects. The function merges the sorted lists into a new list then returns the new list object back to main. Display the returned list.

Linkedlist.h link: https://pastebin.com/L4UUT3V8

In: Computer Science

The following program uses Pthreads to create two threads. They do some work for the process...

The following program uses Pthreads to create two threads. They do some work for the process and then exit. The process then outputs a result.

Assume all supporting libraries and other functions have been included.

=> Use the answer text field to describe what work (operations) the threads are doing, and what kind of result (what is it?) is output by the process.

#include <pthread.h>

#include <stdio.h>

#include <stdlib.h>

int res1, res2, a[100], b[100];

void *runner1(void *param);

void *runner2(void *param);

void readData(int []);


int main(int argc, char *argv[])

{

  pthread_t tid1, tid2;

  pthread_attr_t attr;


  readData(a);

  readData(b);

  pthread_attr_init(&attr);

  pthread_create(&tid1, &attr, runner1, argv[1]);

  pthread_create(&tid2, &attr, runner2, argv[1]);

  pthread_join(tid1,NULL);

  pthread_join(tid2,NULL);

  printf("result = %d\n", res1+res2);

}

void *runner1(void *param)

{

  int i, upper = atoi(param);

  res1 = 0;

  for (i = 0; i < upper; i++)

    res1 += a[i];

  pthread_exit(0);

}

void *runner2(void *param)

{

  int i, upper = atoi(param);

  res2 = 0;

  for (i = 0; i < upper; i++)

    res2 += b[i];

  pthread_exit(0);

}

In: Computer Science

Can you compare 2 search engines based on information retrieval models like Probability model or boolean...

Can you compare 2 search engines based on information retrieval models like Probability model or boolean model?

In: Computer Science

How do I make an HTML JSON button that when clicked will say Hello World!

How do I make an HTML JSON button that when clicked will say Hello World!

In: Computer Science

The following program uses Pthreads to create two threads. They do some work for the process...

The following program uses Pthreads to create two threads. They do some work for the process and then exit. The process then outputs a result.

Assume all supporting libraries and other functions have been included.

=> Use the answer text field to describe what work (operations) the threads are doing, and what kind of result (what is it?) is output by the process.

#include <pthread.h>

#include <stdio.h>

#include <stdlib.h>

int res1, res2, a[100], b[100];

void *runner1(void *param);

void *runner2(void *param);

void readData(int []);


int main(int argc, char *argv[])

{

  pthread_t tid1, tid2;

  pthread_attr_t attr;


  readData(a);

  readData(b);

  pthread_attr_init(&attr);

  pthread_create(&tid1, &attr, runner1, argv[1]);

  pthread_create(&tid2, &attr, runner2, argv[1]);

  pthread_join(tid1,NULL);

  pthread_join(tid2,NULL);

  printf("result = %d\n", res1+res2);

}

void *runner1(void *param)

{

  int i, upper = atoi(param);

  res1 = 0;

  for (i = 0; i < upper; i++)

    res1 += a[i];

  pthread_exit(0);

}

void *runner2(void *param)

{

  int i, upper = atoi(param);

  res2 = 0;

  for (i = 0; i < upper; i++)

    res2 += b[i];

  pthread_exit(0);

}

HTML EditorKeyboard Shortcuts

In: Computer Science

Q: Mention all five elements that Web 2.0 site must contain. Avoid Plagiarism (copying) please.

Q: Mention all five elements that Web 2.0 site must contain.

Avoid Plagiarism (copying) please.

In: Computer Science

1.If variable Test(i,j) is selected so the first column represents the student number (1,2,..., 32), 2nd...

1.If variable Test(i,j) is selected so the first column represents the student number (1,2,..., 32), 2nd column represents the score of the first homework, 3rd column represents the score of the 2nd homework, etc. If there is a total of 5 homework for this class, what is the size of variable Test ? Explain why, Does (i,i) is the same as rows x columns?

(6,32)

(32,6)

2.If the size of b is shown on the workspace menu for MATLAB as 4x4, what type of variable b is? Explain why

2D matrix

4D matrix

3. If you want to multiply 8 by the result of adding 12 to 5, which command would you use in MATLAB? Explain why

[5+12]*8

(8+12)*5

4. If the following commands are executed in MATLAB
a = [1:5;logspace(2,8,5)]  
How many rows are in a?

2

3

8

5

In: Computer Science

Q: Explain the Use of ASP.NET in Web Layer. Avoid Plagiarism (copying) please.

Q: Explain the Use of ASP.NET in Web Layer.

Avoid Plagiarism (copying) please.

In: Computer Science

Write a program including  binary-search and merge-sort in Python. it has to output the following: NeArr range(0,...

Write a program including  binary-search and merge-sort in Python.

it has to output the following:

NeArr range(0, 20)                                                                                                          

result for searching 6 True                                                                                                 

result for searching 16 False  

                                                                                                                          

for-loop's function                                                                                                         

arr range(0, 15)                                                                                                            

for-loop's func result for searching 6 1                                                                                    

result for searching 16 0

it has to be a simple code and please!! put the whole code together.

In: Computer Science

do we expect to get a quick response after posting videos and pictures? Stuart feldman said...

do we expect to get a quick response after posting videos and pictures? Stuart feldman said that our expectations for the systems we use have shifted, like demanding faster communication. are we disappointed when we donot get an immediate feedback

In: Computer Science

java Given a sequence of integers as an array, determine whether it is possible to obtain...

java

Given a sequence of integers as an array, determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the array. Here are the constraints. 1. You must use only arrays. 2. You are not allowed to make copies of the array (use only the one that is passed). 3. Your algorithm running time must be at most O(n 2 ). i.e. You can have only one loop within another. Ideally, you should be able to find a linear running time algorithm. i.e. you can even solve this problem using a single loop. Note: Sequence a0, a1, . . . an is considered to be a strictly increasing if a0 < a1 < . . . < an. Sequence containing only one element is also considered to be strictly increasing. Assuming your method is almostIncreasingSequence, following main method could be used to test your code.

public static void main(String[] args) { int[] a1 = {1, 3, 2, 1}; // false int[] a2 = {1, 3, 2}; // true int[] a3 = {1, 2, 1, 2}; // false int[] a4 = {3, 6, 5, 8, 10, 20, 15}; // false int[] a5 = {1, 1, 2, 3, 4, 4}; // false int[] a6 = {1, 4, 10, 4, 2}; // false int[] a7 = {10, 1, 2, 3, 4, 5}; // true int[] a8 = {1, 1, 1, 2, 3}; // false int[] a9 = {0, -2, 5, 6}; // true int[] a10 = {1, 2, 3, 4, 5, 3, 5, 6}; // false int[] a11 = {40, 50, 60, 10, 20, 30}; // false int[] a12 = {1, 1}; // true int[] a13 = {1, 2, 5, 3, 5}; // true int[] a14 = {1, 2, 5, 5, 5}; // false int[] a15 = {10, 1, 2, 3, 4, 5, 6, 1}; // false int[] a16 = {1, 2, 3, 4, 3, 6}; // true int[] a17 = {1, 2, 3, 4, 99, 5, 6}; // true int[] a18 = {123, -17, -5, 1, 2, 3, 12, 43, 45}; // true int[] a19 = {3, 5, 67, 98, 3}; // true int[] a20 = {1, 1, 1}; // false System.out.println(Arrays.toString(a1) + ": " + (almostIncreasingSequence(a1) == false)); System.out.println(Arrays.toString(a2) + ": " + (almostIncreasingSequence(a2) == true)); System.out.println(Arrays.toString(a3) + ": " + (almostIncreasingSequence(a3) == false)); System.out.println(Arrays.toString(a4) + ": " + (almostIncreasingSequence(a4) == false)); System.out.println(Arrays.toString(a5) + ": " + (almostIncreasingSequence(a5) == false)); System.out.println(Arrays.toString(a6) + ": " + (almostIncreasingSequence(a6) == false)); System.out.println(Arrays.toString(a7) + ": " + (almostIncreasingSequence(a7) == true)); System.out.println(Arrays.toString(a8) + ": " + (almostIncreasingSequence(a8) == false)); System.out.println(Arrays.toString(a9) + ": " + (almostIncreasingSequence(a9) == true)); System.out.println(Arrays.toString(a10) + ": " + 2 (almostIncreasingSequence(a10) == false)); System.out.println(Arrays.toString(a11) + ": " + (almostIncreasingSequence(a11) == false)); System.out.println(Arrays.toString(a12) + ": " + (almostIncreasingSequence(a12) == true)); System.out.println(Arrays.toString(a13) + ": " + (almostIncreasingSequence(a13) == true)); System.out.println(Arrays.toString(a14) + ": " + (almostIncreasingSequence(a14) == false)); System.out.println(Arrays.toString(a15) + ": " + (almostIncreasingSequence(a15) == false)); System.out.println(Arrays.toString(a16) + ": " + (almostIncreasingSequence(a16) == true)); System.out.println(Arrays.toString(a17) + ": " + (almostIncreasingSequence(a17) == true)); System.out.println(Arrays.toString(a18) + ": " + (almostIncreasingSequence(a18) == true)); System.out.println(Arrays.toString(a19) + ": " + (almostIncreasingSequence(a19) == true)); System.out.println(Arrays.toString(a20) + ": " + (almostIncreasingSequence(a20) == false)); }

Output should be the following (Please carefully look at why it prints all true before asking questions). [1, 3, 2, 1]: true [1, 3, 2]: true [1, 2, 1, 2]: true [3, 6, 5, 8, 10, 20, 15]: true [1, 1, 2, 3, 4, 4]: true [1, 4, 10, 4, 2]: true [10, 1, 2, 3, 4, 5]: true [1, 1, 1, 2, 3]: true [0, -2, 5, 6]: true [1, 2, 3, 4, 5, 3, 5, 6]: true [40, 50, 60, 10, 20, 30]: true [1, 1]: true [1, 2, 5, 3, 5]: true [1, 2, 5, 5, 5]: true [10, 1, 2, 3, 4, 5, 6, 1]: true [1, 2, 3, 4, 3, 6]: true [1, 2, 3, 4, 99, 5, 6]: true [123, -17, -5, 1, 2, 3, 12, 43, 45]: true [3, 5, 67, 98, 3]: true [1, 1, 1]: true

In: Computer Science