As much as i've searched online, I cannot find examples of algorithms that aren't solvable in practice due to the amount of time that they'd take to compute. I was trying to think of an example such as counting the number, size, and location of each

I have to handle some data that comes in pipe delimited files, where each field is enclosed in double quotes. "Boolean"|"dada -sdf|xcvnb"|"123" If I take FS="|", then the script takes the above as four fields, where

In a project in which I'm working for, I'm required to either generate n random double numbers (depending from what the input file says) or converting them to doubles if I have them from my input file. Those numbers should have only 2 decimals after

First time posting here, so if I make a mistake with something let me know and I'd be more than happy to fix it! Given N events, each of which have an individual probability (from 0 to 100%) of occurring, I'd like to determine the probability of 0 to

4 0 2 0 1 0 3 2 3 0 3 I'm trying to find effective solution to the above problem. Given input first line is: number of nodes in binary tree=4, root=0, depths=2 Edges or nodes on the edge are not given in any specific order, but edge that connects nod

The assignment problem asks to find a set of n elements with maximal possible sum in distinct rows and columns of a given n-by-n matrix. It can be solved optimally by the Hungarian algorithm in O(n^3). However, let us consider the following suboptima

I've got this ugly bit of code that looks a bit like this ... TestResult GetFirstTestResult() { var result = TestMethod1(); if(result is EmptyResult) { result = TestMethod2(); } if(result is EmptyResult) { result = TestMethod3(); } // ... if(result i

There are two sorted continuous number array merged in to a single array. Both the arrays had distinct numbers. ex : {1, 2, 3, 4, 5, 6, 7, 8, 9} and {10, 11, 12, 13, 14} int[] resultArr = {10, 11, 12, 13, 14, 1, 2, 3, 4, 5, 6, 7, 8, 9}; ^ Algorithm t

I am writing a program to tell me all the perfect numbers between 1 and 500 and I made this program, but it doesn't work although the algorithm makes sense. import java.util.Scanner; class allPerfect { public static void main(String args[]) { int sum

I am using an equation in which we have to find the maximum value that x can take given the value of b. Both x and b can take only nonnegative integer values. The equation is: x^4+x^3+x^2+x+1≤b I have written the following code(apparently dumb) to so

I have a string with a list of words. I want to get all the keywords in the list that exists in the string. But it doesn't work with more than 1 keyword ks = ['Voices', 'Home'] def find_tag(long_string, size, result): for idx, s in enumerate(range(0,

I'm taking a course on Coursera: "Design and Analysis of Algorithms" provided by Stanford University. A text file with 10000 distinct integers is provided in random order. The task is to count the number of comparisons after performing Quick Sor

I have a string such as "A and B or not C and D". The atoms are all simple uppercase letters A,B,C... and the operators are only { and, or, not }. I would like to devise an algorithm that can add parentheses that are implied by the usual rules o

This question already has an answer here: Maximum single-sell profit 16 answers We have an array of numbers representing prices over time. For example, we have [10, 4, 6, 8, 2, 5, 3, 9, 1]. We want to know when would be the optimal time to buy and to

I have a question which data structure is the best for particular situation. we have one string "AAAAAAAAAAA", and we want to know this string contain in one data base column or not. For example below database there is two column. 1. ID 2. Name

Imaging that sequence is Pi 141592653589793238462643383279502884197.... the Pi is stored in a text file. I want to locate a similar sub-sequence in the Pi with for example 80% similarity. for example I want to locate 33384 in Pi, so 14159265358979 32

I am beginner to linked list. I have a situation that to take the size of link is taken at terminal and then read all the data to be kept in freq (In my code it is "freq" but generally called data/info), and create a linked list using them. What

I need to distribute "n" amount of images in a given container. It should optimize the space depending if the container's aspect ratio is landscape, portrait or a square. The intention is that the images are rendered the biggest size possible an

I have a list of longitudes and latitudes which forms boundary for a geographical area. I would like to generate some random co-ordinates inside this geographical area . Could you suggest some approaches I can take in any language?Like any problem, t

its known that DFS time complexity is O(|V|+|E|) . Suppose each vertex v has a positive weight w(v). I want to change the DFS algorithm such that when we have "exertion" of which vertex we need to add to the empty stack-we will add the most weig

Let T be a tree in which each node represents a state. The root represents the initial state. An edge going from a parent to a child specifies an action that can be performed on the parent in order to change state (the new state will be the child). E

am doing my final project that includes face recognition and am trying to implement it on matlab. can anybody help me on getting some resources on each algorithms and their pro's and cons. plus if i get their matlab implementation i would be glad. i'

I am trying to implement the inplace quick sort as explained in the http://en.wikipedia.org/wiki/Quicksort Below is the python code, The partition function does not work as expected. def swap(array, index1, index2): tmp = array[index1] array[index1]

All the possible distinct sums mean that the sums of any one, two, three to n(the length of the array) number in an array. For example, if the given array is [2,2,3] the sums of one number in the array is the array itself [2,2,3] the sums of any two

Is it possible to transpose a (m,n) matrix in-place, giving that the matrix is represented as a single array of size m*n ? The usual algorithm transpose(Matrix mat,int rows, int cols ){ //construction step Matrix tmat; for(int i=0;i<rows;i++){ for(in

I have an assignment that requires reading a huge file of random inputs, for example: Adana Izmir Adnan Menderes Apt Addis Ababa Aden ADIYAMAN ALDAN Amman Marka Intl Airport Adak Island Adelaide Airport ANURADHAPURA Kodiak Apt DALLAS/ADDISON Ardabil

I don't understand this explanation which says if n is the number of elements in the hash table and m is the total number of buckets then hashtables have constant access time in average only if n is proportional to theta(n). Why does it have to be pr

I feel like there should be an available library to more simply do two things, A) Find the mode to an array, in the case of doubles and B) gracefully degrade the precision until you reach a particular frequency. So imagine an array like this: double[

I need to generate encoding String for each item I inserted into the database. for example: x00001 for the first item x00002 for the sencond item x00003 for the third item The way I chose to do this is counting the rows. Before I insert the third ite

Photoshop has a lot of cool artistic filters, and I'd love to understand the underlying algorithms. One algorithm that's particularly interesting is the Cutout filter (number 2 at the link above). It has three tunable parameters, Number of Levels, Ed