##### Problem: Given an integer k, find the two closest integers in absolute difference and the whole...

Problem: Given an integer k, find the two closest integers in absolute difference and the whole product equals k+1 or k+2. Return the two integers in any order. Write the code in java.

• You can assume the integer value will be between [1,10^9]

• You can multiple a divisor with itself.

• Description of a sample run 1:

• The input number 8 hence, k+1 is 9 and k+2 is 10

• The divisors for 9 are: 1,3,9 and for 10: 1,2,5,10

• For both cases, we have 2 divisors that multiply exactly to the values (3*3=15 and 2*5=10), we also have 1*9 and 1*10, however, this will yield the largest difference

• However, we want to pick the product with the lowest absolute value hence: 3-3=0 and 5-2=3 so our correct choice is 3,3

Sample Input:

Input: num=8

Output: [3,3]

In: Computer Science

##### a) For the following FOL knowledge base, prove Older(Lulu, Fifi) using resolution. Mother(Lulu, Fifi) Alive(Lulu) ∀x...

a) For the following FOL knowledge base, prove Older(Lulu, Fifi) using resolution.
Mother(Lulu, Fifi)
Alive(Lulu)
∀x ∀y.Mother(x,y) ⇒ Parent(x,y)
∀x ∀y.(Parent(x,y) ∧ Alive(x)) ⇒ Older(x,y)

In: Computer Science

##### What is the pipelining technique? How does this technique improve the performance of multicore processor so...

What is the pipelining technique? How does this technique improve the performance of multicore processor so that multimedia applications could run on microcomputers at high speed?

Please write, not a screenshot

In: Computer Science

##### Write a Java console application that reads a string for a date in the U.S. format...

Write a Java console application that reads a string for a date in the U.S. format MM/DD/YYYY and displays it in the European format DD.MM.YYYY  For example, if the input is 02/08/2017, your program should output 08.02.2017

In: Computer Science

##### According to Ed Leonard, the CTO at DreamWorks “Shrek 3 consumed 20 million CPU render hours...

According to Ed Leonard, the CTO at DreamWorks “Shrek 3 consumed 20 million CPU render hours with 3000+ server CPUs, with 24TB file size”.

Suppose the personal computer CPU advanced so much so that we accomplished that goal by fabricating 3000-core Processor Motherboard.   Would this new multicore machine perform as well as the parallel processing employed by DreamWorks?

Give 2 justifications to support your answer?

Please write, not a screenshot

In: Computer Science

##### Write a program that asks the user to enter the monthly costs for the following expenses...

Write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires, and maintenance. The program should then display the total monthly cost of these expenses, and the total annual cost of these expenses.

Using the following test data:
310.34
104.95
78.34
12.34
8.12
45.00

Your output should look like this:
Enter the monthly loan payment amount:

Enter the monthly cost of insurance:

Enter the monthly cost of gas:

Enter the monthly cost of oil:

Enter the monthly cost of tires:

Enter the monthly cost of maintenance:

The total monthly cost is $559.09. The total annual cost is$6709.08.

This is C++ and use visual studio 2017 please.

Use blank lines to separate the major parts of your main function. And show your output.

In: Computer Science

##### Make sure it works on jsfiddle and keep the code seperate html: css: javascript: -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Make sure it works on jsfiddle

and keep the code seperate

html:

css:

javascript:

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

Assignment

You should already have some experience with jQuery and some simple experience with JSON (from charting). In this assignment we will be creating some JSON data, parsing it, and displaying it.

Step 1 – If you are not familiar with JSON you should complete the JSON tutorial at w3schools

Step 2- You will now create a JSON file to represent some data of your own making some examples of data that you could create such as A sports score database ex. players, playerName, season, and scoring. Feel free to create data on something that is of interest to you (and share on the discussion board).

Step 3 – Validate your JSON (you can use JSON Lint) jsonlint.c o m  and save it to your server as a text file.

Step 4 – In a web page, read the JSON data and display the data in a nice human readable format (table or list). This is demonstrated in the W3Schools tutorial.

