homework

How to implement alarm() method correctly to kill all worker processes created by fork()?

If I have a parent coordinator program and a worker program, but the coordinator program is creating all of the needed worker processes. If I want to implement the alarm() method correctly to kill all of the processes and terminate the program after a certain amount of time. Is this the correct way to implement it? The current way I hav...

Access Violation With Pointers? - C++

Hi, I've written a simple string tokenizing program using pointers for a recent school project. However, I'm having trouble with my StringTokenizer::Next() method, which, when called, is supposed to return a pointer to the first letter of the next word in the char array. I get no compile-time errors, but I get a runtime error which stat...

How can I make this work with every delimiter? - C++

Hi, I just wrote a program that tokenizes a char array using pointers. The program only needed to work with a space as a delimiter character. I just turned it in and got full credit, but after turning it in I realized that this program only worked if the delimiter character was a space. My question is, how could I make this program wor...

Find String Array Difference in Java

I created two array variables: s1 and s2 s1 contains {ram,raju,seetha} s2 contains {ram} I want to subtract the two arrays as sets, in order to get the following result: raju seetha How can I do this? ...

Converting letters to digits using phone standard.

Only starting java, need a program to convert the letter on the button of a mobile phone into a number. e.g. a=2 or v=8. I've tried a few approaches, it compiles alright but wont give me the answer? public class digits { public static void main (String letter) { if (letter=="A" || letter=="B" || letter== "C") ...

Inserting a value into an ordered tree in Haskell

Hi Basically I have defined a Tree data type which is defined as follows: data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a) deriving (Eq, Ord, Show) Now I have to create a function to insert a value into an ordered tree (it doesn't have to sort the tree, just add the value). This is what I've come up with so far: insert :: a -...

Why does C give me a different answer than my calculator?

I've run into an odd problem with this code: legibIndex = 206.385 - 84.6 * (countSylb / countWord) - 1.015 * (countWord / countSent); This is the calculation for the legibility index of a given text file. Since this is a homework assignment, we were told what the Index should be (80, or exactly 80.3) My syllable count, word count, and...

Binary Trees in Scheme

Consider the following BNF defining trees of numbers. Notice that a tree can either be a leaf, a node-1 with one subtrees, or a node-2 with two subtrees. tree ::= (’leaf number) | (’node-1 tree) | (’node-2 tree tree) a. Write a template for recursive procedures on these trees. b. Define the procedure (leaf-count t) that returns the ...

What data-structure should I use to create my own "BigInteger" class?

As an optional assignment, I'm thinking about writing my own implementation of the BigInteger class, where I will provide my own methods for addition, subtraction, multiplication, etc. This will be for arbitrarily long integer numbers, even hundreds of digits long. While doing the math on these numbers, digit by digit isn't hard, wha...

Game development with Qt: where to look first?

Hi there, So, I'm going to develop my Pac-Man clone with Qt. The problem is that I do not really know where to start. I quickly take a look at the documentation and some demo. I also downloaded some game sources on qt-apps.org. And it seems that there is a lot of ways to develop a game with Qt! In your experience, which part of Qt sho...

what is the name of this data structure

(10) / \ (9) (8) / \ / \ (7) (5) (4) x x / and \ == x=>y y y thanks in advance ...

Class Diagram with aggregation and generalization

Hi I am working on a university project and i have the following problem i can not figure out. I have a class Called Employee from this i generalize two classes Contractor employee and Permanent Employee. Now i have a team that is made by both types of Employee so i am planning to use aggregation. Do i have to connect the team cla...

Binary to character matrix help

FYI: This is a practice homework exercise. I've been working on it, but now I'm stuck. Any tips/help would be appreciated. I've been staring at it a while and no progress has been made. Summarized question: Nine coins are place in a 3x3 matrix with some face up and some face down. Heads = 0 and tails = 1. Each state can also be represen...

Addressing a single dimensional pointer array with two dimensions

I have the following homework question: Consider the following declarations and answer the question. char strarr1[10][32]; char *strarr2[10]; Are strarr1[3][4] and strarr2[3][4] both legal references? I tried compiling the code with gcc to test it. I was fairly sure that the second reference would throw an error, but it didn't. This ...

How do you use sets and gets in C++?

I've used them in java and didn't seem to have too many issues, but I'm not grasping them very well in C++. The assignment is: Write a class named Car that has the following member variables: year. An int that holds the car's model year. make. A string that holds the make of the car. speed. An int that holds the car's curr...

How Can I Reset The File Pointer to the Beginning of the File in Java?

I am writing a program in Java that requires me to compare the data in 2 files. I have to check each line from file 1 against each line of file 2 and if I find a match write them to a third file. After I read to the end of file 2, how do I reset the pointer to the beginning of the file? public class FiFo { public static void main(...

help for solving problems in a java rmi assignment

Hi, I want to write an application to share desktop between client and server with java rmi. This is the interface: public interface IServer extends Remote{ public void share(BufferedImage image) throws RemoteException; } ----------------------------- // This is the server side code: public class ServerFrame ex...

Accessing named fields in a Haskell function

Hi I've defined a Tree data type in Haskell and an associated 'size' method which calculates the number of elements in the tree. This worked before, however I have updated the Tree data type to use named fields as in the following definition: data Tree a = Empty | Leaf {value::a} | Node {left :: (Tree a), value :: a, right :: (Tree a...

Implementing file locks to make a copy a file.

Develop a C program for file-copy where two processes work together to complete the task: Parent process receives source filename and destination filename from command line. It opens the source file in read mode. Use shared lock on the source file in both the processes. Use exclusive lock on the destination file. Do read/write operatio...

Help with team selection program

Team Selection One of the cherished customs of my childhood was choosing up sides for a cricket game. We did it this way: The two bullies of our gully would appoint themselves captains of the opposing teams, and then they would take turns picking other players. On each round, a captain would choose the most capable (or, towards the end,...