Programming & Computer Science Answers

C++ 9913
Python 5288
Java | JSP | JSF 3611
C 1680
C# 1362
Computer Networks 989
Algorithms 652
Databases | SQL | Oracle | MS Access 641
HTML/JavaScript Web Application 588
Other 537
Visual Basic 358
Assembler 209
Software Engineering 202
AJAX | JavaScript | HTML | PHP 166
MatLAB 150
MatLAB | Mathematica | MathCAD | Maple 124
Action Script | Flash | Flex | ColdFusion 112
UNIX/Linux Programming 89
Web Development 73
Excel 36
ASP | ASP.NET 23
Delphi | Pascal 21
Perl 16
Prolog 9
Functional Programming 9
MathCAD 5
Wolfram Mathematica 4
WPF 4
Ruby | Ruby on Rails 3
NodeJS Web Application 2

Questions answered by Experts: 26 876

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

A clan of people eat their dinners from a large pan that can hold K servings of food. When a

hungry person wants to eat, s/he helps himself from the pan with one serving, unless it is empty.

if the pan is empty, the person wakes up the cook and then waits until the cook has refilled the pan.

A hungry person thread executes the following unsynchronized code:


while (true) {

getServingFromPan();

eat();

}


Thus as shown above, a hungry person p will invoke this getServingFromPan() as long as he is

hungry and there is food in the pan. In a single invocation of getServingFromPan(), the p will get

one serving.

The single cook thread runs the following unsynchronzied code:


while (true) {

putServingsInPan(K);

}


The synchronization constraints are:

• Persons cannot invoke getServingFromPan if the pan is empty.

• The cook can invoke putServingsInPan only if the pan is empty.


Fare per Kilometer

Given total fare

fare and distance travelled in kilometers distance for a rental bike, write a JS constructor function with a method to calculate the fare per kilometer.

Quick Tip

The formula to calculate the fare per kilometer is,

fare per kilometer = fare / distance

Input

The first line of input contains a number

fare The second line of input contains a number distanceOutput

The output should be a single line containing the fare per kilometer


  1. Write a custom sorting method that rearranges a List of LivingSpace objects so that all the properties that do not have an assigned address are moved to the front of the list, in order of descending number of bedrooms. All properties with an address may be left unsorted at the end of the list.
  2. An insertion sort is probably the best-suited algorithm for this task. Do not implement a selection or merge sort algorithm. Java's built-in sorting methods use a highly-optimized merge sort, so there is rarely a good reason to write your own version. Selection sort is rarely useful when speed is the primary concern Your solution should have a method header that looks like: public static void customSort(List properties);
  3. In your main method, give an example where the sorting algorithm you created in step 1 is faster than a solution using Collections#sort(List, Comparator), and an example where it is slower

Update Pickup Point

Given a previous pickup point in the prefilled code, and updated pickup point

area, city as inputs, write a JS factory function with a method to update the pickup point.Input

  • The first line of input contains a string area
  • The second line of input contains a string city

Output

  • The output should be a single line containing the updated pickup point area and city separated by a space

Write a C++ program in which, read a c-string from user. Now your task is to find either the entered string is a palindrome or sub-palindrome

Consider a system consisting of n processes/threads and k identical resources where k<n. Each

thread of which has a unique priority number. Each thread request for a single resource at a time. If

the resource is available then it is immediately allocated. If the resource is not available then the

thread is made to wait. Thus in the course of time, multiple threads may wait to access the resource.

Once the resource is available, the resource is given to the waiting thread with the highest priority.

Develop a monitor that achieves this. Specifically, the monitor should the following methods:


void request-resource(int thr_priority); // Here thr_priority is the priority of the invoking thread

void release-resource();


Given a matrix of order M*N and a value K, write a program to rotate each ring of the matrix clockwise by K elements. If in any ring has less than or equal to K elements, then don’t rotate that ring.

Sample Input 1

4 4

1 2 3 4

5 6 7 8

7 8 9 10

11 12 13 14

3

Sample Output 1

13 9 5 1

14 7 11 2

15 6 10 3

16 12 8 4


Update Pickup Point

Given a previous pickup point in the prefilled code, and updated pickup point

area, city as inputs, write a JS factory function with a method to update the pickup point.Input

  • The first line of input contains a string area
  • The second line of input contains a string city

Output

  • The output should be a single line containing the updated pickup point area and city separated by a space

Remove Words Given a string, write a program to remove all the words with K length. Input The first line of the input will contain a string A. The second line of the input will contain an integer K. Output The output should contain a string after removing all the words whose length is equal to K. Explanation For example, string A is "Tea is good for you", k is 3 then output should be "is good." Here words "Tea", "for", "you" length is equal to 3, so these words are removed from string.


Explain why PCI performs better than EISA and VL-Bus


LATEST TUTORIALS
APPROVED BY CLIENTS