JavaScript
Write a function named "reverse_kvs" that has a key-value store as a parameter and returns a new key-value store. Your function should add each key-value pair in the parameter to the new key-value store EXCEPT reversing the key and value. For example, if the key-value "extreme":45 were in the parameter then the returned key-value store should contain the key-value pair 45:"extreme".
Code:
function reverse_kvs(store) {
var reverse_store = {};
for (var key in store) {
if (store.hasOwnProperty(key)) {
reverse_store[store[key]] = key;
}
}
return reverse_store;
}
I need to have this code return an output other than an empty result. Does anyone know how to fix the code?
*** UPDATE: The code is not correct. It returns an empty result, such as this "{}"***
In: Computer Science
Write in Java
Postfix notation is a way of writing expressions without using parentheses. For example, the expression (1 + 2) * 3 would be written as 1 2 + 3 *. A postfix expression is evaluated using a stack. Scan a postfix expression from left to right. A variable or constant is pushed into the stack. When an operator is encountered, apply the operator with the top two operands in the stack and replace the two operands with the result.. Write a program to evaluate postfix expressions. Pass the expression as a command-line argument in one string.
Command line argument:
“1 2 + 3 *”
Correct output (3 points):
9
In: Computer Science
Use winHex to become familiar with different the types. Follow these steps
1) Locate or create Microsoft Excel(xlsx), Microsoft Word (docx), gif , jpg, and mp3 files if you are creating a word document or an excel spreadsheet save its as a word or excel file.
2) Start WinHex
3) Open each file type in WinHex. Record the hexadecimal codes for each file in a text editor , such has Notepad or Worded. For example for the Word document , record Word Header:50 4B 03 04.
4) Save the file , and then print it to give to your instructor.
Note ) this is forensic class not operation Management class bcoz chegg doesn’t have an option of forensics class so i have to choose operation Management
In: Computer Science
Consider the following page reference string:
1,2,3,5,4,2,1,5,4,2,6,3,1,2,6,3,1,2,4,7,5,4,3,5
How many page faults would occur for replaement by LRU, FIFO, optimal, for
four frames? All frames are
initially empty and first unique page reference causes a page fault. Draw the frame for each page reference.
In: Computer Science
In lecture we discussed Milgram’s 1967 experiment; he picked 300 people at random in Nebraska and asked them to send a letter to a stockbroker in Boston, by way of relaying the letter through a chain of people. The rule is that every person has to know the next person they are sending the 1 letter to on a first name basis. He found that on average each letter went through the hands of 6.4 people before reaching the stockbroker. This is where the expression ”six degrees of separation” comes from. When you tell your friend Dirk about this experiment he says he is not surprised. Dirk says that often, when he tells something to a friend, a couple of days later he hears back the same information from someone else! You decide to test whether the six degrees of separation principle can also be applied to oneself. Let’s imagine that “friendships” on Facebook are a good representation of Milgram’s rule for being on first-name terms with somebody. Assume you are given access to all of the friendship links on Facebook as a graph (where nodes are accounts, and links are “friends”). Design an algorithm to determine if there is a chain of at most 7 friends (because the average number in Milgram’s experiment was 6.4) such that Dirk is friends with both the first and the last person. You may assume that the graph is undirected. For full credit your algorithm should run in time O(m + n) (where n and m are the number of nodes and edges, respectively).
Hint: MODIFY/ USE BFS please helP!
In: Computer Science
In C++
Write a function called findBestSimScore that takes a genome and a sequence and returns the highest similarity score found in the genome as a double.
Note: the term genome refers to the string that represents the complete set of genes in an organism, and sequence to refer to some substring or sub-sequence in the genome.
Your function MUST be named findBestSimScore
Your function should take two parameters in this order:
a string parameter for the genome (complete set of genes)
a string parameter for the sequence (sub-sequence of the genome)
Your function should return the highest similarity score as a double.
Your function should not print anything.
The best similarity scores is [0.0,1.0]
Our sequence is "ACT", which is a string of length 3. That means we need to compare our sequence with all the 3 character long sub-sequences (substrings) in the genome.
Examples:
|
genome sub-sequence |
sequence |
similarity score |
|
|
ATACGC |
ACT |
0.33 |
|
|
ATACGC |
ACT |
0 |
|
|
ATACGC |
ACT |
0.66 |
← findBestMatch returns 0.66, since that is the highest similarity score found |
|
ATACGC |
ACT |
0 |
In: Computer Science
In C++
Write a function called findMatchedGenome that takes three genomes and a sequence and prints the list of matched genomes
Checking these cases must be performed in the order specified
above. First check for empty genomes and sequence followed by a
check for different lengths.
Helper functions (the functions used in your
findMatchedGenome) should be written in the answer
box as well.
For example:
| Test | Result |
|---|---|
//For empty sequence
findMatchedGenome("TTC","GCC","TCT",""); |
Genomes or sequence is empty. |
In: Computer Science
1. For the following C statement, write the corresponding RISC-V assembly code. Assume that the C variables a, b, and c, have already been placed in registers x10, x11, and x12 respectively. Use a minimal number of RISC-V assembly instructions. a = b + (c − 2);
2. Write a single C statement that corresponds to the two RISC-V assembly instructions below. add e, f, g add e, h, e
3. Assume that registers x5 and x6 hold the values 0xA000000000000000 and 0x2000000000000000, respectively.
(1) What is the value of x30 for the following assembly code? add x30, x5, x6
(2) For the contents of registers x5 and x6 as specified above, what is the value of x30 for the following assembly code? sub x30, x5, x6
(3) For the contents of registers x5 and x6 as specified above, what is the value of x30 for the following assembly code? add x30, x5, x6 add x30, x30, x6
In: Computer Science
C PROGRAMMING
Identify and correct the errors in each of the following. [Note: There may be more than one
error in each piece of code.]
a)
if ( sales => 5000 )
puts( "Sales are greater than or equal to $5000" )
else
puts( "Sales are less than $5000 )
b)
int x = 1, product = 0;
while ( x <= 10 ); {
product *= x;
++x;
}
c)
While ( x <= 100 )
total =+ x;
++x;
d)
while ( y < 10 ) {
printf( "%d\n", y );
}
In: Computer Science
you are to write a program in Java, that reads in a set of descriptions of various geometric shapes, calculates the areas and circumferences of the shapes, and then prints out the list of shapes and their areas in sorted order from smallest to largest area. There are four possible shapes: Circle, Square, Rectangle, and Triangle. The last is always an equilateral triangle. The program should read from standard input and write to standard output. The program should read until the end of input is reached, i.e., there is no sentinel value to mark the end of input. There are at most 100 shapes in the input. Each line of the input contains a description of one shape and contains three or four fields separated by a single space. The first field is the name of the particular object (some String). The second field is the type of the shape (one of "Circle", "Square", "Rectangle", or "Triangle" - also a string.) The third field is the size: the radius of the circle, the size of a side of the square, the length of the rectangle, or the size of a side of the triangle. Only the rectangle has a fourth field - the height of the rectangle. The program should read in the input, compute both the area and circumference (or perimeter) of the shape, then sort the shapes by their areas, and print out the shapes in order from smallest to largest area.
Your program must: • Read from standard input and write to standard output. • Work on any size lists up to and including 100, not just the sizes in the example below. • Be efficient. • Have a base class, Shape, for a generic shape. This class must a method, getShape(String desc) which takes the description of a shape (including the name of the object) as described above and returns an appropriate Shape object, a getArea method, a getCircumference method, and a toString method. • Have four subclasses of Shape: Circle, Square, Rectangle, and Triangle.
In: Computer Science
Project title: Automated attendance system using facial recognition system
Describe in detail about this title of project
Research Depth :
- Depth of literature review
- Feasibility of the proposed project
- Implementation plan, methods and strategies
- Incorporating previous comments
In: Computer Science
USING JAVA
Consider the following methods:
StringBuilder has a method append(). If we run:
StringBuilder s = new StringBuilder();
s.append("abc");
The text in the StringBuilder is now "abc"
Character has static methods toUpperCase() and toLowerCase(), which
convert characters to upper or lower case. If we run Character x =
Character.toUpperCase('c');, x is 'C'.
Character also has a static isAlphabetic() method, which returns
true if a character is an alphabetic character, otherwise returns
false.
You will also need String's charAt() method, which returns the
character at a given index in the String. For example,
"Godzilla".charAt(1) returns 'o'.
Write an application as follows:
public static String getNonAlpha() takes a String as parameter,
builds a StringBuilder consisting of only the nonalphabetic
characters in the String, and returns a String based on the
StringBuilder (eg, sb.toString())
public static String getUpper() takes a String, builds a
StringBuilder of the upper case versions of all the alphabetic
characters in the String, and returns a String based on the
StringBuilder.
Write JUnit tests to verify that the above methods are correct
In: Computer Science
Convert the following decimal numbers to 16-bit 2’s complement binary. Display your result in hexadecimal.
a.3030
b.404
c.5050
d.-5050
e.-20000
Show work with steps
In: Computer Science
Programming languages
Explain orthogonality and its importance.
In: Computer Science
For this activity, you will use a top-down approach to create part of a specification for development of a video game. The game can be any genre or theme that you’d like, but for this exercise, you should choose a single platform (smartphones, iPads, PS4, PC, etc.).
Your “roadmap” should cover the following elements:
Cover the specifications for the software needs and requirements
of the project, presented in a top-down approach (starting with the
“big picture” and breaking down from there into the smaller
requirements). Remember that not all software needs are programming
related. For each need or requirement, propose a software solution.
You don’t have to specify the exact program you would use (for
example, you could say “word processor” instead of “Microsoft
Word”).
You may use any requirement tracking technique or tool you like in
building the requirements list. One program, platform, application,
or piece of software can meet many different needs.
In a separate section, you should describe how you will apply
prototyping techniques and analysis tools to improve the final
product. Again, this discussion should consider what, if any, tools
you will need to implement prototyping.
You can structure the specification however you think best, as long
as it maintains a top-down perspective. Suggested formats include a
flowchart style or a tiered outline.
You can refer to online resources or independent research for this
activity.
In: Computer Science