homework

C Programming - My program is good enough for my assignment but I know its not good

Hi there I'm just starting an assignment for uni and it's raised a question for me. I don't understand how to return a string from a function without having a memory leak. char* trim(char* line) { int start = 0; int end = strlen(line) - 1; /* find the start position of the string */ while(isspace(line[start]) != 0) { st...

Best book regarding NP-hard, NP-complete, P =? NP

What is the best book for a student learning about concepts such as NP-hard, NP-complete and P=?NP? I've already got the CLR but it doesn't really cover these particular topics as thoroughly. ...

Any website with an api that serves mp3 songs(or just portions) for free?

As a homework i need to make a webapp that will play an mp3 file and the user has to guess the name of the song or the band in a certain time. My question is where can i get this songs? Is there any website that offers mp3's and an api from which i can get songs along with the band and the name? It doesn't have to be the whole song, in f...

Scheme sorting a list

Okay so I am trying to take in a list and sort it from greatest to smallest. Example: > (maxheap (list 5 6 2 1 18 7)) ;output: > (18 7 6 5 2 1) So here's what I got so far: (define (mkmaxheap heaplist) (let ((max (mymax(heaplist)))) ;mymax is a func that returns max number, it works (let (( head (car heaplist)) (tail (cdr he...

Basic C# problem

Determine if all the digits of the sum of n -numbers and swapped n are odd. For example: 36 + 63 = 99, y 409 + 904 = 1313. Visual Studio builds my code, there is still something wrong with it ( it doesnt return an answer) can you please help me here? using System; using System.Collections.Generic; using System.Linq; using System.Tex...

Calculate shortest path through a grocery store

Hi, I'm trying to find a way to find the shortest path through a grocery store, visiting a list of locations (shopping list). The path should start at a specified startposition and can end at multiple endpositions (there are multiple checkout counters). Also, I have some predefined constraints on the path, such as "item x on the shoppin...

Array reverse and Array sort on One int array and store into another array using delgate

Array reverse and Array Sort on an int array and store into another array using a delegate. We have to accept the elements from the user ...

code for sorting of numbers in ascending order in visual c++

i need the code for sorting of numbers in ascending order using visual c++ in the windows forms,the output comes on the forms text box and i am doing it in visual studio.... anyone please help...provide the code ...

multitreading scheduling related java

class A implements Runnable{ B b=new B(); public void run(){ while(true){ System.out.println("H1"+Thread.currentThread().getName()); } } } public class Test { public static void main(String[] str){ A a1 =new A(); // A a2 =new A(); // Thread t1 =new Thread(a1, "Vichi"); Thread t2 =new Thread(a1,"Vishu"); t1.start()...

Is this an example of polymorphism?

I'm working on a homework assignment (a project), for which one criterion is that I must make use of polymorphism in a way which noticeably improves the overall quality or functionality of my code. I made a Hash Table which looks like this: public class HashTable<E extends Hashable>{ ... } where Hashable is an interface I made th...

nth smallest number among two databases of size n each using divide and conquer

we have two databases of size n containing numbers without repeats. So, in total we have 2n elements. They can be accessed through a query to one database at a time. The query is such that you give it a k and it returns kth smallest entry in that database. we need to find nth smallest entry among all the 2n elements in O(logn) queries. t...

Help in C with integers

You need to use division and remainder by 10. Consider this example: 163 divided by 10 is 16, remainder 3 16 divided by 10 is 1, remainder 6 1 divided by 10 is 0, remainder 1 You'll notice the remainder is always the last digit of the number that's being divided. How do I do this in C? ...

Values of Integers and Calculations

Say you have a variable n1 which will be the value of three digits entered how can i then without knowing what exactly will be input split n1 into 3 seperate integers to do futher calculations with? ...

How can I make a recursive version of my iterative method?

Greetings. I am trying to write a recursive function in Java that prints the numbers one through n. (n being the parameter that you send the function.) An iterative solution is pretty straightforward: public static void printNumbers(int n){ for(int i = 1; i <= n; i++){ System.out.println(i); i++; } As a novic...

How can I round money values to the nearest $5.00 interval?

I have an Informix-SQL based Pawnshop app which calculates an estimate of how much money should be loaned to a customer, based on the weight and purity of gold. The minimum the pawnshop lends is $5.00. The pawnshop employee will typically lend amounts which either ends with a 5 or 0. examples: 10, 15, 20, 100, 110, 125, etc. They do thi...

xml to hashmap - php

Hi, Given an xml structure like this <gesmes:Envelope> <gesmes:subject>Reference rates</gesmes:subject> <gesmes:Sender> <gesmes:name>European Central Bank</gesmes:name> </gesmes:Sender> <Cube> <Cube time="2010-03-26"> <Cube currency="USD" rate="1.3353"/> <Cube currency="JPY" rate="124.00"/> <Cube currency="BGN" rate="1.9558"/> <Cube cur...

Problem with VisualBasic

I have a silly error that I am unable to resolve. I try to debug, and when I debug I get the following error ERROR "Visual Studio cannot start debugging because debut target 'C:\Documents and Settings\user\Desktop\programs6\HuricaneSeasonStatistics\bin\Debug\HuricaneStatistics.exe" is missing. Please build the project and...

Accessing elements of this xml

<wsdl:definitions targetNamespace="http://www.webserviceX.NET/"&gt; <wsdl:types> <s:schema elementFormDefault="qualified" targetNamespace="http://www.webserviceX.NET/"&gt; <s:element name="ConversionRate"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="FromCurrency" type="tns:Currency"/> <s:element minOccurs="1...

Java - How to declare table[i][j] elements as instance variables?

All, I am trying to code a Connect4 game. For this, I have created a P4Game class and a P4Board class which represents the i X j dimensions of the Connect4 board. In P4Game, I have the following: public class P4Game{ //INSTANCE VARIABLES private int nbLines; private int nbColumns; private P4Board [][] position; //CONST...

Adding the sum of numbers using a loop statement

I need serious help dividing the positive numbers and the negative numbers. I am to accumulate the total of the negative values and separately accumulate the total of the positive values. After the loop, you are then to display the sum of the negative values and the sum of the positive values. The data is suppose to look like this: ...