homework

want to find maximum numbers from text file and want to assign the value for max number as 1 using java program

hi friends, I have text files with some numbers like 100 38963 27856 0 534 From this numbers i want to find maximum numbers and want to assign the value for max number as 1. From that i want to assign values to other numbers which is least.For example the first one want to give (38963/100)*100. I want to do all this...

bool function problem - always returns true ?

#include <iostream> #include <string> #include <algorithm> #include <cstdlib> #include <cstdio> using namespace std; static bool isanagram(string a, string b); int main(void) { int i,n,j,s; cin >> n; string a, b; cin >> a >> b; if(!isanagram(a,b)) cout << "False" << endl; else cout << "True" << endl; return...

Recursion paths from coordinate to coordinate

I'm working on a java assignment for a class and I'm unsure how to solve this problem. I don't want it completed for me, but get me started in the right direction. I'm mostly unsure of the recursive part of the program. I'm not very good at programming. problem: NorthEast paths are obtained from a two-dimensional grid ...

Simplest path between points

I have a list of points (x, y coordinates) and a list of connections between them. Examples: Points A B C D E Connections AB BC CE BD D E | | A-B-C Of course, there are many more points and connections than this... What I need to do is find out the simplest path between some of these points. For example, if I wanted to go to A,...

noob homework question window dimensions in java

I am a high school student taking cs106a at Stanford via video. For my current assignment I have to add GObjects and position them relative to the size of the window. I am currently trying to get the width of the window using the command int width = getWidth(); however width = 0 One thing that could be causing this: this is o...

how to make a queue from data in a file

here is what i have so far. the problem i am faceing is how do i find the number of elemets in the file so i can initialze the queue. Your suggestions will b most appritated. class FileHandler { BufferedReader data; DataInputStream in; public FileHandler(String fileName) { try { data = new BufferedReader(new FileReader(...

help for solving problems in a java rmi assignment

Hi, I want to write a client/server application with rmi and I want the client have the ability of running media player in the server’s system. Can you help me please? Can you show me the way in the code snippets please? ...

Find an algorithm in RBTREE in O(logn)

I need to find a data structure which I can do with the following actions: Build(S,k) - O(nlogn) Search(S,k) - O(logn) Insert(S,k) - O(logn) Delete(S,k) - O(logn) Decrease-Upto(s,k,d) - O(logn) - this method should subtract d(d>0) every node which is <=k The obvious first choise was RedBlackTree. However, I can't come to a solution ...

How do I read in a double in Java?

I am trying to get a decimal input from the keyboard, and it is just not working. First I tried double d = Integer.parseInt(JOptionPane.showInputDialog( "Please enter a number between 0 and 1:")); and that obviously didn't work very well. I am used to just parsing int's as they come in from the ke...

Define struct with one field in scheme

I am working on a homework assignment for a class. The problem statement says to use the data definition: (define-struct diff-exp exprs) (define-struct mult-exp exprs) ;; An Expr is one of ;; -- Number ;; -- (make-diff-exp (cons Expr LOExpr)) ;; -- (make-mult-exp (cons Expr LOExpr)) ;; Interpretation: a diff-exp represents a difference,...

Compare different search algorithms

In what ways are DFS and Best-first search similar? How are BFS and Best-first similar? To me, to better decribe how DFS and BestFS are similar, it might be easier to point the difference,which is that in BestFS we chose as the next to expand the one that seems closest to the goal using the heuristi function. In almost all other wa...

Illegal start of term in Prolog

Hi, I'm trying to write some predicates to solve the following task (learnprolognow.com) Suppose we are given a knowledge base with the following facts: tran(eins,one). tran(zwei,two). tran(drei,three). tran(vier,four). tran(fuenf,five). tran(sechs,six). tran(sieben,seven). tran(acht,eight). tran(neun,nine). Write a predicate listtra...

Need algorithm for Sequence calculation

Hi, I am trying to find the solution for a problem where i have something like A > B B > C B > D C > D And I should get the answer as A > B > C > D. Conditions for this problem The output will involve all the elements. The problem will not have any bogus inputs. for example, (A>B) (C>D) is a bogus input, since we cannot determine...

Dynamic programming algorithm N, K problem

An algorithm which will take two positive numbers N and K and calculate the biggest possible number we can get by transforming N into another number via removing K digits from N. For ex, let say we have N=12345 and K=3 so the biggest possible number we can get by removing 3 digits from N is 45 (other transformations would be 12, 15, 35...

How to calculate the number of longest common subsequences

Hi, I'm trying to calculate the amount of longest possible subsequences that exist between two strings. e.g. String X = "efgefg"; String Y = "efegf"; output: The Number of longest common sequences is: 3 (i.e.: efeg, efef, efgf - this doesn't need to be calculated by the algorithm, just shown here for demonstration) I've manag...

help for solving problems in a java rmi assignment

Hi I want to write a client/server application with java rmi, that the client has the ability to run the window media player in the server side. I have used the ProcessBuilder class like this: ProcessBuilder process= new ProcessBuilder(“mwplayer”).start(); but it doesn’t work. It cause these exceptions: java.io.IOException: Cannot ru...

how to read and extract an integer from a string in java

Given a string 7 + 45 * 65 How to check whether a given character of this string is an integer and then store the whole integer value in an integer variable? E.g. for 65, check if 6 is an integer, if yes, then store 65 in another integer variable. You can assume that the string can be converted into a character array. ...

autodecrement in number using c#

How do I autodecrement the number of students allowed everytime you assign a section to each student added? I have the code, but it has an error. private void btnAssign_Click(object sender, EventArgs e) { ////for auto increment ds = DBConn.getStudentDetails("sp_Retrieve_Student_Section"); int cnt = ds....

Proving and Disproving BigO

In proving and disproving Big O questions that explicitly say use the definition to prove and disprove, my question is, is what I am doing correct? For example you have a question that is g(n) = O(f(n)) ... In order to prove it I was doing the following g(n) <= C(F(n)) g(n)/F(n) <= C .. then give n=1 and solve for C , which proves it. ...

Clarification on Masking Bits

I have a quick question about masking bits. If I want to turn two 8 bit streams on, do I use the AND logic against the two: 10101010 AND 01101001 ________ 00101000 or do I actually change one of the bits in the stream to turn the bits on? I guess my question is when I'm turning on (using AND) or turning off (using OR)...