homework

How to implement a state-space tree?

I'm trying to solve a knapsack like problem from MIT OCW. It's problem set 5. I need use branch and bound algorithm to find the optimal states. So I need implement a state-space tree. I understand the idea of this algorithm, but I find it's not so easy to implement. If I find a node that with it, the budget is not enough, I should stop...

How to work with Index on sql server 2008 ?

Hi is it faster to search with index ? if I have this table: MEN: ID|Fname|Age how I insert index to this table how i can search all the person that the age between 20-30 using index ? I work with sql server 2008 thank's in advance ...

Controlling Forks in C

I have a c file that looks like this: #include <stdio.h> #include <sys/types.h> #include <unistd.h> int main () { pid_t child_pid; printf ("The PID is %d\n", (int) getpid ()); child_pid = fork (); if (child_pid != 0) { printf ("this is the parent process, with PID %d\n", (int)getpid()); prin...

Recursive? looping to n levels in Python

Working in python I want to extract a dataset with the following structure: Each item has a unique ID and the unique ID of its parent. Each parent can have one or more children, each of which can have one or more children of its own, to n levels i.e. the data has an upturned tree-like structure. While it has the potential to go on for i...

Accurate evaluation of 1/1 + 1/2 + ... 1/n row

I need to evaluate the sum of the row: 1/1+1/2+1/3+...+1/n. Considering that in C++ evaluations are not complete accurate, the order of summation plays important role. 1/n+1/(n-1)+...+1/2+1/1 expression gives the more accurate result. So I need to find out the order of summation, which provides the maximum accuracy. I don't even know wh...

External sorting of ints with O(N log N) reads and O(N) writes

I'm interested in algorithm which I should use to meet these requirements (topic subj). ...

Java Deque without using any of the existing classes like LinkedList?

Hi, I've got to write a very short bit of code on a deque, however I'm not sure how to write the code for the methods, if someone could help me with one of the methods, (eg. a method to add an object to the from of the deque) then that would get me started. I'm sure I could manage the rest of the methods, just at the moment I'm pretty st...

Java Help: Using Classes

Now I have read and read on this but i am just stuck. Any help appreciated. I am looking for hints. The code compiles and runs fine but I don't think the variables are being stored in the employee class and I am not sure i am understanding my use of the constructor right. -Thanks Requirements: I have completed: Values are checked t...

Java try catch problem

I'm currently writing an app for school that is a mini search engine. On execution, it indexes the contents of the text files included as args. I haven't used the try and catch methods before, and we were just given this code in include in our program: Scanner inputFile = null; try { inputFile = new Scanner(new File("dog.txt")); } c...

splitting a group by preferences

Am a C# rookie trying to help a friend programatically take a group of twenty people (labelled 1 - 20) and spilt them into five subgroups of four each based upon expressed preferences of who those people wish to be with. Each person in the group of 20 could express 0, 1, 2, 3, or 4 preferences. For example, person 1 could select 0 (no ...

Computer System Class and Virtual Memory - Need help with the Algebra

I have what might be more of a math question but this question is stemming from reading my computer systems book in the chapter on Virtual Memory... so I feel justified asking it here. The book states: Each virtual page is P = 2p bytes in size. My algebra is rusty which is probably the reason I need to ask this. Now, for an examp...

Big O Notation for an Algorithm

I can't solve a problem; can someone help me? What is the Big O notation for the below statement:- for (int i=2;i<=n;i=i*4) sum++; ...

php implode explode can do it?

eg: existing data retrieve from db field: a,b,c,d,e so now $data= "a,b,c,d,e"; eg: new data to be added--- cc, gg final value saved into db will be $finaldatatobeupdatedintodb= "a,b,c,d,e,cc,gg"; Retrieve out and add in few more values. Then append it back into the comma list. How to do it purely with implode and explode, without nee...

polynomial multiplication using fastfourier transform

i am going through the above topic from CLRS(CORMEN) (page 834) and I got stuck at this point. Can anybody please explain how the following expression, A(x)=A^{[0]}(x^2) +xA^{[1]}(x^2) follows from, n-1 ` Σ a_j x^j j=0 Where, A^{[0]} = a_0 + a_2x + a_4a^x ... a_{n-2}x^{\frac{n}{2-1}} A^{[1]} = a_1 + a_3x + ...

Comparison Algorithm.

I have 2 arrays (A and B) that contain similar data with some differences. I would like to return an array of objects that are only in A and another array of objects that are only in B. So far I have been thinking: Brute force with some optimizations (this is trivial) Sort the arrays and use a binary search. What are my other option...

Most common checked and unchecked Java Exceptions?

As far as I understand, there is no way to find out which Exceptions a method throws without looking up the API docs one-by-one. Since that is no option, I'd like to reverse the research and ask you which are the most common Exceptions and RuntimeExceptions you've come across when dealing with Casting Arrays Vector, ArrayList, HashMap...

Is there any relation between CPU and threads??

if yes,what is the relation? ...

Is this code O(N) or O(1)

vector<int>::iterator it; vector<int> p; p.push_back(4); p.push_back(5); p.push_back(6); p.push_back(7); it = p.begin() + 2; cout << it << endl; Is this O(N) or O(1)? And why? ...

Using one probability set to generate another

How can I generate a bigger probability set from a smaller probability set? This is from Algorithm Design Manual -Steven Skiena Q: Use a random number generator (rng04) that generates numbers from {0,1,2,3,4} with equal probability to write a random number generator that generates numbers from 0 to 7 (rng07) with equal probability.? I t...

Print out the line with the longest length, the line with the highest sum of ASCII values, or the line with the greatest number of words

I need some help to print out the line with the longest length, the line with the highest sum of ASCII values, or the line with the greatest number of words from a text file. This is my first time programming and I'm really struggling with python and don't know how to calculate want is required for my lab this week. I 've try to work it ...