Intro to Python!
1. Using while loops, write a program that prints multiples of 5 which are less than 100. Your loop initially starts from 0.
2. Consider B to be a list of alphabetically ordered strings. Using while loops, write a program that only prints words which start with letter A.
B = [Alex, Airplane, Alpha, Australia, Ben, Book, Bank, Circuit, Count, Dark]
3. Using while loop, create a program that only prints first 18 multiples of 7.Hint: Your loop initially starts from 1. You should create a counter to keep track!
In: Computer Science
Compare between functional and non-functional requirements with example for each.
Distinguish among the fundamental architectural views proposed in Krutchen’s 4+ 1 model.
In: Computer Science
Code: C++
Write a very general sort method that can sort any type of data arrays/lists. For example, can sort a list of integers in ascending order, a list of integers in descending order, a list of doubles, a list of student objects (with names and scores) in ascending order of names, or in descending order of scores, … You can use any pre-defined sort function or can code your own. Use your favorite language for implementation. If your language doesn’t support these features, implement a revised version (clearly state the revision you made to the problem with a brief discussion of the language’s weakness.) Then test the following cases:
(a) 4, 3, 7, 2, 1, 9 in ascending order
(b) 4.5, 2.0, 9.0, 8.4, 7.2, 6.1, 20.5, 2.1 in descending order
(c) John 40, Casey 45, Ben 47, Zadi 41, Kay 39, Tay 43 in ascending order of names
In: Computer Science
What types of projects would be more suited for Black-Box testing compared to White-Box testing and vice versa?
In: Computer Science
Problem 1 [50 pts]
Consider a hard disk drive that has 5 double-sided platters, each surface has 1000 tracks, each track has 256 sectors of size 512 bytes. Each block (disk page) comprises of 8 sectors. The seek time between adjacent tracks in 1ms and the average seek time between two random tracks is 25ms. The disk rotates at a speed of 7200 rpm (revolutions per minute).
Let’s say, we have a file of size 1 MB and it contains 2048
equal-sized records.
1. What is the size of a block? How many records fit in a block?
How many blocks are required to store the
entire file?
2. What is the capacity of each cylinder?
3. What is maximum time (worst case) to read two blocks from the disk (the blocks to be read are part of the same read request and no external factors affect the read latency)?
4. If the file is stored “sequentially”, how long will it take to read the whole file? Assume that for sequential writes data are written in adjacent tracks once a track is full.
5. If the blocks in the file are spread “randomly” across the disk, how long will it take to read the whole file?
In: Computer Science
Could you please write a working program "linkedlist.cpp" using recursive approach for the given files below
--------------------------------------------------------------------------------------------
// app.cpp
#include <iostream>
#include "linkedlist.h"
using namespace std;
void find(LinkedList& list, char ch)
{
if (list.find(ch))
cout << "found ";
else
cout << "did not find ";
cout << ch << endl;
}
int main()
{
LinkedList list;
list.add('x');
list.add('y');
list.add('z');
cout << list;
find(list, 'y');
list.del('y');
cout << list;
find(list, 'y');
list.del('x');
cout << list;
find(list, 'y');
list.del('z');
cout << list;
find(list, 'y');
return 0;
}
--------------------------------------------------------------------
// linkedlist.h
#ifndef _LINKED_LIST_
#define _LINKED_LIST_
#include <ostream>
class LinkedList
{
public:
LinkedList();
~LinkedList();
void add(char ch);
bool find(char ch);
bool del(char ch);
friend std::ostream& operator<<(std::ostream& out, LinkedList& list);
};
#endif // _LINKED_LIST_
In: Computer Science
(Java)Run length encoding is a simple form of data compression. It replaces long sequences of a repeated value with one occurrence of the value and a count of how many times to repeat it. This works reasonably well when there are lots of long repeats such as in black and white images. To avoid having to represent non-repeated runs with a count of 1 and the value, a special value is often used to indicate a run and everything else is just treated as a simple value. For this exercise you will decompress one line of input at at time assuming the line was compressed according to the following:
The newline characters are passed through uncompressed even when there are repeated blank lines. When a run of n>=3 repeated characters, c, is detected where c is NOT a digit, the run will be replaced with #nc. When a run of n>=3 repeated characters, c, is detected where c IS a digit, the run will be replaced with #n#c. The extra # is needed to avoid confusing the repeated digit c with the last digit of the run count. All other characters (i.e. runs of just 1 or 2 characters) are passed through unmodified. Assume the uncompressed input does not contain the symbol '#'. This assumption can be eliminated. You might think about how you would do it.
Some examples:
abc decompresses to abc
#3ab#4c decompresses to aaabcccc
abc12#14#3 decompresses to abc1233333333333333
Your decoder can assume the input was properly compressed, i.e. no need for error checking. Your program must include a public static method decompress() that takes one parameter, a String, that is the line to be decompressed. The method returns the decompressed String. Write Decoder.java to answer this question.
In: Computer Science
using c++ You have been contracted to build a hotel reservation system. This is the system that hotel desk clerks will use to take desk reservations.
Assumptions: This is acting as though the only reservations taken are at the desk. All reservations are for one night. The hotel is empty when you start the program.
First, this program will give the full inventory of rooms in the hotel.
Total rooms: 122
There are four types of rooms with these prices:
Second, the program will allow for a room to be reserved for one night. The program will keep track of the inventory as rooms are being reserved.
Third, the program will keep track of revenue brought in for the day from reserved rooms.
Fourth, the user can choose a getTotal() function that will display remaining room inventory, what was reserved and revenue generated for the day.
PLEASE NOTE: This project must incorporate a class friend or class inheritance structure.
In: Computer Science
in P2P, each peer only upload chunks to a limited number of peers? Why is the Bit torrent designed in such a way?
In: Computer Science
Give an intuitive explanation of why the maximum throughput, for small beta, is approximately the same for CSMA slotted Aloha and FCFS splitting with CSMA. Show the optimal expected number of packets transmitted after a state transmission in an Aloha is the same at the beginning of a CRP for FCFS splitting. Note that after a collision, the expected numbers are slightly different in two systems, but the difference is unimportant since collisions are rare.
In: Computer Science
1. Complete the second printSalutation() method to print the following given personName "Holly" and customSalutation "Welcome":
Welcome, Holly
End with a newline.
What I am given:
import java.util.Scanner;
public class MultipleSalutations {
public static void printSalutation(String personName) {
System.out.println("Hello, " + personName);
}
//Define void printSalutation(String personName, String customSalutation)...
/* Your solution goes here */
public static void main (String [] args) {
printSalutation("Holly", "Welcome");
printSalutation("Sanjiv");
}
}
2. Write a second convertToInches() with two double parameters, numFeet and numInches, that returns the total number of inches. Ex: convertToInches(4.0, 6.0) returns 54.0 (from 4.0 * 12 + 6.0).
What I am given:
import java.util.Scanner;
public class FunctionOverloadToInches {
public static double convertToInches(double numFeet) {
return numFeet * 12.0;
}
/* Your solution goes here */
public static void main (String [] args) {
double totInches;
totInches = convertToInches(4.0, 6.0);
System.out.println("4.0, 6.0 yields " + totInches);
totInches = convertToInches(5.8);
System.out.println("5.8 yields " + totInches);
}
}
In: Computer Science
1. Write a program that prompts the user for a filename, then reads that file in and displays the contents backwards, line by line, and character-by character on each line. You can do this with scalars, but an array is much easier to work with. If the original file is:
abcdef
ghijkl
the output will be:
lkjihg
fedcba
Need Help with this be done in only PERL. Please use "reverse"
In: Computer Science
Are the security needs of small businesses different than those of a larger corporation? Please support your answers.
In: Computer Science
the following lists the nodes in a binary tree in two different orders:
Preorder : A B C D E F G H I J K L M
Inorder : C E D F B A H J I K G M L
Draw the binary tree
In: Computer Science