Information

In: Computer Science

##### Explain (in your own words) how does JAGGIES happens in text and what is the technique...

Explain (in your own words) how does JAGGIES happens in text and what is the technique used to mitigate the JAGGIES effect? Mention an application that applies that technique.

Please write, not a screenshot

In: Computer Science

##### Create Kernel of a Strongly Connected Components using Kosaraju's Algorithm in Java. I have to create...

Create Kernel of a Strongly Connected Components using Kosaraju's Algorithm in Java.

I have to create a Kernel DAG using the Strongly Connected Components found using Kosaraju's Algorithm. The input to the code is in the format.

5 \n 5 \n 1 0 \n 0 2 \n 2 1 \n 0 3 \n 3 4

The code will find the SCCs and print them to the screen, however, I need to find a way to construct a kernel based on these SCCs, so that the output will look like the following:

[0,1,2] [3]

[3] [4]

Due to the fact that the SCCs of [0,1,2] have an edge with SCC [3] and so on.

import java.util.*;

public class Scc {

public static Scanner kbd = new Scanner (System.in);
public static int Vnum; // No. of vertices
public static int Enum;   // No. of vertices
{
System.out.println("Enter data in the following format:\n");
System.out.println("n -number of vertices \ne -number of edges");
System.out.println("a1 b1 -represents an edge \na2 b2 \na3 b3 \n.\n.\n.\nae be\n");
Vnum = kbd.nextInt(); // number of vertices.
Enum = kbd.nextInt(); // number of edges.

for(int i = 0; i < Vnum; i++)
{
ArrayList<Integer> T = new ArrayList<Integer>();
}

// loop to acquire the vertices from the user.
for(int i = 0; i < Enum; i++)
{
int tempX = kbd.nextInt();// vertex 1
int tempY = kbd.nextInt();// vertex 2
ArrayList<Integer> point = adj.get(tempX);
}

}
public static ArrayList<Integer> dfs (ArrayList<ArrayList<Integer>> adj)
{
boolean[] visit = new boolean[Vnum];
Stack<Integer> stack = new Stack<Integer>();
ArrayList<Integer> stackRev = new ArrayList<Integer>();

// set all values to false
for(int i = 0; i < Vnum; i++)
{
visit[i]=false;
}

while(true)
{
int go = notVisited(visit);
if(go != -1)
{
stack.push(go);
visit[go] = true;
while(!stack.isEmpty())
{
int top = stack.peek();
Iterator<Integer> iter = adj.get(top).iterator();

while(true)
{
if(iter.hasNext())
{
int nx = iter.next();
if(visit[nx] == false)
{
stack.push(nx);
visit[nx] = true;
break;
}
}
else
{
break;
}
}
}
}
else
{
break;
}
}

return stackRev;
}
public static ArrayList<ArrayList<Integer>> dfsPost (ArrayList<ArrayList<Integer>> adj, ArrayList<Integer> dfs)
{
ArrayList<ArrayList<Integer>> connected = new ArrayList<ArrayList<Integer>>();
boolean[] visit = new boolean[Vnum];
Stack<Integer> stack = new Stack<Integer>();
Iterator<Integer> iter1 = dfs.iterator(), iter2;
int nx1, nx2;

for(int i = 0; i < Vnum; i++)
{
visit[i]=false;
}

while(iter1.hasNext())
{
nx1 = iter1.next();
if(!visit[nx1])
{
stack.push(nx1);
visit[nx1] = true;

ArrayList<Integer> temp = new ArrayList<Integer>();

while(!stack.isEmpty())
{
int top = stack.peek();
while(true)
{
if(iter2.hasNext())
{
nx2 = iter2.next();
if(!visit[nx2])
{
stack.push(nx2);
visit[nx2] = true;
break;
}
}
else
{
stack.pop();
break;
}
}
}

}

}
return connected;

}
public static void display (ArrayList<ArrayList<Integer>> adj)
{
Iterator<ArrayList<Integer>> temp = adj.iterator();
int size = adj.size();

System.out.println("\nThe given graph has " + size + " Strongly Connected Components.");
for(int i = 0; temp.hasNext(); i++)
{

ArrayList<Integer> x = temp.next();
System.out.println("Connected Component #"+i + ":\t" + x);
}

}

public static void main(String[] args)
{

// creates the Adjacency list.
ArrayList<ArrayList<Integer>> adj = new ArrayList<ArrayList<Integer>>();

// creates the reverse Adjacency List.
ArrayList<Integer> x = dfs(revAdj);

}

In: Computer Science

##### language c++(Data structure) You have to read a file and store a data in character array...

language c++(Data structure) You have to read a file and store a data in character array ( you cant initialize a character array, you have to code generically) code must be generic u must read a file onece u cant use built in function etc string, code in classes if u initialized a char array or ur code doesn't run i will dislike and report u

you can use link list to store data

In: Computer Science

##### Prompt: This exercise uses your programming environment to enhance the Web site you created last week...

Prompt:

This exercise uses your programming environment to enhance the Web site you created last week with additional functionality to include images, tables and a Form using Python flask. Specifically, you will add two (2) additional routes allowing a user to register and login to a web site. Additional security considerations include other routes (beyond the register route) will not be accessible until a successful login has occurred.

In addition to the requirements list above the following functionality should be found within your web site on one or more web pages:

- Add at least 4 different images. The images should be local in your environment. For example, they should be saved in your environment and referenced

- A Table with at least 4 rows and 3 columns.

- A user registration form

- A user login form

- A password complexity should be enforced to include at least 12 characters in length, and include at least 1 uppercase character, 1 lowercase character, 1 number and 1 special character.

- Display date and time throughout website

---------------------BASE CODE-----------------------

routes.py

#pages
@app.route('/')
@app.route('/index.html')
def index():
return render_template('index.html', the_title='Console Wars: Xbox vs Playstation')

@app.route('/xbox.html')
def xbox():
return render_template('xbox.html', the_title='Console Wars: Xbox Specs')

@app.route('/playstation.html')
def playstation():
return render_template('playstation.html', the_title='Console Wars: Playstation Specs')

if __name__ == '__main__':
app.run(debug=True)

main.css

{
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}

body {
font-family: 'Source Sans Pro', sans-serif;
font-size: 100%;
color: #000;
background: #fafbff;
margin: 0;
}

#container {
margin: 2em auto;
width: 740px;
background: #000000;
}

