homework

C++ templating question regarding comparators

Probably a very newb C++ question. Say I have a class, vertex, with several properties and methods. I want to stuff a bunch of vertices into a queue, and have them ordered by a special property on the vertex class (doing a basic Dijkstra graph algo for school yes). I'm having some problems penetrating the C++ syntax however. Here is my ...

I need a function to convert lower case to upper case in Java

Hi, I'd like to know how to convert to upper case the input from the keyboard either if they are letters or numbers (only). I'm learning to program and I'd like to do it in the Java language. I have to remove the accents if the input has it and convert the input in the upper case letter. I have an idea of this but I'd really appreciat...

Why aren't students taught to use a debugger?

There's a lot of homework questions here on SO. I would guess that 90%+ can be solved by stepping through the code in a debugger, and observing program/variable state. I was never taught to use a debugger. I simply printed and read the GDB manual and stepped through their examples. When I used Visual Studio for the first time, I reme...

Error with 'extern' usage -- unresolved external symbol

I got the following error message while compiling, but I'm sure I have the variables declared in an external Project2.c file. Could someone give me a hint what I did wrong? Thank you 1>main.obj : error LNK2001: unresolved external symbol _num_days 1>main.obj : error LNK2019: unresolved external symbol _countDays referenced in function _...

How to map 2 different objects together

My current project got 2 modules ModuleA and ModuleB, inside ModuleA and ModuleB got a class call 'Student' (same class name same attributes, but for some purpose ModuleA must call ModuleB to do the actual task) . They communicate to each other through Web Services. Now I want ModuleA WS will call ModuleB proxy to do the actual task. I...

R: How do I best create a function that sums

With R. For a sequence of numbers x, how do I best create a function S(x, r, s) that computes sum(x[t]*x[t+r-s], t ranges from s to length(x)-r+1; r,s>0. Thanks. ...

Java - Which is the best implementation structure for Graph?

The graph is very large but undirected. Edges are unweighted.. In my implementation, I have to find the vertex with max degree and do deletion on both vertexes and edges... Linked list? ArrayList? Map? Which one is better for my implementation? ...

What data structure should I use for a snake game?

I have some homework for my school and I have to make a snake game, like Nokia's, in Delphi. I wonder which solution is the best. I want my snake be a class and the body is an array of points (parent class) or a linked list of points. What's the best? An array or a linked list? ...

Sorting using Comparator- Descending order (User defined classes)

Hi, I want to sort my objects in descending order using comparator. class Person { private int age; } Here i want to sort a array of Person objects. How to do? Please give me a solution, Thanks. ...

Balls and Baskets Problem Algorithm?

Hello all, Let's say there are N people and all these people have 1 basket and unlimited balls. They can throw a ball to others' baskets. We let them throw their balls to others' baskets and we come up with a scenario like that : 'A' person's basket Balls from E, F, G, I, K, L, M, P 'B' person's basket Balls from A, C, E, F, K, T, R,...

Balls and Baskets Problem Ver2

In addition to original balls and baskets problem I mentioned here : http://stackoverflow.com/questions/1948311/balls-and-baskets-problem-algorithm There is a slightly different problem. Still there are N people and they have unlimited balls but they dont have baskets this time. Problem is : There are N people with unlimited balls an...

Java Reflect 2 objects

Hi i got the code below : ModuleA.Student student 1 = null; ModuleB.Student student 2 = null; student2 = retrieveStudentFacade().findStudentbyName("John"); student1 = StudentSessionEJBBean.convert(student2,ModuleA.Student.Class); The problem now student1.getId(); return null but supposed to return me a value. Below is the converter m...

Print an array of numbers from the least significant digit to most significant digit?

8 | * 7 | * 6 | * 5 | * 4 | * * 3 |* * * * * * 2 |* * * * *** ** * * 1 |* * *** ****** **** * * +--------------------------- 012345678901234567890123456 11111111112222222 how would you print numbers from the least significant digits to the most significant digits (like the numbers shown on the x-axis)? Thank you ...

Binary Tree Height

I need a general formula to calculate the minimum height of the binary tree and the maximum height of the binary tree. (not the binary search tree) ...

Concat a list of elements and scores without using a recursive function in XQuery with Tijah extensions

For a university search engine project, I am using MonetDB with Tijah extensions. I've got a list of nodes, returned from a search string: let $qid := tijah:queryall-id($nexi) let $nodes := tijah:nodes($qid) $nodes now contains a list of elements, e.g.: <book>Design Patterns</book> <book>AntiPatterns</book> I can calculate and ret...

Php/MySql Help needed

I am very new to php and MySql, but I am writing a project for school on ticket reservation. I need help with: creating a table in a db that has specified number of rows and the rows increase by mulitples of the specified number (Example: say I have a table for Bus A that has 15 seats so I want d db table to contain 15 rows but has the...

Returning Garbage value c++

I have a method that is suppose to return a garbage value if an item in a tree is not found. All I'm getting though is a runtime exception: "garbage is being used without being defined" ItemType BstClass::rRetrieve(node* trav, KeyType key, bool& inTree) { if(trav == NULL) { inTree = false; ItemType garbage; return...

How to get the elements in a set in C++?

I am confused as to how to get the elements in the set. I think I have to use the iterator but how do I step through it? ...

C - print chars in reverse order (w/o using arrays or functions - yes, it's a hw problem)

Hi - As a homework problem, I'm working on reading a decimal int from stdin, converting it to a different base (also provided from stdin) and printing it to the screen. Here's what I've got so far: #include <stdio.h> #include <stdlib.h> int main() { int num, base, remainder, quotient; printf("please enter a positive number to...

What's wrong with this? It always returns 0

I have this class: public class Fibonacci { public static int Calculate( int x ) { if (x <= 0) { return 0; } else { return Calculate(x - 1) + Calculate(x - 2); } } Per a tutorial I'm doing if one inputs ...