homework

Trimming a string in C (without using library functions)

Hi, i was hoping for some help, opposed to full solutions and i have an idea that i need to know what i am doing wrong when trying to implement basically i am trying to remove spaces from the end of an array of characters in c this is what i am doing i have a method to work out the length of the string and store it in to an int i se...

Disjoint Set ADT Implementation in c++

Hay Dear! I have problem in implementing disjoint set ADT in c++ due to the fact that our teacher only explained the union and find operations. I have full concept of union and find but still I am confused about how to implement. Please give me an idea , also explain what should be the interface of this data structure. Explain this data...

Efficient algorithm for finding spheres farthest apart in large collection

I've got a collection of 10000 - 100000 spheres, and I need to find the ones farthest apart. One simple way to do this is to simply compare all the spheres to each other and store the biggest distance, but this feels like a real resource hog of an algorithm. The Spheres are stored in the following way: Sphere (float x, float y, float...

how to grow a dynamic array of char pointers (in C++)?

I am trying to work with an array of char pointers. Let's say I dynamically declare such an array like so: int numrows=100; char** array = new char*[numrows]; And then I populate it by using getline to get strings from a file, converting the strings to char arrays, then setting a pointer in my array to point to said char array l...

Writing a C++ version of the algebra game 24

I am trying to write a C++ program that works like the game 24. For those who don't know how it is played, basically you try to find any way that 4 numbers can total 24 through the four algebraic operators of +, -, /, *, and parenthesis. As an example, say someone inputs 2,3,1,5 ((2+3)*5) - 1 = 24 It was relatively simple to code the...

having problem adding to a collection

I am adding information about different books, cd, dvd from main() I am trying to use inheritance in this project... First, i am a beginner so keep that in mind when you help me. please try to keep it really simple.. I will post partial code where i need help then i will post the full code at the bottom.. now in the items class i am n...

Simple Linked List Implementation Problem - C++

Hi, I'm a programming student in my first C++ class, and recently we covered linked lists, and we were given an assignment to implement a simple one. I have coded everything but my pop_back() function, which is supossed to return a pointer to the Node that needs to be deleted in Main(). No Node deletion is to be done in the actual funct...

[compiler] Question about first and follow

Given following grammar S -> L=L s -> L L -> *L L -> id What is the first and follow for the non-terminals? If the grammar is changed into S -> L=R S -> R L -> *R L -> id R -> L What will be the first and follow ? Thanks ...

Conversion from int to char in c

how can i convert integer to char ...

Logic Issues - Help needed

I am trying to remove spaces from a string in c, not from the end, nor the beginning, just multiple spaces in a string for example hello everyone this is a test has 2 spaces between hello and everyone, and five spaces from this to is. Ultimatley i would want to remove 1 space from the 2 and 4 from the 5, so every gap has 1 space...

Instance of child class ?

How to create the instance of child class in C#? class Parent { virtual void test() { Console.writeline("this is parent"); } } class Child : Parent { override void test() { Console.writeline("this is from child"); } } public static void main() { //Which one is right below? Child ch = new Child(); Parent pa = new Parent(...

Remove redundant whitespace from string (in-place)

Ok so i posted earlier about trying to (without any prebuilt functions) remove additional spaces so "this is <insert many spaces!> a test" would return "this is a test" http://stackoverflow.com/questions/2279679/logic-issues-help-needed As it was homework i asked for no full solutions and some kind people provided me with the fol...

compression with huffman

I have a project that should compress and decompress the text files in Java. I understand the Huffman algorithm, but I don't know how to code the whole project. Who can help me? ...

How can I solve this three variable equation with C#?

My teacher asked me to create a program to solve something like: 2x plus 7y plus 2z = 76 6x plus 1y plus 4z = 26 8x plus 2y plus 18z = 1 x = ? y = ? z = ? Problem is, this is literally the first two days of class and he expects us to make something like this. Any help? ...

Where is my module located?

I made a kernel module and used the code below to try to make a /dev/mytimer entry. #define DEVICE_NAME "mytimer" #define MAJOR_NUM 61 static struct class *fc; fc = class_create(THIS_MODULE, DEVICE_NAME); device_create(fc, NULL, MAJOR_NUM, "%s", DEVICE_NAME); I don't see my module in /dev as /dev/mytimer... But when I lsmod, I see i...

I can't seem to delete the simplest case on a Binary Search Tree in C

Hi, I've posted about this last year because some university project and now I have to do it again (I never finished what I had to do last year). I've already looked at me previous code, all you guys answers on those questions, but still, I can't seem to understand this. I'm not going to put all my questions in one long post, it just m...

Endless Recursion in Python

Full disclosure, this is part of a homework assignment (though a small snippet, the project itself is a game playing AI). I have this function built into a tree node class: def recursive_score_calc(self): current_score = self.board for c in self.children: child_score = c.recursive_score_calc() ...

Javascript building tree hierarchy

var array = [{"grandpa","father"}, {"father"}, {"grandpa","father","me"}]; Given the above array, I want to product a java-script object(JSON) like below, that has the parent-child like structure. {"id":"grandpa", "children":[ {"id":"father", "children":[ {"id":"me", "children":[] }] }] } ...

Class Method with arguments that returns an array

Hi there I'm pretty new to Java and not from a programming background. I am doing a course and am stuck on a piece I hope this is appropriate to ask a question here). The question ask to create a method that takes an array of integers as an argumetn and returns a sorted set containing the elements of the that array. I am not includin...

help for a java assignment

Hi, I want to write a messenger application with java. I want to send smily pictures. I have written this code but it doesn’t work. public class MyClient extends JFrame implements IClient { … JEditorPane editorPane=new JEditorPane(); final String SMILE = ClassLoader.getSystemClassLoader().getResource("images/1.gif").toString(); … ...