homework

Scheduler hacking in Freebsd 5.2.1

How can I modify the thread priorities within, umm... the Timesharing class? In case I want to implement my own scheduler, how would I have to do that? (like assigning priorites on my own terms) How do I play around with the time slice values (or time quantums, as they are referred to by a lot of people) Edited I figured that the time q...

How to compare two numbers to see which is greater

Comparing two numbers x,y; if x>y I return 1, else return 0. I am trying to do this using only bitwise operators such as >> << ~ ! & | ^ +. So far I got this: int greaterThan(int x,int y) { return ((~(x-y))>>31); } So if x-y is negative, the most significant bit would be a 1. So I negate it to get a 0 and shift it so that it returns...

Java homework help

Hello I have this assignment that I've tried. But when I enter 1 it should not give any output as 1 is > 0 and 1 is not even but I still get output as: Enter a +ve number 1 You entered 1 I'd asked for a +ve number :) . import java.util.Scanner; class Main { public static void main(String[] args) { Scanner input = new Sca...

How to resolve dependent classes?

I have two classes which depend on each other. I've solved this problem before but I can not for the life of me remember how to fix this. My simplified code is this: struct MenuOption{ string Text; int Choice; bool UseSubMenu; Menu SubMenu; }; class Menu{ public: Menu(MenuOption optionlist[],int optioncount); }; ...

Nesting Function Calls

Hey all, This has been driving me absolutely nuts. I have a substitute function like this: (define (mysub x bind body) ;; x, bind, body are lists ...) I need to call the function like this: ;;this is the explicit call for when length x = length bind = 2. ;;how do I generalize these nested calls? ;;in case it's not obvious, i'm ...

difference between operator overloading and operator overriding in c++?

hi.. what is main difference between operator overloading and operator overriding in c++? please explain with example? Edit1 :- Any good web links that would help a novice programmer to improve and be confident about the language he/she is learning. ...

why my heap is corrupted?

i'm getting an error - heap corruption, can't figure out why. my base : h: class Base { public : Base(char* baseName, char* cityName); virtual ~Base(); list<Vehicle*>::const_iterator GetEndList(); void PrintAllVehicles(ofstream &ResultFile) const; char* GetBaseName() const; char* GetLocation() const; v...

How to poll simple website for updates?

I have a professor who randomly updates his website with homework due tomorrow and seems to expect us to check it every hour. This sounds like a job for a program. His website is simple and entirely html, not even any javascript. How could I programatically detect any changes/updates to his website? ...

C# simple program errors

I'm having a little trouble with this code im writing for a simple program. I get tons of errors saying "invalid token" The program basically asks for 2 integers and sums them up, but the program needs to be called in another method. Thanks in advance :D using System; using System.Collections.Generic; using System.Linq; using System.T...

Binary Counting : How many values can be represented w/ 9 bits?

I fear that I may be over thinking this homework question that I have for my assembly course. It reads: How many different values can be represented in 9 binary digits (bits)? My thinking is that if I set each of those 9 bits to 1, I will make the highest number possible that those 9 digits are able to represent. Therefore, the highest...

Haskell - get items that occur only once

Im trying to figure out how to create a new list that has only the elements that occur only once. I can't use recursion either. This is a small part of a bigger function. Im trying to write a function to get the Intersect of two sets. Basically i combined the sets. Then sorted. Then i want to combine that with set B and get rid of all t...

Real vs Apparent classes in Java

class A { public static void main(String[] args) { A a = new A(); B b = new B(); A ab = new B(); System.out.format("%d %d %d %d %d %d", a.x, b.x, ab.x, a.y, b.y, ab.y); } int x = 2; int y = 3; A(int x) { this.x = x; } A() { this(7); } } class B extends A { int y = 4; B() { super(6); } Hey all, I was just ...

Crazy C++ iterator error - pointer keeps changing!

I'm writing a binary search tree for school, and part of the assignment is to write a find function. Here's my code: typedef BSTIterator<Data> iterator; iterator find(const Data& item) const { BSTIterator<Data> iter = this->begin(); BSTIterator<Data> end = this->end(); while (iter != end) { if (*iter == item) { return it...

Python; reading file and finding desired text

Need to create a function with two params, a filename to open and a pattern. The pattern will be a search string. Eg. the function will open sentence.txt that has something like "The quick brown fox" (can possibly be more than one line) The pattern will be "brown fox" So if found, as this will be, it should return a line number and i...

How do I pass a string to a linked list instead of an array of characters in C?

I understand that there's no String data type in C. What I want to do is get an input string from the user and store it to a variable without having to define how many characters it needs to have. Can I do that using linked lists? I want to avoid putting it to a character array as much as possible so linked lists are the only thing I can...

How to return control from a function in lisp

(defun returnFirstCharacter(p) (if (symbolp p) (char (symbol-name p) 0) nil) ) (defun returnRestCharacters (p) (let () (intern (subseq(string p) 1)) ) ) (defun val (x a) (cond ((null a) nil) ((equal (car(cdr a)) x) (cdr (cdar a))) (t (val x (cdr a))) ) ) (defun match (pattern data) (cond ...

An example of what they are asking would be great.

Possible Duplicate: A class definition for a date class that contains three integer data members:month,day,year I am not sure what they are asking for here. An example would be great. Here is the complete list of requirements. I am working through an exercise in a book I have been reading but I have read the chapter over and ...

Need idea on what sort of PHP script to create

For a job application I need to make a nice PHP script to show them what I can do and mail it to them. I haven't been able to think of just what kind of script to create, so maybe you could give me some ideas? I'm fairly good in PHP by the way. ...

Write a program to count how many times each distinct word appears in its input. Use C++.

This is a question(3-3) in ACCELERATED C++. I am a fresh man for C++. I have thought for a long time, however, failed figuring it out. Will anyone kind to resolve this problem for me? Thank you very much. Please explain it in detail, you know I am not very good at programming. Tell me the meaning of the variables you use. THANKS A LOT! ...

What's the problem with this code?

Hi When I run the following code I am getting NumberFormatException can anybody help me out in debugging code. import java.io.*; public class Case1 { public static void main(String args[]) { char ch='y';int i=0; BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); System.out.println("ch b...