h1, h2 {
font-family: 'Droid Serif', serif;
font-size: 3em;
margin: 0;
}

h2 {
font-size: 2em;
}

p, li {
font-size: 1.4em;
}

p.credit {
font-size: 0.9em;
}

img {
display: block;
margin: auto;
max-width: 100%;
}

a {
color: #1484bc;
text-decoration: none;
}

a:hover {
color: #407189;
text-decoration: underline;
}

/* media */

@media (max-width: 800px) {
body {
background: #000000;
}
#container {
margin: 0;
width: 100%;
}
}

base.html

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ the_title }}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">

<body>

<div id="container">

{% block body %}
{% endblock %}

</div>

</body>
</html>

index.html

{% extends 'base.html' %}

{% block body %}

<h1>{{ the_title }}</h1>

<!-- retrieves photos and incorporates a link -->
<img alt="Photo: playbox" src="{{ url_for('static', filename='images/playbox.jpg') }}">
<p class="credit">Photo by Microsoft/Sony/Paul Tassi [Public domain] <a href="https://www.forbes.com/sites/davidthier/2020/09/28/this-is-how-xbox-series-x-and-ps5-will-solve-their-exclusive-problem/#284c74b33358" target="_blank">via Forbes.com</a></p>

<ul>
<!-- routes to other pages -->
<li><a href="{{ url_for('xbox') }}">Xbox Specs</a></li>
<li><a href="{{ url_for('playstation') }}">Playstation Specs</a></li>
</ul>

