homework

Using java.io.Serializable when implementing a tree?

Hey everyone, I have ANOTHER serialization question, but this time it is in regards to Java's native serialization import when serializing to binary. I have to serialize a random tree that is generated in another java file. I know how serialization and deserialization works, but the example I followed when using binary serialization wi...

Calculator using 2 stacks

Hi all. I have an intel assembly assignment. I need to write a calculator which uses 2 stacks. For example, i have an expression like 23+4/2^4$ .So that $ indicates the end of expression. What I will do is to have two stacks, one for numbers, one for operators and push and pop them according to the operator precedence. What I need is ho...

how to determine the period of a function

Hi,if i have a function A,which can apply a certain rule on a given matrix to generate a another matrix which i call it the next state of the origin matrix,also the function can determine the the final state of the matrix by given times N(apply the rule on origin,and apply the rule on the next state of the origin matrix again,and apply r...

Finding difference less than the average in an unsorted array?

Hi, I need to find 2 elements in an unsorted array such that the difference between them is less than or equal to (Maximum - Minimum)/(number of elements in the array). In O(n). I know the max and min values. Can anyone think of something? Thank you! ...

C# implementation multiple variables

Hi all, I have something like this: classes A to D all have variables var1, var2, var3, var4, var5 class A has an extra variable var6 class B doesn't have var6, but do have the variables var7, var8 class C is the same as B, but has an extra variable var9 class D only has an extra variable, var10 How should i implement this? The be...

How can i stop a While loop?

Hi,i wrote a while loop in a function,but dont know how to stop it...when it doesnt meet its final condition,the loop just go for ever....how can i stop it?thanks in advance. def determine_period(universe_array): period=0 tmp=universe_array while True: tmp=apply_rules(tmp)#aplly_rules is a another function pe...

Understanding memory management in mingw/g++.

Greetings. I was give an assignment to basically explain thi. I have taken a quick look at the compiler documentation, and it seems to be a good place to start although it is quite extensive and I don't have much time. I'd like to know if I'd need to understand the C99 standards beforehand, or if there's another good source I can check....

How do you JOIN two MySQL tables where the data is NOT in the other table?

For example, I have a pet table and a lost pets table. I want to get all of the pets that are NOT lost with 1 join and no sub-selects. Is that possible? A typical join only returns results that are in both tables. ...

What is the smallest program possible to parse an email message header?

the homework: http://www.cs.rit.edu/~waw/networks/prob1.082.html Ok, I am still confused why this question was asked for my data communications and networks class, but here is the question from my homework: Write a computer program that reads the header on an e-mail message and deletes all lines except those that begin with ...

What's the difference between a parameter passed by reference vs. passed by value?

I need help. what is difference between a parameter passed by reference, and a parameter passed by value? Could you give me some examples please? ...

How to append the contents of a list at the end of the other list?

How do I append the contents of one list at the end of another list? ...

Macro which prints an expression and evaluates it (with __STRING)

For learning and demonstrating, I need a macro which prints its parameter and evaluates it. I suspect it is a very common case, may be even a FAQ but I cannot find actual references. My current code is: #define PRINT(expr) (fprintf(stdout, "%s -> %d\n", __STRING(expr), (expr))) and then: PRINT(x & 0x01); It works fine but I am not...

Profiling ASP.NET websites with EQATEC Profiler

I'm searching for a free ASP.NET profiler, and I stumbled upon EQATEC Profiler for .NET, but I can't find any instructions on how to profile ASP.NET projects with it. Please post step-by-step instructions or a link with sufficient info. I'm using Visual Studio 2008 Professional and .NET 3.5. ...

Using user input to find information in a Mysql database

I need to design a program using python that will ask the user for a barcode. Then, using this barcode, it will search a mysql to find its corresponding product. I am a bit stuck on how to get started. Does anyone have any tips for me? ...

Checking array duplication in linear time

Is there any algorithm using comparisons that check array duplication in O(n) time limit? I.e., Suppose we have a array of type double. Then I need a function like this bool has_duplicate(double *arr, int len) that works in O(n) time in the worst case and checks whether it has to equal elements or not. Please include a proof, if po...

How can I convert string to double in C++?

how can I convert string to double in C++ I want a function that returns 0 when the string is not numerical ...

MVC in Java

Hi all, This is about a school assignment so I'm trying to do things by the book. I feel like I'm getting the grips of Java, but good programming practice, design patterns, etc. are all rather new to me. I've made my model and it works fine. It contains a student class which contains a number of fields with student information (obvious...

Word Anagram Hashing Algorithm?

Given set of words, we need to find the anagram words and display each category alone using the best algorithm input: man car kile arc none like output: man car arc kile like none the best solution I am developing now is based on a hashtable, but I am thinking about equation to convert anagram word into integer value exmaple: man...

Pointer class assistance

I'm writing a sparse matrix class in C++ in which every row and column are arrays of linked lists from a class I created (aptly named: LinkedList). I want to write a class that is a "smart" pointer to one cell in this matrix. In that class, let say LIPointer, I will implement a ++ operator function for moving in the linked lists of the...

Check linkedlist circularity

I need a method that takes a linkedlist as a parameter and return true or false if it is circular or not. ex:circular linkedlist means there is node pointes to any previous node. I forgot to tell some constraints, I can not use any datastructure or dynmaic memory allocations. I can use local variables only and the alogrithm can be done...