homework

Building a suffix tree in C++

I'm attempting to build a suffix tree in C++ as part of an assignment on gene sequencing void Tree::insert(string ins) { Node* iterator = chooseBranch(root, ins.at(0)); string temp; for(int i=0; i<100; i++) { if(iterator->data=="") . . . chooseBranch() is a function to pick which of 4 children to go to, a...

Java: FileRead question

How would you write this code? This particular question is about a maze game that has an arraylist of occupants which are Explorers (you), Monsters (touching will kill you), and Treasures. The game uses blocks of square objects in which these occupants reside in. The particular thing I want to do is file reading which can export the cur...

java Change the title of a object everytime I run a for loop NOOB Question

private void drawGrid(){ for(int i = 0; i<3; i++){ GLine line = new GLine(0,0,21*i,211*i); add(line); } } Is there a way to change the name of the gline I create each time the for loop is run? ...

help with set & map on STL for c++

I am taking a CS class, and most of the assignments were in java. in the last java assignment we learned collections. This assignment we are using c++ and i need to learn the STL The required book is all in java. We were given this webpage http://www.cplusplus.com/ however, that and google is not going to get me through the assignment. ...

How does this java code execute code?

I have a project in my programming class and I'm failing a test case. I look into the test driver and find this: private static boolean testSquareArch() { boolean pass = true; int test = 1; int cnt; Square sq; Class cl; System.out.println("Square architecture tests..."); sq = new Square(true, true, true, true, 0, 0); ...

Swapping bytes in C (endianness)

I'm trying to swap bytes for an assignment, and I thought this would be the way to do it. p points to the scalar object to be reversed size is the number of bytes of the object. void *ReverseEndian(void *p, size_t size) { char *head = (char *)&p; char *tail = head + size - 1; for (; tail > head; --tail, ++head) { ...

Question about the cancel button on a standard JOptionPane

So I am working on a program for school, and part of the assignment is to have a bunch of prompts for input pop up. I am using the JOptionPane, which inherently has an OK button and a Cancel button. Now, to make the program exit when they press cancel when the prompt is asking for a string, I have something like this: firstName = JOpti...

Strassen's algorithm efficiency help

Hello I am trying to get the efficiency for Strassen's algorithm but need some help. The recurrence relation for the algorithm is the following: A(n) = 7A(n/2)+18(n/2)^2, for n>1, A(1) = 0. I've solved it to the point where I have a(n) = 6( 7^(log base(2) n) - 4^(log base(2) n) ) Does this mean the efficiency of the algorithm is...

How to build a basic and simple 5-star rating system?

I'm very new to web technologies and this is basically for a term project that my team is working on. We are working on a food review site. As of now, I'm not quite sure how to implement a simple 5-star rating system. Am I supposed to use a server-side language like PHP or a client-side one like Javascript (w/ JQuery). Looking around it...

Haskell: syntax error when adding new line in pattern matching

Basically I'm modifying a parser to handle additional operators. Before my changes, one part of the parser looked like this: parseExpRec e1 (op : ts) = let (e2, ts') = parsePrimExp ts in case op of T_Plus -> parseExpRec (BinOpApp Plus e1 e2) ts' T_Minus -> parseExpRec (BinOpApp Minus e1 e2) ts' T_Times -...

Operator precedence and associativity in a parser (Haskell)

I am trying to extend a recursive-descent parser to handle new operators and make them associate correctly. Originally there were only four operators (+ - / *) and they all had the same precedence. The function I am looking at is the parseExpRec function: parseExpRec :: Exp -> [Token] -> (Exp, [Token]) parseExpRec e [...

Using a for loop to print a pattern in java

I am trying to print out this pattern using a for loop in java but I am kind of stuck. zzzzz azzzz aazzz aaazz aaaaz aaaaa I can print: a aa aaa aaaa aaaaa using: String i = " "; int a = 0; for (i="a";i.length()<=5;i=i+"a") System.out.println(i); and zzzzz zzzz zzz zz z using: String i = " "; for (i=...

transformation in matlab

how to use matrix to transform to curve in matlab??? --scaling on the xy plane --translation on the xy plane --translation in space --rotation on plane about the origin by angle --rotation in space about the z-axis by angle how i want write the source code? thank you!! ...

nth smallest element of a BST

a BST(binary search tree) T is given. how to find the nth smallest element of T ? ...

Help with Overloaded Methods

I have created a class named Times and I have to construct 4 overloaded methods. I just would like some help understanding overloaded methods and at least maybe some help with the first one. I would really appreciate it. Thanks :) multiply 2 integers and return the (integer) product multiply 3 integers and return the (integer) product ...

I'm trying to change my Maze traversal recursive coding part into a while loop.

Here's my code. #include <iostream> using namespace std; enum Direction { EAST, NORTH, WEST, SOUTH }; const int size = 12; int xStart = 2; int yStart = 0; char *maze2[ ] = { "############", "#...#......#", "..#.#.####.#", "###.#....#.#", "#....###.#..", "####.#.#.#.#", "#..#.#.#.#.#", "##.#.#.#.#.#", ...

Drawing circles in Android

Hi I' trying to complete an assignment. I need to be able to draw circles with the canvas in Android and also draw the ten previous circles while my finger moves. I have saved the coordinates in an arraylist and tried to use a for loop to draw all of the circles. Here is my code, I'm just looking for suggestions not answers if anyone...

Java variable number or arguments for a method

Can you tell me if I am correct in this question? It's a homework question, I don't want the answer. I just want to make sure that I am correct. It is possible to declare a method that will allow a variable number of parameters. The symbolism used in the definition that indicate that the method should allow a variable number of paramet...

Confusing with memory allocation of array in Java

I get annoying to comprehend memory allocation of array in Java,could your guys give me some clarification about this.Following is an example that i want you to give me the result of how many object get instantiated for each statement. String s1[] = {"12","saf"}; int s2[] = {1,2}; Object s3[] = new Object[2]; String s4[][] = {{"12","...

"Top-down discussion of design"

I need to write a lab report for a program I made. I need to provide a "top-down discussion of design." What does that mean? ...