12 Answered Questions for the topic algorithms


Work out the O() running time for the following recursive function. Show all your working.

void sort(int vals[], int n) { if (n == 1) return; sort(vals, n-1); // sort first n-1 values // now insert vals[n-1] into correct position in vals[] int temp = vals[n-1]; int i = n-1; while... more

Write a static method histogram() that takes an array a[ ] of int values...........

Write a static method histogram() that takes an array a[ ] of int values and an integer M as arguments and returns an array of length M whose ith entry is the number of times the integer i appeared... more

Time efficient algorithm.

Write a time efficient algorithm to find the ith maximum and ith minimum number from thereverse sorted array.

Find the total number of comparisons:

Find out total number of comparisons made in the execution of the loop for any n > 0 in termof CEILING or FLOOR function.int j, n;j = 1;while (j <n) j = j*2;I'm not able to understand... more
Algorithms Math Computer Science


Searching for and removing a low priority item in an array

Suppose you are handed a list of n events, each carrying some priority value represented by a real number in the interval [0,1], where a larger priority corresponds to a more important event. This... more


Looking for a tutor! I am self-taught in Node, Express, Python and SQL

Hey there!My name is James, and I started teaching myself html and css about 5 years ago, then jumped into javascript.I am hoping to change direction and focus on python and sql, more along the... more


Can x^4 be an upper bound for x^7 for a given constant, k ?

If k can be a constant so that: k•(x4) ≤ x7It would have to be for all n values (n being real values greater than zero)

Selection Sort - Java

Write a Java program to implement the selection sort algorithm in Java, input the following array and display the sorted on the screen. Write a function selectionsort(Arr,N), which sort the array... more

LinkedList Java

Imagine we have to create a Linked list with 5,8 as elements and at first before adding them head should pointed to null. And since 8 is the last element, next of 8 also should point to a null.How... more
Algorithms It Coding Pseudocode


Write pseudocode that prompts (input) the capacity, in gallons, of an automobile fuel tank and the miles per gallon the automobile can be driven

The program outputs the number of miles the automobile can be driven without refueling.

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.