<p>It is the year of new consoles which means the console war between Xbox and Playstation are the main topic of discussion. They have been the most prevalent consoles for over a decade now. Each console will have its loyal customers, but what side will the rest of the median consumers go to? In this website I will display key facts about each console and why they matter to you, The reader. This is so you can have an unbiased opinion between the two, and chose what console is best for you. Both consoles have their upsides and downsides when it comes to game exclusives, but that is entirely opinionated. The console hardware however, is now set in stone and can clearly be compared without any opinions and cold hard facts.</p>

<p>Since it is a new generation of consoles, much has changed. From updated hardware, game exclusives, and the economy. Consoles now have more power than ever before, and console exclusives have unfortunately became even more prevalent than before. Sony(Playstation) have had more exclusives than any other traditional console in recent memory. Xbox has certainly lagged behind Playstation in this manner, but it looks like Microsoft is ready to change. Recently Microsoft has started purchasing game development studios such as Bethesda(Zenimax), Obsidian, and many more. This is a very big deal as these studios will likely work specifically for Microsoft. These popular studios before were once neutral. At the time of writing it appears that future Fallout, and Elder Scrolls games will be Xbox exclusives. This is a massive deal as these two franchises are major sellers and will likely lead people into buying the new Xbox rather than the Playstation. Overall it looks like Xbox is ready to be an even tighter competitor to Playstation than before. </p>

{% endblock %}

playstation.html

{% extends 'base.html' %}

{% block body %}

<h1>{{ the_title }}</h1>

<img alt="Photo: Playstation Specs" src="{{ url_for('static', filename='images/pspecs.jpg') }}">
<p class="credit"> Playstation 5 Specifications[Public domain] <a href="https://i.pinimg.com/originals/72/bb/8f/72bb8f4b33381e3d40a8bc85d650d298.png">via Playstation</a></p>

<ul>
<li><a href="{{ url_for('xbox') }}">Xbox Specs</a></li>
</ul>

<p>The Playstation 5 is the next generation console from Sony. This console is in line with a royal lineage of previous consoles, that have amassed to the most sales ever sales by a console producer. The PS5 is projected to have more sales than the Series X, but why? To start it off, Playstation is very popular globally compared to Xbox with a very loyal fan base. Playstation has prided itself off of exclusive games, sleek design, and past success. They can back it up too, as the Playstation is the highest selling console of all time. Xbox has recently made efforts on catching up in the exclusive game market, while Playstation has had an ahead start for years now. If your looking for single player story games, than the PS5 could be for you. The large majority of exclusives have been just that and overall very well received and even sought out by Xbox players. </p>

<p>Having good game exclusives is very nice but how does the PS5 hardware stack up to the Xbox One? Playstation loyalists might want to look away because from reports the PS5 will not be as powerful as the Series X. It will still be able to run beautiful graphics and 120fps, just like the Xbox Series X. It will have a slower GPU which is a pretty big deal for competitive gamers, as well as smaller storage. The console still has good performance that can be compared to a low budget PC none-the-less. The performance may be worse but the design is nothing short of amazing compared to the Series X. It has a sleek futuristic design that can catch your eye. All of this will come at a price tag of $499, which is the same as the Series X. The digital edition on the other hand costs$399, which is a whopping $100 more than the Xbox counterpart. It comes down to what you value more at the end of the day; Performance, Exclusives, Appearance or Price. </p> {% endblock %} xbox.html {% extends 'base.html' %} {% block body %} <h1>{{ the_title }}</h1> <img alt="Photo: Xbox Specs" src="{{ url_for('static', filename='images/xspecs.jpg') }}"> <p class="credit"> Xbox Series X specifications[Public domain] <a href="https://i.ytimg.com/vi/ID9sjhU2RW0/maxresdefault.jpg">via Microsoft</a></p> <ul> <li><a href="{{ url_for('playstation') }}">Playstation Specs</a></li> <li><a href="{{ url_for('index') }}">Home Page</a></li> </ul> <p>The Xbox Series X is the most powerful console to date. The hardware for the Series X has more power than the Playstation 5, and even lower budget PC's. As you can see in the graph above the new Xbox can run at 8k, but even more importantly 120fps. Frames per second or FPS, is a gamers best friend. The more frames you can receive the smoother gameplay will be giving you a better experience than previous generations. It is worth noting that video output, is mainly based off the TV/Monitor you have. So if you want to run 8k, 120fps, and even Ray-Tracing you need a monitor tah can handle the Xbox Series X impressive capabilities. The other main selling point is the updated graphics card. This graphics card is a Custom AMD GPU which rivals a PC GPU. It is also one of the key differences between the new Consoles. A better GPU is important because its means faster performance, or less of a delay. The Series X wins in this regard as it is stronger than the PS5</p> <p>For some people, the design of the console is an important factor when purchasing. As you can see above it closely resembles the likes of a PC. Internet memes asides it does kind of look like a speaker and it does appear a bit bland. For most gamers this should not be an issue. It is also worth mentioning this console will have a separate edition which will include an entirely digital library. This means it will not have a disc tray, but it also means the console will be cheaper as well, which is great for people who cant afford expensive consoles or PCs. The Series X will be$499, while the Series S(Digital) will be \$299. Overall great prices for the value you are getting. It is also cheaper than the Playstation variant which is a positive. Obviously because of console exclusives you will miss out on some popular franchises and a large collection of well received single-player games.</p>

