homework

floating points: IEEE based, but non-standard conversion of bit values to binary

hey! So here is what we have, a custom IEEE based setup: Consider a five-bit floating representation based on the IEEE floating point format with 1 sign bit, two exponent bits and 2 significand bits. And a selection of bits that needed to be converted to binary (answers included): 0 00 00 = 0 0 00 01 = 0.01 ...

Proper way to accomplish this construction using constructor chaining? (C#)

Hi, I have an assignment for my first OOP class, and I understand all of it including the following statement: You should create a class called ComplexNumber. This class will contain the real and imaginary parts of the complex number in private data members defined as doubles. Your class should contain a constructor that allows the...

C# using desicion logic to meet these requirements?

I've made a program for my OOP class that does the following: Defines a class to represent complex numbers Uses a constructor to initialize a Complex Number object passes and returns complex number objects from a function tests the complex number class in a driver, and optionally adds and subtracts complex numbers. My Program works a...

How to choose and set the correct loop invariant?

Hi, I've been given the following problem about loop invariants: Consider x=4; for(i=5;i<k;i++) { a=a+x+i; x=x*2; } Define the appropiate loop invariant that utilizes a closed formula for a and x. Now, How do you know you have the right loop invariant here? I mean you can set the loop invariant to be: "At j'th iteration 'x' is less...

checking if a tree is a heap [in prolog]

I need some help writing a predicate heap(Tree) in prolog that succeeds if Tree is a heap that satisfies both the heap property and the shape property: The shape property: the tree is an almost complete binary tree; that is, all levels of the tree, except possibly the last one (deepest) are fully filled, and, if the last level of the t...

Write a function int mystrlen(char *s) that returns the number of characters in a string wuthout strlen func.

heres what i did, i just have ne error that i cant figure out. int mystrlen(char string[]) { char string1[LENGHT], string2[LENGHT]; int len1, len2; char newstring[LENGHT*2]; printf("enter first string:\n"); len1 = mystrlen(string1); printf("enter second string:\n"); len2 = mystrlen(string2); if(len1 == EOF || len2 == EOF) ex...

count the number or characters in the string

I need to count the number of characters in the string without using the strlen function. int mystrlen(char *s) { char s[]=”program”; int counter = 0 ; int i; for (i = 0; i < s[i]!= 0; i++) { counter++; } printf( "The number of characters is %d", counter); return 0; ...

Prolog Beginner

I'm trying to make predicates such that for lists X and Y, rmlast is true if X and Y are the same list except for the fact that Y has 1 element more. So [1] [1,2] or [3,2] [3,2,5]. rmlast([], [_]). :- true. rmlast([X|xtail], [Y|ytail]) :- rmlast(xtail,ytail), X is Y. This however, produces a false result for anything other than the ba...

C++ error C2819: type 'List' does not have an overloaded member 'operator ->'

I keep getting this error - error C2819: type 'List' does not have an overloaded member 'operator ->' i can't figure out why? help? Main.cpp - #include <iostream> #include <string> #include <cassert> using namespace std; #include "List.h" #include "Node.h" The error happens here: void PrintList ( List list ) { Node * tem...

Are there tools to integrate Java and C++?

Hello, thanks for reading this question. I am doing this homework which need a GUI as frond end to integrate with back end code which written in C++. I wanna to write this front end GUI in java as its cross-platform feature and strong graphic components. Is there any good way I can integrate java and C++ well? Thank you ...

Reading in MIPS external file so another file can use it?

Hey all, I'm working on this final thing for my MIPS project and it's deceptively easy. I need to get a procedure (called feed) and let its main driver program use it by reading it in. I know that I'm supposed to use the call code 14 and .globl sym (I think) in order to feed it into the file and have it read it. I just need a basic tut...

Java : Reading in a binary file.

I have an program that allows a user to input their employee name and number and then their hourly wage and their total number of regular hours and overtime hours. Then writes out the data to a binary file. The program I need assistance with reads in that file, adds a new field at the bottom, "Gross Pay", and calculates the gross pay fr...

C# Any way to repeat this process twice using a loop?

Hi, I'm in my first OOP class, and I was wondering if there was any way to use a loop (for, while, do-while) do loop through the process below twice, but store the results of the second iteration through the loop in two new variables, and then create a second ComplexNumber object using those variable values from the second iteration? ...

C# using the "this" keyword in this situation?

Hi, I've completed a OOP course assignment where I design and code a Complex Number class. For extra credit, I can do the following: Add two complex numbers. The function will take one complex number object as a parameter and return a complex number object. When adding two complex numbers, the real part of the calling object is adde...

Binary tree search algorithm errors

I have a binary tree that I need to search through. I'm not searching for one specific node of the tree, but rather over every node of the tree to gain information about them. I have a simple recursive search right now, but every time it runs I get a stack overflow error. It's a full binary tree of depth 7... if (curDepth < 6 && !search...

Does anyone recognise this unfamiliar notation?

I have a question from a test in a Programming Languages class that is confusing me. Give a context-free grammar to generate the following language L = { aibjck | 0 <= i <= j <= i + k } I am completely unfamiliar with this notation. I cant seem to find anything in the book or my notes about it, and I have no idea how to query google f...

Lost in Multiple Fork(), Pipe() and Select()

Hello, Hope I can find some help here cause I'm starting to give up. Heads up as this is an homework assignment, hence why it might be stupid. Context: Have to program something which will be shell executed as such: logn [--tick n] cmd [args] [, cmd [args]]... Basically, it's a program that multiple programs simultanously. Constraint...

Algorithm to find the duplicate numbers in an array ---Fastest Way

Hi, I need the fastest and simple algorithm which finds the duplicate numbers in an array, also should be able to know the number of duplicates. Eg: if the array is {2,3,4,5,2,4,6,2,4,7,3,8,2} I should be able to know that there are four 2's, two 3's and three 4's. Thanks in advance. ...

Is there any java code for Othello

i would to like need the baisc Othello as this : 0 : 0 0 0 0 0 0 1 : 0 0 0 0 0 0 2 : 0 0 1 2 0 0 3 : 0 0 2 1 0 0 4 : 0 0 0 0 0 0 5 : 0 0 0 0 0 0 ...

How to inspect the stack using an ASM visitor?

I am attempting to use the Java byte code engineering library ASM to perform static analysis. I have the situation where I would like to inspect the variables being assigned to a field. I have MethodVisitor which implements the visitFieldInsn() method. I am specifically looking for the putfield command. That is no problem. The problem i...