homework

Trouble with frogger on flash

For starters: I'm working with Flash CS3 and Actionscript 2.0 I'm trying to remake the frogger game, and I'm kinda stuck with putting the cars on the screen. For those of you who don't know frogger: http://www.actionscript.org/showMovie.php?id=1157, but I'm not implementing the logs. The big problem is that I have 3 cars, all of which...

Why does syscall need to switch into kernel mode?

I'm studying for my operating systems final and was wondering if someone could tell me why the OS needs to switch into kernel mode for syscalls? ...

If and equality statements

I'm trying to solve the problem here but I don't know why my code isn't working. Any help is appreciated. EDIT: Edited to make correction mentioned below, but there is still an extra "15" (in bold) on the second line of the output and I don't understand where it is coming from. My output is 18662658515 555227215 #include <stdlib.h> #...

Haskell: Printing out the contents of a list of tuples

Basically what I need to do is write a function that takes in a list of type [(String,String)] and print out the contents so that, line-by-line, the output looks like this: FirstString : SecondString FirstString : SecondString ..etc, for every item in the list. I've got the following code and it prints it out, but for some reason it p...

implement RC5 encryption in java

I've an assignment currently to implement this RC5 encryption in my java project but I have no much idea how to achieve it. I tried to create Cipher object as below line and it throw me exception: Cipher desCipher = Cipher.getInstance("RC5"); ***java.security.NoSuchAlgorithmException: Cannot find any provider supporting RC5*** but ot...

Given numbers from 1 to 2^32-1, one is missing. How to find the missing number optimally?

You are given 2^32-2 unique numbers that range from 1 to 2^32-1. It's impossible to fit all the numbers into memory (thus sorting is not an option). You are asked to find the missing number. What would be the best approach to this problem? Edit: Let's assume you cannot use big-integers and are confined to 32bit ints. ints are passed in...

Java methods and classes, how do they fit together? (Solved)

Currently I am writing a program for an introductory Java class. I have two pieces to my puzzle. Hopefully this is a relatively simple to answer question. Firstly, here is what I am trying to use as my main program: import java.util.Scanner; public class TheATMGame { public static void main(String[] args){ Scanner input = new S...

Derived Functor with any return type and any parameters

I have a class that uses functors as units of work. It accepts a reference to a functor in its Run() method. To allow this class to operate on any functor, all these functors must derive from my base functor class which looks like this: class baseFunctor{ public: virtual void operator()()=0; virtual baseFunctor Clone()=0; }; ...

Help with search coding please.

I am doing a project where I want a person to enter the name of any artist/band into a text box where it will seach my mysql database for the event information and display the results/content on another page. The code below is within my index.php where it should get the information from search.php (below also). I've looked all over and I...

Calculating e^x without using any functions

We are supposed to calculate e^x using this kind of formula: e^x = 1 + (x ^ 1 / 1!) + (x ^ 2 / 2!) ...... I have this code so far: while (result >= 1.0E-20 ) { power = power * input; factorial = factorial * counter; result = power / factorial; eValue += result; counter++; iterations++; } My problem now is tha...

Memory allocation problem in HashTable

Please don't close this saying a duplicate question. I made an important change so not to confuse people, I resubmitted this much clearer codes. Please help me to solve this memory allocation problem. I'm working on a HashTable and this is what I've (partial codes only) main.c HashTablePtr hash; hash = createHashTable(10); insert(hash...

Draw a line of X length given a point in space and a vector.

Before everyone jumps on me for outsourcing my homework, my question is not a question on my homework. I'm just having a problem getting some stuff to draw properly. I'm trying to draw lines perpendicular to a plane. I know the three points in space the make up the plane. From those coordinates I can calculate vectors and get the normal...

Haskell: Writing text files and parsing them back to original format

Hi - I have a list of tuples of format [(String,String)] and I need a function to write the contents of the list to a text file, then another function to read this text file in as the same list of tuples. Here's what I've got for the saving function: save :: Table -> IO() save [] = writeFile "database.txt" "" save zs = do { writeFile "d...

linked list problem in c: the print function deletes the value from my list

As a part of an assignment, I need to write two functions: a function that sums up two natural numbers represented as a linked list a functions that prints a number represented in the same way. for some reason, both function work perfectly fine separately, but when I try to use the print function on the result of the sum function, i...

Parsing a string in C++

Hi, I'm trying to make a constructor for a graph class that accepts a string as a parameter and uses it to build the graph. The string is formatted as follows: |vertex list|Edges list| e.g. |1,2,3,4,15|(1->2),(3->2),(4->15)| The idea is that the constructor will take the values from the string and then know to perform the following a...

c++ accidental static

I've got a linked list class and for some reason when I increment an int in one object e.g linked1.size for some reason linked2.size also increments! And ideas why this is? I didn't intentionally make it a static variable. my code: main() { Vlist v1; v1.add(1,0); v1.add(2,0); Vlist v2; } Incrementing the size member vari...

Algorithms: Interesting diffing algorithm.

This came up in a real-world situation, and I thought I would share it, as it could lead to some interesting solutions. Essentially, the algorithm needs to diff two lists, but let me give you a more rigorous definition of the problem. Mathematical Formulation Suppose you have two lists, L and R each of which contain elements from some...

read from binary file with variable length records

Hello, I have a binary file with variable length record that looks about like this: 12 economic10 13 science5 14 music1 15 physics9 16 chemistry9 17 history2 18 anatomy7 19 physiology7 20 literature3 21 fiction3 16 chemistry7 14 music10 20 literature1 The name of the course is the only variable length record in the f...

c++ Operator overloading "-"

I've done operator overloading to "-" for my class graph. It's use isn't totally intuitive (bad coding-I know) but if I do graph3 = graph2-graph1 then graph 3 is supposed to receive only those vertexes in both graph 2 and graph 1. So, I've written the code and when I run the debugger, the operator- function seems to create a new "grap...

how to use built in list function "filter"

Please help me with using the DrScheme built-in function "filter". "create a function "hello" that consumes a number 'Max', and a list of numbers 'L', produce a list of numbers in 'L' that are smaller than 'Max'." edit Taken from the comments for formatting this is what i have so far (define (smaller? n Max) (cond [(> Max n...