homework

Java Thread Wait-Notify

I have 3 threads (A, B, C) that i just can't make them work how i want them to. ALL these 3 threads share a reference to the same object - K. What i'm trying to do, is to start all 3 up, then at some point in time when thread A arrives in a certain state, pause threads B and C, until A executes some method work() and when work finishes, ...

Derived classes

Hello, I have, for example, such class: class Base { public: void SomeFunc() { std::cout << "la-la-la\n"; } }; I derive new one from it: class Child : public Base { void SomeFunc() { // Call somehow code from base class std::cout << "Hello from child\n"; } }; And I want to see: la-la-la Hello from child C...

Sorting Algorithm 2

An in-place algorithm with O(n) running time that rearranges an unsorted array A[0 . . . n − 1] filled with distinct integers so that, for a given k (1<=k<=n), A[0 . . . k − 1] contains the k smallest integers in increasing order. Is there an existing algorithm that meets these specifications, or one that can be altered to meet them, I ...

Linux iptables redirect

I am an ISP and I need to suspend with a message the clients who didn't pay. For every web page they acces they have to see " suspended " ( port 80 ) and all the other ports need to be closed. How can I accomplish this ? Thanks. ...

Manhattan distance algorithm implementation in 8 puzzle

Could you please help me in implementing a Manhattan distance euristic algorithm in solving 8 puzzle or give a link where I can find a solution? Thanks in advance. ...

Print a x,y matrix, java

I want to print the followin matrix using for loops: 1 2 3 4 5 6 2 3 4 5 6 1 3 4 5 6 1 2 4 5 6 1 2 3 5 6 1 2 3 4 6 1 2 3 4 5 I use: public static void main ( String [ ] args ) { for(int w = 1; w <= 6; w++){ System.out.println(""); for(int p = w; p <= 6; p++){ System.out.print(p + ""); } ...

definition pointer variable

hi everybody, i can't understand following defining pointer variable. can you help me? double(*)(double *) foo; note : sory, i edit name of variable func to foo. ...

Game programming without a main loop

My professor gave my class an assignment today based on object oriented programming in Pygame. Basically he has said that the game that we are to create will be void of a main game loop. While I believe that it is possible to do this (and this question has stated that it is possible) I don't believe that this is required for adherence t...

Code uses parent class methods when it should be

I can't seem to get my code to create either a child class or parent class, depending on input. Here's the code: BST<countint> t; if (rst) RST<countint> t; t.print_type() // always prints "BST" RST is a child class of BST. print_type() is just a test method I wrote. RST only really inherits one method, repair(), which is virtual...

Haskell programing: map and fold on search trees

I have a search tree thats defined as data (Ord a) => Stree a = Null | Fork(Stree a) a (Stree a) deriving Show and I have to define two functions, mapStree: mapStree :: (Ord b, Ord a) => (a -> b) -> Stree a -> Stree b and foldStree: foldStree :: (Ord a) => (b -> a -> b -> b) -> b -> Stree a -> b I dont fully understand whats g...

C++ remove node binary search tree

...

Wits End with IDictionary<T,T> and ModelBinders, ASP.NET MVC 2.0

Okay, I'm not trying to do anything super complex, I have searched, and searched, and roamed every blog and forum I can find. I am about to tear my hair out because no one just outright shows it working. I want to use an IDictionary in my Model. Nevermind the reason why, that's irrelevant. I just want to do something very simple, and u...

How do I turn my custom linked list into an array?

I have to implement a method: E[] toArray(E[] a) // Pass an array, convert to singly linked list, then return the array. from java.util Interface List<E> As I mentioned, I have to pass an array, convert it to a singly linked list, sort it, then return the array. In the Node class I have this to work with: public Node(E v, Node<...

Power Set and Union

Following set is given: X := {Horse, Dog} Y := {Cat} I define the set: M := Pow(X) u {Y} u for union The resulting set of the power set operation is: Px := {0, {Horse}, {Dog}, {Horse, Dog}} 0 for empty set My question is referenced to the unio operation. How do I unite 0 and Y? M := {{Horse, Cat}, {Dog, Cat}, {Horse, Dog, Ca...

Generating a multiple list of combinations for a number in Java

The following is the problem I'm working on and my snippet of code. Is there a better way to implement this? I have used basic control structures for this below. Is it better to store the rows and columns in a map and searching through the map based on the key/value pairs? There is a security keypad at the entrance of a building. It...

Need help with my COBOL homework

Sorry to bother you all but I am stuck on my homework for COBOL. I've made two attempts, neither of which is working as expected. The two attempts and their output are shown below followed by the final results it needs to be. I thank you all for your help. First attempt: IDENTIFICATION DIVISION. PROGRAM-ID. MAIL-LABEL. * *************...

draw an ER diagram that fulfills the information about the car dealer company which is described below.

This car dealer company has many branch offices. In each of these branch offices, some sales people are working whose job is selling cars to customers. You need to define your branch offices in your diagram. And also, you need to define sales people who are working in these branch offices. - This company sells cars, so you must store car...

Linked Lists, Assigning char array [C]

Hi all. I've got the task of making a car rental program, which uses linked lists to control what cars are available for rent, are rented, or are in repair. The 'car' is a structure, and so is the rented list, available list, and repair list. Heres my current issue. If the user wants to make a new car available, we must add it to our l...

Help me with my backprop implementation in Python

EDIT2: New training set... Inputs: [ [0.0, 0.0], [0.0, 1.0], [0.0, 2.0], [0.0, 3.0], [0.0, 4.0], [1.0, 0.0], [1.0, 1.0], [1.0, 2.0], [1.0, 3.0], [1.0, 4.0], [2.0, 0.0], [2.0, 1.0], [2.0, 2.0], [2.0, 3.0], [2.0, 4.0], [3.0, 0.0], [3.0, 1.0], [3.0, 2.0], [3.0, 3.0], [3.0, 4.0], [4.0, 0.0], [4.0,...

Print a table in cmd in java

I have the following matrix 1 2 3 4 5 6 2 3 4 5 6 1 3 4 5 6 1 2 4 5 6 1 2 3 5 6 1 2 3 4 6 1 2 3 4 5 ...and I want to have it in a table | 1 2 3 4 5 6 --------------- 1| 1 2 3 4 5 6 2| 2 3 4 5 6 1 3| 3 4 5 6 1 2 4| 4 5 6 1 2 3 5| 5 6 1 2 3 4 6| 6 1 2 3 4 5 Having n elements is it possible to print such a table dynamically? ...