homework

Implementing a State Machine in C++ HOW?

Dear All, I'm new to C++. How can I implement a State Machine in C++ ? I'm getting only the messages and should know the next state. What is the proper structure I need to use ? Thanks, Igal ...

Branch prediction , correlation bit

Problem ; Consider following simplified code fragment; if (d==0) d=1; if (d==1) ... Construct the action table for the 1-bit predictor with 1-bit correlation assuming predictor initialized to NOT TAKEN and the correlation bit is initialized to TAKEN. The value of d alternates 1,2,1,2 Note count the instances of misprediction. I ...

Is this in any way usefull if (this != null)?

I came across some tests that included code like this: if (this != null) { do something } Is this if clause of any use? Is there a purpose I don't get that makes this useful? ...

c++ polymorphism and other function question

i have got this code: class father{ public: virtual void f() { cout<<1;} }; class son:public father{ public: void f() {cout<<2;} }; void test (father x){x.f();} int main(){ son s; test(s); } the question says: the output is '1', what is the rule about polymorphism that the programmer forgot and how can i fix it so...

CSS precedence order? My lecture slides are correct or not?

Hi all: I've noticed that there are a couple of similar questions and answers at SO already, but let me clarify my specific question here first: I've got lecture slides which states like this: To be frank, I haven't heard of this rule of css precedence myself, and I googled to find something with similar topic but not quite like tha...

How would you code a washing machine?

Imagine I have a class that represents a simple washing machine. It can perform following operations in the following order: turn on -> wash -> centrifuge -> turn off. I see two basic alternatives: A) I can have a class WashingMachine with methods turnOn(), wash(int minutes), centrifuge(int revs), turnOff(). The problem with this is th...

Use case modelling for calculator

hi, i need help modelling a use case diagram from a topic, it will be in java GUI Design a Calculator that 1.Allow user to key in a legitimate arithmetic statement that involves number, operator +, - and bracket '(' and ')' ; 2.When user press “Calculate” button, display result; 3.Some legitimate statement would be ((3+2)-4+2) (equa...

it means quick-select algorithm?

Hi, I have a question from my homework. I think my teacher needs an algorithm like quick select for this question, is this correct? The question: Following a program (Subroutine) as a "black box" is given (for example, inside it is not clear and we do not even inside it) with the worst case linear time, can find the middle ...

PIC Assembly function calling

I'm writing a pretty basic program in PIC18 assembly. It requires that I write a subroutine to multiply two 16-bit numbers... This is what I have right now: ;*********************************************************************** ; mul_16bit: subroutine that multiplies two 16 bit numbers stored in ; addresses mul_16ptr1, mul_16ptr1+1...

problem with quicksort

Possible Duplicate: what is mistake in this code i have following code from algorithm in c++ public class improved_quicksort { public static final int m=10; public static int partition(int a[],int l,int r){ int i=l-1; int j=r; int v=a[r]; while (true){ while(a[++i]<v); ...

Church numeral for addition

Hi All, I am stuck up at the following step. It will be great if someone can help me out: 2 = λfx.f(f x) 3 = λfx.f(f(f x)) ADD = λm n f x. m f (n f x) My steps are: (λm n f x. m f (n f x)) (λf x.f(f(f x))) (λf x.f(f x)) -> ((λn f x. (λf x.f(f(f x))) f (n f x))) (λf x.f(f x)) -> ((λf x. (λf' x'.f'(f'(f' x'))) f ((λf" x".f"(f" x"))...

making game by java programing language

i ma working on game as assignment I've never really programmed a game before, wtih java programing language, so I'm completely new … ame across very little information on starting game development in java programming a … I'm looking to write a game with java code programe that also put the data to a file.can any one post me some java...

How to work with Strings in ARM?

This is a homework question. Frankly, I'm not sure how a C program delivers a string parameter to the assembly level. I have the function StringSearchInString( text, searchString); and the parameters text = "Hallo Alles klar" searchString = "ll" I know ARM delivers the parameters into register R0, R1 respectively for text, searchSt...

question about inversion

Hi I have read something in the site that inversion means if i<j then A[i]>A[j] and it has some exercises about this , I have a lot of questions but I want to ask just one of them at first and then i will do the other exercises by myself if I can!! Exercise: What permutation array (1,2, ..., n) has the highest number of inversion? What ...

8085 arithmetic program

Can I get the assembly language arithmetic program operations for 8 bit microprocessor programming ? ...

What is wrong with this code?

int main() { char *name = new char[7]; name = "Dolphin"; cout << "Your name is : " << name <<endl; delete [] name; } Why doesn't the VC++ compiler complain? ...

Big-oh time complexity for nested for loop

Hi, I have a question here the loop is: for (i=0; i < n; ++i) for (j = 3; j < n; ++j) { ... } I kind of understand how to calculate the big-oh but I am not entirely sure on how to do it. The outer loop executes n times and the inner loop executes i times for each value of i. The complexity is sup...

Big-oh complexity for logarithmic algorithms

Hi again, Few more problems I ran into calculating the Big-oh complexity. There are 2 problems which I cannot solve due to log base operations. Here are the two problems: n = # of data items being manipulated 1) n^3 + n^2 log (base 2) n + n^3 log (base 2) n 2) 2n^3 + 1000n^2 + log (base 4) n + 300000n I am confused when the logs ha...

[java] Looking to count frequency of #'s of 2D array output and assign it to a 1D array.

Need to put the frequency of each number occurrence into a 1D array and output the result. The 2D to 1D part is throwing me off, I'm not terribly comfortable with arrays yet. public static void main( String[] args ){ int matrix [][]=new int[20][2]; for (int row=0;row<matrix.length;row++){ for (int column=0;column<matrix[row]...

SQL to Relational Algebra

How do I go about writing the relational algebra for this SQL query? Select patient.name, patient.ward, medicine.name, prescription.quantity, prescription.frequency From patient, medicine, prescription Where prescription.frequency = "3perday" AND prescription.end-date="08-06-2010" AND canceled = "Y"...