{% endblock %}

FILE DIRECTORY:

|____routes.py
|____static
| |____css
|   |____main.css
| |__images
|   |___xspecs.jpg
|   |___pspecs.jpg
|   |___playbox.jpg
|_____templates
| |___base.html
| |___index.html
| |___xbox.html
| |___playstation.html

In: Computer Science

##### Modify the following code to use ONLY pointer arithmetic (no array expressions) and no for loops...

Modify the following code to use ONLY pointer arithmetic (no array expressions) and no for loops to do the same thing this code does. Be sure that you understand how the code works and how the pointer arithmetic relates to the array expression form. Provide liberal comments to explain what your pointer arithmetic is computing.

#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{ int arg_count = 0;
for (arg_count = 0; arg_count < argc; arg_count++)
printf("%s\n", argv[arg_count]);
}

In: Computer Science

##### In python I have a linked list. I want to create one function that takes in...

In python I have a linked list. I want to create one function that takes in one parameter, head. In the function, cur = head and next_cur = head.next. I want to return head and next_cur, except at the end of the function they will return alternating values from head.

For example, if the these are the values in the linked list:

2, 3, 5, 7, 11

after the function head should return:

2, 5, 11

and next_cur should return:

3, 7

In: Computer Science

##### This assignment uses a combination of classes and arrays. Instructions: 1) download the 3 program files...

This assignment uses a combination of classes and arrays.

Instructions:

1) download the 3 program files into a new C++ project.    NOTE: if your IDE does not allow you to create projects - or you are not sure how to do it - then you may combine the two cpp files into a single file.

2) Complete the program by adding code the the class methods. You may want to study the existing code first to get a feel for how to access the class attributes. There is no need to modify any of the methods that are already implemented.

UPDATE: You are working with magic_square.cpp. View comments as ref. Thank you.

Attachments ~ (3):

magic.h ~

#ifndef MAGIC_H
#define MAGIC_H

#define SQUARE_SIZE 3
class MagicSquare {
private:

// matrix is a two-dimensional array that holds the
// magic square.
int matrix[SQUARE_SIZE][SQUARE_SIZE] = {{ 4, 9, 2 },
{ 3, 5, 7 },
{ 8, 1, 6 }};

public:

// is_magic - returns true if matrix forms a magic square.
// a magic square is one that all the rows and all the cols and
// the two diagonals add up to the same number.
bool is_magic();

// GIVEN : scramble(int loops) - switch two random elements of the matrix for form
// a new square.
void scramble(int loops=1);

// row_sum(int r) - return the sum of all the elements of row r.
int row_sum(int);

// col_sum(int c) - return the sum of all the elements of column c.
int col_sum(int);

// diagnoal_left() - return the sum of all the elements from the upper-right
// to lower-left.
int diagonal_left();

// diagnoal_right() - return the sum of all the elements from the upper-left
// to the lower-right.
int diagonal_right();

// showMatrix() - Print the values of the matrix in a square format.
// For example:
//
//    1 2 3
//    4 5 6
//    7 8 9
//
void showMatrix();

// GIVEN:  set_matrix(int * array) - create a new matrix using the values
// of the array.
void set_matrix(int *);

};

