In: Computer Science
I) Calculate the 8-bit 2's complement for -113. *
a)0111 0001
b)1000 1110
c)1000 1111
d)1000 0001
II) Select the correct expanded form for the binary number 11010.
III) What is the value of the digit A in the following hexadecimal number: 3A2
a)10
b)100
c)16
d)160
IV) What is the decimal representation for the integer with two’s complement 1011 1001? You must show work
In: Computer Science
IN JAVA!!!
This is called the Josephus problem. Josephus.mp4Play media comment.
Use words.txt as input.
Use the Node class and the Circular Queue class you created in L5b.
In your main program input the words from words.txt into a Queue (a circular queue) - do this by using enqueue .
Then input an integer (n). Then starting at the head of the queue delete every nth node until only one node remains. Output the String in that last node.
Make NO changes to the Node class. In the Queue class you will need a method to delete every nth node.
You will need to print your queue, so make a print method in your Queue class. This should print the ENTIRE queue, not just the head. It is true that at the end only the head should remain, but by printing the entire queue and finding there is only one node printed you are verifying to me (and to yourself) that only the head remains.
When I ran my program these are the answers I got:
n=5 : hostelry
n=29: cliquish
n=7: alienist
SUGGESTION: Try this on a smaller input file first. This one contains just the numbers 1-20 Ex.txt
You can try this by hand, and then verify that your program is correct. For n=5, the answer is "20"
NODE CLASS
class Node<T> {
//Node makes item, next, and prev all private
//and therefore has to provide accessors
//and mutators (gets and sets)
private T item;
private Node next;
private Node prev;
Node(T newItem) {
item = newItem;
next = null;
prev = null;
}
Node(T newItem, Node nextNode, Node prevNode) {
item = newItem;
next = nextNode;
prev = prevNode;
}
/**
* @return the item
*/
public T getItem() {
return item;
}
/**
* @param item the item to set
*/
public void setItem(T item) {
this.item = item;
}
/**
* @return the next
*/
public Node getNext() {
return next;
}
/**
* @param next the next to set
*/
public void setNext(Node next) {
this.next = next;
}
/**
* @return the prev
*/
public Node getPrev() {
return prev;
}
/**
* @param prev the prev to set
*/
public void setPrev(Node prev) {
this.prev = prev;
}
}
QUEUE CLASS
class Queue<T> {
private Node head, tail = null;
int size = 0;
public Queue() {
head = tail = null;
size = 0;
}
//enqueue
public void enqueue(T item) {
Node temp = new Node(item);
if (head == null) {
head = temp;
tail = temp;
} else {
temp.next = head;
tail.next = temp;
tail = temp;
}
size++;
}
//dequeue
public T dequeue(T item) {
Node temp = head;
head = head.next;
tail.next = head;
size--;
return (T) temp.item;
}
//size
public int size() {
if (size == 0) {
}
return size;
}
//peek
public T peek() {
return (T) head.item;
//return item
}
//isEmpty
public boolean isEmpty() {
return (size == 0);
}
//print in queue class
public void print() {
if(head != null) {
Node curr = head;
System.out.println(curr.item);
curr = curr.next;
while (curr != head) {
System.out.println(curr.item);
curr = curr.next;
}
}
}
//Deletes every nth node until only one node remains
public void delete(int num, Queue q) {
Node head = q.head;
Node tail = q.tail;
int count;
Node temp = tail;
int length = q.size;
while((head != tail) && length > 1){
count = 1;
while(count != num){
temp = temp.next;
count++;
}
System.out.println("Deleting " + temp.next.item);
temp.next = temp.next.next;
length--;
}
q.head = temp;
q.tail = temp;
q.size = length;
}
}
In: Computer Science
How would Hyper-V be installed on a Windows Server Core installation?
In: Computer Science
In: Computer Science
Which of the following is not a source of switching costs?
Question 3 options:
Financial Commitment. |
|
Learning Costs. |
|
Loyalty Programs. |
|
Lack of Contractual Commitments. |
2,
Agile Development""
Question 2 options:
Tends to take too much time to implement, and is typically considered inflexible. |
|
A relatively linear, and sequential approach to software development. |
|
Seeks to enable more frequent product roll outs, and constant improvement across smaller components of a large project. |
|
Frequently considered the "classic" method of software development. |
3,
Which of the following is not an attribute of "Infrastructure as a Service" ("IaaS")?
Question 5 options:
It offers an organization an alternative to buying its own physical hardware. |
|
It offers an organization the opportunity to pay solely for the resources that it consumes. |
|
It typically requires the least amount of support and maintenance. |
|
It offers an organization the least opportunity for customization. |
In: Computer Science
1. Remove left recursions if any
A -> Aab | abA | ab B -> bb | Bb | bB
In: Computer Science
Prove the following problems.
1 .Use the definition of big O to explain why or why not 3/(x2 + 3x) = O(3). Prove your answer.
2 .Use the definition of Θ to explain why or why not sqrt(2 + sqrt(3x)) = Θ(x1/4). Prove your answer.
3 .Explain why 5x2 = Θ(2x2) is true and 5x2 ~ 2x2 is not true.
In: Computer Science
Create a new project to build a Binary search tree, and do the following:
Create a TreeNode class,
Add the methods "Insert" to insert new nodes to the tree.
Add the method "inorder". Make the method to return a list of the node elements in inorder.
Implement the equals method in the BST. Two BST are equal if they contain the same elements.
In the main insert the elements of the tree, call the max method and print the max element, and Print the tree in "inorder" format.
Enter the following tree :
BinaryTree Test your program in case you have two identical trees and another time when you have different trees.
Java Please!
In: Computer Science
Question 1: What third-party modules does this project use? What are they? What are their versions? How did you find that information?
Question 2: Who are the contributors for socket.io module? List their names and email addresses.
Question 3: What do you need to do if the event name ‘chat message’ is changed to ‘trump’ in index.html file so that the application doesn’t break?
var socket = io();
$('form').submit(function(){
socket.emit('trump', $('#m').val());
$('#m').val('');
return false;
});
socket.on('trump', function(msg){
$('#messages').append($('<li>').text(msg));
});
index.js:
var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); app.get('/', function(req, res){ res.sendFile(__dirname + '/index.html'); }); io.on('connection', function(socket){ socket.on('chat message', function(msg){ io.emit('chat message', msg); }); }); http.listen(3000, function(){ console.log('listening on *:3000'); });
In: Computer Science
When multiple thread access the setLower and setUpper methods of the NumberRange object, the isValid method return false. Explain why?
public class NumberRange {
private final AtomicInteger lower = new AtomicInteger(0);
private final AtomicInteger upper = new AtomicInteger(0);
public void setLower(int i) {
if(i>lower upper.get()) throw new IllegalArgumentException();
lower.set(i);
}
public void setUpper(int i) {
if (i < lower.get()) throw new IllegalArgumentException();
upper.set(i);
}
public boolean isValid() {
return (lower.get() <= upper.get());
}
}
In: Computer Science
Directions:
Using a vector of integers that you define.
Write a C++ program to run a menu driven program with the following choices:
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Make sure your program conforms to the following requirements:
1. Write a function called getValidAge that allows a user to enter in an integer and loops until a valid number that is >= 0 and < 120 is entered. It returns the valid age.
2. Write a function called displayAges that takes in a vector of integers as a parameter and displays the ages in the format in the sample run below.
3. Write a function called AddAge that takes in a vector of integers by reference as a parameter, asks the user to input a valid age, and adds it to the vector of integers .
4. Write a function called getAverageAge that takes in a vector of integers as a parameter, computes, and returns the average age.
5. Write a function called getYoungestAge that takes in a vector of integers as a parameter, computes, and returns the youngest age.
6. Write a function called getNumStudentsVote that takes in a vector of integers as a parameter, computes, and returns the number of ages in the vector that are >= 18. (15 points).
7. Write a function called RemoveStudentsLessThanSelectedAge that takes in a vector of integers as a parameter, asks the user for an age, creates a new vector of integers that only contains the ages in the parameter vector which are >= the age selected by the user and returns the new vector.
8. Add comments wherever necessary.
NOTE: You must take care of the case when the vector is empty and an operation is being performed on it. In such cases the program should display a 0 for the given result.
Sample Runs:
NOTE: not all possible runs are shown below.
Welcome to the students age in class program!
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..1
Student ages:
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..3
Average age = 0
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..4
Youngest age = 0
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..5
Number of students who can vote = 0
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..6
Please enter in the age...
5
Students removed
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..2
Please enter in the age...
4
Age added
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..2
Please enter in the age...
24
Age added
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..2
Please enter in the age...
18
Age added
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..2
Please enter in the age...
12
Age added
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..1
Student ages:
4 24 18 12
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..3
Average age = 14
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..4
Youngest age = 4
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..5
Number of students who can vote = 2
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..6
Please enter in the age...
15
Students removed
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..1
Student ages:
24 18
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..3
Average age = 21
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..4
Youngest age = 18
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..5
Number of students who can vote = 2
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..-8
Select an option (1..7)..8
Select an option (1..7)..1
Student ages:
24 18
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..2
Please enter in the age...
-8
Please enter in a valid age (1-120) ...
130
Please enter in a valid age (1-120) ...
55
Age added
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..1
Student ages:
24 18 55
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..7
Process finished with exit code 0
General Requirements:
1. Please make sure that you're conforming to specifications (program name, print statements, expected inputs and outputs etc.). Not doing so will result in a loss of points. This is especially important for prompts.
2. If we have listed a specification and allocated point for it, you will lose points if that particular item is missing from your code, even if it is trivial.
3. No global variables (variables outside of main() ) unless they are constants.
4. All input and output must be done with streams, using the library iostream
5. You may only use the iostream, iomanip, and vector libraries. Including unnecessary libraries will result in a loss of points.
6. NO C style printing is permitted. (Aka, don't use printf). Use cout if you need to print to the screen.
7. When you write source code, it should be readable and well-documented (comments).
In: Computer Science
Design the topic and write a 500-word abstract on the Spark technology. Define the technology and explain why it is indeed disruptive Show your understanding on its importance in industry. Site industry examples of use. Understand how and where it can be used in relation to Enterprise Computing. Why is it important? Site at least 5 references to show your research and use proper grammar and writing discipline. Note: Paper must include all 5 discussion points in content for grading. 50 points. Please use the APA Format Template below for all of your papers. mainframe
In: Computer Science
I am doing a paper in which I have to find the following information:
two web design theories. an example given is Gestalt
two web best practices, an example given is CSS
two technologies, an example given is HTML5
Are there any others? I am kind of lost here. I have no idea what theories, practices or technologies there are out there. Can someone give me a run down of several?
In: Computer Science
Recall the linear search algorithm:
procedure linear search (x: integer, a1, a2, ..., an: distinct integers)
i := 1
while (i ≤ n and x 6= ai) i := i + 1 if i ≤ n then location:= i else location:= 0 return location
Apply the linear search algorithm to search for the number 3 in the list 1, 5, 3, 9.
(a) In this application of the algorithm, what is the integer n?
(b) What is the initial value of i?
(c) How many iterations of the while loop occur when applied to this list?
(d) What is the value of i after the while loop finishes its iterations?
(e) What does the algorithm return?
In: Computer Science