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...
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...
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?
...
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.
...
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);
...
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) {
...
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...
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...
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...
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 -...
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 [...
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=...
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!!
...
a BST(binary search tree) T is given.
how to find the nth smallest element of T ?
...
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
...
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[ ] = {
"############",
"#...#......#",
"..#.#.####.#",
"###.#....#.#",
"#....###.#..",
"####.#.#.#.#",
"#..#.#.#.#.#",
"##.#.#.#.#.#",
...
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...
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...
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","...
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?
...