#endif



________________________________________________________________________________________________

magic_square.cpp ~

#include
#include
#include
#include
#include "magic.h"

using namespace std;
// Replace # after return as row_sum and col_sum

int MagicSquare::row_sum(int r) {
return matrix [0][0] + matrix [0][1] + matrix [0][2];
}

int MagicSquare::col_sum(int c) {
return matrix [0][0] + matrix [1][0] + matrix [2][0];
}

int MagicSquare::diagonal_left() {
return 0;
}

int MagicSquare::diagonal_right() {
return 2;
}

bool MagicSquare::is_magic() {
return false;
}

void MagicSquare::showMatrix() {

}

// Swap two random values of the matrix.
void MagicSquare::scramble(int loops=1) {

static bool _initialized = false;

if (! _initialized) {
srand((unsigned)time(0));
_initialized = true;
}
while (loops--) {
int r1 = (rand()%SQUARE_SIZE);
int c1 = (rand()%SQUARE_SIZE);
int r2 = (rand()%SQUARE_SIZE);
int c2 = (rand()%SQUARE_SIZE);
int temp = matrix[r1][c1];
matrix[r1][c1] = matrix[r2][c2];
matrix[r2][c2] = temp;
}
}

// Create a new set of values for a magic square. The user should pass in an
// array of 3 integers.
void MagicSquare::set_matrix(int *values) {

int a = values[0];
int b = values[1];
int c = values[2];

matrix[0][0] = a;
matrix[0][1] = 3 * c - a - b;
matrix[0][2] = b;

matrix[1][0] = c + b - a;
matrix[1][1] = c;
matrix[1][2] = c - b + a;

matrix[2][0] = 2 * c - b;
matrix[2][1] = a + b - c;
matrix[2][2] = 2 * c - a;

}


_________________________________________________________________________________________________________

main.cpp ~

#include
#include "magic.h"

using namespace std;
/*
*
*/

int main()
{
int times = 200000;
MagicSquare square;
int my_values[SQUARE_SIZE];

cout << "Here is array \n\n";
square.showMatrix();

if (square.is_magic())
cout << "\nIt is a magic square\n\n";
else {
cout << "Program is not working!!" << endl;
return 1;
}

while (times--) {
square.scramble();
if (square.is_magic()) {
cout << "Found one !!" << endl;
square.showMatrix();
cout << endl;
}
}

cout << "Now you try!  Enter " << SQUARE_SIZE << " values" << endl;

// Collect 3 values from the user and store them in an array called my_values

// Call the set_matrix method and pass in the my_values array.

// Display the new matrix using the showMatrix() method.

// Copy the while loop above to search for more versions of this magic square.

return 0;

} // End main function

In: Computer Science

##### 7. CIR is the actual frame relay network throughput realized at times of low usage. True...

7. CIR is the actual frame relay network throughput realized at times of low usage. True or False?

a. True

b. False

8. Which of the following factors might influence the use of a frame relay network over a T1 mesh network?

a. Number of endpoints (networks) that need to be connected

b. Types of computers being used

c. Type of router being used to connect the network

d. Physical circuit being used

9. A PAD serves what purpose on an X.25 network?

a. It assigns frames locally significant DLCIs as they traverse the network switches

b. It accepts byte streams from synchronous DTE and assembles them into X.25 packets

c. It provides an interface between the PSTN and the packet network

d. It accepts data from an asynchronous DTE and assembles that data into X.25 packets

10. Which are the X.25 virtual circuit stages? (Choose three.)

a. Call setup

b. Call cancel

c. Data transfer

d. Call clearing

In: Computer Science