homework

Return statement that works but doesn't make much sense

I have the following function: int mult(int y, int z) { if (z == 0) return 0; else if (z % 2 == 1) return mult(2 * y, z / 2) + y; else return mult(2 * y, z / 2); } What I need to do is prove its correctness by induction. Now the trouble I'm having is that even though I know it works since I ran it I can't follow eac...

how to create a data structure with run time limits

hello i need to implement a data structure that supports insertion deletion and search in O(log(n)) and extracting a special object in O(1) my Data structure needs to hold vehicals sorted by their ID and every vehical got a field which represents the time until the next care. i need to extract the vehical that needed to be cared next in...

Write an overloaded operator+ function so that two instances of the quadratic class can be added together as in the following code:

Write an overloaded operator+ function so that two instances of the quadratic class can be added together as in the following code: quadratic y1 = quadratic (1.0, -5.0, 7.0); quadratic y2 = quadratic (-3.0, -2.0, 10.0); quadratic y3; double result; y3 = y1 + y2; result = y1.evaluate (10.0); cout << result <<endl; To help you out, her...

spotting an Ambiguous BNF

I have an assignment to correct an ambiguous BNF, but I am completely lost. I know this not a true programming question, and I will gladly delete it if it is not an appropriate question for these boards. Are there any good sites where I could learn more about BNF's? The one I am dealing with seems rather simple, but I can't find any exam...

Operator Overloading Questions

So my prof has a sample .h file with the following operators at the end //ComplexNumber.h #include <iostream> using namespace std; #ifndef MY_COMPLEX_H #define MY_COMPLEX_H class complexNumber { public: complexNumber(); complexNumber(double a, double b); void setReal(double a); void setImaginary(double b); double ...

Run the same C++ Program from different Binary Names

Okay, for a homework assignment my professor wants us to write a program in C++ that converts from miles to km. I did all that, the program runs. However, he has this special way of calling the program: The program's usage options are based on the NAME of the BINARY FILE. If the program name is 'km2miles', the program interp...

Need help with Java homework.

I need some help with my homework assignement. My assignment is to create a program that creates a Till object, takes a payment, issues exact change, tells me which coins I need to use and then tells me how much is in the till after. Below is the code I have written. The USmoney class is done and is working. The teacher offered a cheat s...

Chat Server with sockets in C

I'm trying to write a chat server in C that allows communication between two clients using POSIX sockets. I'm not sure I have a good grasp on this concept or how I should set up the communication protocol between the clients and the server. I know I need one socket to bind() the server port to so I can accept incoming connections from c...

Help with Shannon–Fano coding

Hello I hope some one will help me with this=): I have a set of some numbers, I need to divide them in two groups with approximately equal sum and assigning the first group with "1", second with "0", then divide each group the same way in to subgroups until subgroups will be one of number from set! Picture explaining this crazy things):...

Knight's Tour algorithm help

Okay everybody, I know the knight's tour problem is popular for all cs students and I am having trouble getting mine to work. I use this recursive algorithm to progress through the moves, however, once I get to around move 50 I have to backtrack since no moves are available and I end up never completing the tour. I pass a ChessNode (hold...

Properly Reading a Char from an Int in C on a Stack

Hi all, so I'm having a crazy time right now reading characters off a stack. I'm storing the char as an int, so I can check for the EOF signal, but things aren't going so well. I'm new to the implementation of stacks, so things are probably just wrong somewhere. Here's my code. I'm getting both the incorrect top character on the stack (...

iPhone targeted websites

I have to do a short paper (6-8 pages) (at my collage, I'm a student) on the subject: "Developing web-sites for iPhone". I have not yet done any work related to mobile browsers, so I am pretty clueless how things work in that department. I don't even have an iPhone :( Please answer these basic questions (I will be generous in upvoting ...

C# problems with a for loop

Can someone tell me why this doesnt work. When I enter the loop it prints everything instead of one line and get the users input. It prints Enter the integer the account numberEnter the integer the account balanceEnter the account holder lastname Got it working thanks everyone, but now the searchaccounts doesnt work using System; using...

Java Bucket Sort

I am trying to create my own style of Bucket Sort and I am getting an error with my code and I don't know how to fix it. Any help would be great. I have two classes, Node and BucketSort: public class Node { protected int element; protected Node next; public Node() { element = 0; next = null; } p...

Patterns using loop in java or blueJ

How to print the follwoing pattern in JAVA 1. * * * * * * * * * * * * * * * * 2. * * * * * * * * * * * * 3. * * * * * * * * * * * * * * * 4. B L U E J B L U E B L U B L B 5. B L B U L B E U L B J E U L B ...

frame background colour

how to give background colour in a frame using java swing? ...

Algorithm: Find index of 2nd smallest element from an unknown array

I have been pondering about my homework question for a while. I welcome (and prefer) any suggestions or approach on how to attack this problem. Basically, I have an array A of size N. We do not know the elements but we know they are distinct. The only thing that I have is a person who will take two indices (i,j) in N. This person will t...

Using Binary Trees to find Anagrams

I am currently trying to create a method that uses a binary tree that finds anagrams of a word inputted by the user. If the tree does not contain any other anagram for the word (i.e., if the key was not in the tree or the only element in the associated linked list was the word provided by the user), the message "no anagram found " gets ...

html parser in iphone

i want to display output of html file without using uiwebview.please give some sample code to parse html file............thanks in advance ...

c++ program for matching drum sticks

I am want to write a C++ program to accomplish drum stick matching. I am really new to C++, so could any one help me. Below is my project description Use the vector class in STL. Use iterators in STL. Use at least one STL algorithm Use an externally imposed design for an existing class without making modifications Create stubs to ...