homework

Questions in C

I've faced three separate situations in C lately that I would assistance on: My C code has a global variable: int ref_buf; //declared in a header file In a function definition I use the same name as a parameter: void fun(int ref_buf, param2, param3) { } Will it overwrite the originally defined global variable and will it cause b...

Efficient Huffman tree search while remembering path taken

As a follow up question related to my question regarding efficient way of storing huffman tree's I was wondering what would be the fastest and most efficient way of searching a binary tree (based on the Huffman coding output) and storing the path taken to a particular node. This is what I currently have: Add root node to queue while q...

passing enum in C

This may seem like a simple question but i am getting an error when compiling this. I want to be able to pass an enum into a method in C. Enum enum TYPES { PHOTON, NEUTRINO, QUARK, PROTON, ELECTRON }; Calling the method makeParticle(PHOTON, 0.3f, 0.09f, location, colour); Method struct Particle makeParticle(enum TYPES type, float...

How do I read input character-by-character in Java?

I am used to the c-style getchar(), but it seems like there is nothing comparable for java. I am building a lexical analyzer, and I need to read in the input character by character. I know I can use the scanner to scan in a token or line and parse through the token char-by-char, but that seems unwieldy for strings spanning multiple line...

Property is null, even after being set in code.

Hello, I've been trying to solve this for ages (3 days) now and I just cannot figure it out. I will try to explain the problem comprehensively because it is a bit more complex. My school assignement is to create a simple text game using OOP in C# Visual Studio 2008 (should be built on a library the teacher provided for us). It should o...

help with implementation of strspn( )

The definition of library function strspn is: size_t strspn(const char *str, const char *chars) /*Return number of leading characters at the beginning of the string str which are all members of string chars.*/ e.g. if ‘str’ is “fecxdy” and ‘chars’ is “abcdef” then the function would return 3, since ‘f’, ’e’ and ‘c’ all appear somewhe...

what is wrong with this code snippet

Folks, here is an implementation of memset(), however I have been told that there is one logical mistake in the code. Could you help me find it. I feel that a double pointer for the target string should be passed to this function, which will be like passing the address of the pointer variable and not the pointer itself. I am getting a...

HashTable Java... Can you check my code

Hi, I'm writing an class for a hash table in java... can you please make sure that I am doing it correctly so far. I need to store StudentRecord objects in it.... I am calculating the hash value based on the student's ID which is of type long... package proj3; import java.util.LinkedList; public class HashTable { LinkedList<Stu...

Finding element in LinkedList

If I have an LinkedList of Employee objects... Each employee has a Name, and an ID fields. I have linkedList call list.... If I want to see if the list contains an employee I do: list.contains(someEmployeeObject) How about if I want to see if the the list contains an employee based on the imployee ID.. let's say I have the followi...

Java Generics Help

I'm working on this homework that's kind of confusing me... I am provided with the following BinarySearchTree class import java.util.NoSuchElementException; /** * * @param <T> The type of data stored in the nodes of the tree, must implement Comparable<T> with the compareTo method. */ public class BinarySearchTree<T extends Compara...

Source Code Translator

I have to write program in C#, that converts from C++ source code to C# code. Is there any idea where to start? Do i have to use parser tree? Thanks! ...

Difference between binary search tree and m-way tree

Please explain the difference between a binary search tree and m-way tree? ...

how to check the login in jsp

this the first time i use jsp, and i face some problems. i want to know how to check teh login if i have to tyoe of login. for examplem i have the student and professor. when the anyone is login it should check if he student or professor to forward him to the right page, the student should go to the take_quiz.jsp page and the professor ...

Haskell: looking up the second value of a tuple in a list based on the first value

I've got a function here that is meant to look through a list of tuples and find the second value in the tuple by taking in the first value. Here's the function so far: lookup :: String -> [(String,String)] -> String lookup _ _ [] = "Not found" lookup x y zs = if (notFound x zs) then "Not found" else (head [b | (a,b) <- zs, (a==...

Java True False Questions

My teacher gave out a practice exam on java recently and I'm curious to see how I did on the true/false part. I'm least confident about number one, so any explanation there would help a lot. In Java, a class can extend any number of abstract classes. false. I don't quite understand why, is it just because in an inheriting class the...

Circle functions not behaving as expected in Java Class

so i made a circle class that sets the radius, and should output the radius, circumference and area however, if i input the radius, the radius, circumference, area wont output back, it just shows as 0.0 heres my Circle.java public class Circle { private double radius; private double PI = 3.14159; public void setRadius(doubl...

Convert hex character to decimal equivelant in MIPs?

How do I take a single ASCII character and convert it to its decimal equivelant in MIPs? Do I simply have to have some conditions to subtract a certain amount from the ascii code to make it its decimal representation? ...

Is there any decryption algorithm that uses a dictionary to decrypt an encrypted algorithm?

Well I have been working on an assigment and it states: A program has to be developed, and coded in C language, to decipher a document written in Italian that is encoded using a secret key. The secret key is obtained as random permutation of all the uppercase letters, lowercase letters, numbers and blank space. As an example, let us con...

How can I write a program to determine if a list of test scores are pass/fail in MIPS?

i m writing a MiPS program that will examine a list of 15 test scores. And it is going to input from the terminal.Well, the passing criterion is the score of 50. the ouptuts to the terminal will include the scores in each category and the number of students passing and failing. with input prompts and output statements...Below is the prog...

Any suggestions for a program or small project to learn about concurrency in Java?

I'm aiming to learn about concurrency in Java. Currently my state of knowledge is poor. I'm pretty sure I know what "volatile" means. I sort of know what "synchronized" means. Sometimes. I've never written code that starts threads or manages them. Outside of this issue, I feel confident and at home working in Java. I'm looking for...