homework

Multiprocess Synchronization with a Single Semaphore

We're covering multithreaded programming in a class I'm taking. The professor offered a bonus question that I have been trying, to no avail, to figure out: Each of processes P0, P1, P2 and P3 have to wait for the other three to cross or reach a particular synchronization point in their code, and only then may that process cross its own ...

Algorithm to find next greater permutation of a given string.

Hello all, I want an efficient algorithm to find the next greater permutation of the given string. ...

Creating a struct on the heap?

I've been instructed to write a model strdup by creating a String struct on the heap the holds a copy of the source. I think I have successfully coded the strdup, but I'm not sure if I've created a Struct on the heap... typedef struct String { int length; int capacity; unsigned check; char ptr[0]; } String; char* model...

help writing an algorithm

i need to write algo for this problem. i have never written an algo before . please correct me. there is a list which contains four collumns each with numbers with upto 5 digits and about 10 rows in total. we have to remove the rows containng any number with less than 3 digits. here is how i have tried read list into multi-dimensiona...

Client server application

Hi, Can any one please provide me the sample client and server application in win32, i just want to make my machine as server and client.. if i send a data from client i should be able to see at server, vice versa.. Thanks GrabIt ...

JavaScript simple grid?

I need a simple (HTML/JavaScript) working example for the following objective. In a table with three columns and 5 rows the first column is a text box. The second column is a button/link called EDIT and third column is button/link called SAVE. When I click on EDIT for say the 3rd row the textbox in 3rd row should become editable. I ente...

Soundex algorithm in Python (homework help request)

The US census bureau uses a special encoding called “soundex” to locate information about a person. The soundex is an encoding of surnames (last names) based on the way a surname sounds rather than the way it is spelled. Surnames that sound the same, but are spelled differently, like SMITH and SMYTH, have the same code and are filed toge...

Common Lisp: Beginner's trouble with funcall

I'm trying to pass a function as an argument and call that function within another function. A piece of my code looks like this: (defun getmove(strategy player board printflag) (setq move (funcall strategy player board)) (if printflag (printboard board)) strategy is passed as a symbol represented in a two dimensional list as some...

Help converting input string into Unicode integers in Java

I've been set an assignment which requires me to capture the input of 5 strings, convert them to uppercase, output them as a string, convert them to their Unicode integers (using the getNumericValue method) and then manipulate the integers using some basic operators. I get the first part but I am having trouble with the following: Usi...

Retrieving stdin after using the redirection operator <

For a programming assignment, we have the following requirements: It needs to be a command-line program written in C. It needs to read text from a text document. However, we are to do this by using the Unix redirection operator < when running the program rather than having the program load the file itself. (So the program reads the tex...

find points that are within a circle given center and radius

We have a point (x,y) and some other points (xi,yi). How can we determine wich of (xi,yi) points are within a circle with center (x,y) and radius d (a given number) Thanks ...

Simple Algorithm time complexity Question

Hi, I am working on an assignment for an intro Datamining course. I am trying to figure out the time complexity of an algorithm (see below)? Is it linear/exponential/log/quadratic/polynominal? Any tips on how to approach a question like this would be much appreciated Consider the following algorithm for finding the third smallest elem...

Learning Java Recursion, Ackerman function

I'm working on a recursive Ackermann function in Java. I am getting an error at may recursive line, 23. return Ack(m - 1, Ack(m, n - 1)); Thanks so much if anyone could point out what's wrong. -Kyle /*enter code here Ackerman's function, A(m, n) is defined: A(0 , n) = n + 1 for n >= 0 A(m , 0) = A(m – 1 , 1) ...

Markov Chain Text Generation

We were just assigned a new project in my data structures class -- Generating text with markov chains. Overview Given an input text file, we create an initial seed of length n characters. We add that to our output string and choose our next character based on frequency analysis.. This is the cat and there are two dogs. Initial ...

Regular Expression questions

I am learning regular expressions and having a hard time. Can anyone tell me if I'm on the right path with these two problems? -List the words in the language specified by the regular expression (a|b)(c|elipson) -- I am thinking the answer is ac, bc, a,b. Am I right? -Give a regular expression recognizing all words with an odd number o...

is there another way of solving this problem ?

i have a list 1 column and 100 rows each with a number the number on each row may not be unique i need to output the unique list of numbers sorted according to their rank , which is less if the number of its repetitions is more. least ranked number i.e 1 is on the top now here is how i am planning to solve this problem first i want to...

Looking for Multi-Platform Memory Leak detection programs.

Ok I have a school assignment to basically pick 3 memory leak detecting programs and run them on a bunch of c++ programs that the teacher supplies us and see how they compare to each other. These 3 programs have to be multi-platform and this is where I'm stuck. I have only been able to find one called valgrind which works on both MAC OSX...

Assembly Programming and Interrupt Handling

I'm writing a program in assembly using MIPS architecture for a class, and I'm having trouble figuring out how to grab an input character by a user and store it in a register to process. The program would open a console, output a message, the user can then input a character and then this determines what is supposed to happen next in the...

complexity help..O(n^2), 0(nlog) etc

hey there could someone please help me determine the complexity?. An example given in my class was bubble sort int main() { int a[10] = {10,9,8,7,6,5,4,3,2,1}; int i,j,temp; for (j=0;j<10;j++) { for (i=0;i<9;i++) { if (a[i] > a[i+1]) { temp = a[i]; a[i] = a[i+1]; a[i+1] = te...

What happens in a try-finally block with no catch when an exception is thrown?

What happens when an exception is thrown and you I have try-finally structure (without catch) What does this do? . public class Bicycle{ private int cadence; private int gear; private int speed; // the part with static:???? static{ something // I don't remember exactly the format } //...