homework

Java Question Linked List objects

I have the following piece of code : Essentially the number of methods should remain the same as in the code and I need to extract a string from an element of the linkedlist of Objects of type emp_struct.. How do I do it? import java.util.*; import java.io.*; class a1 { static LinkedList l1; private emp_struct input() throws I...

Permanent DOS Attacks - Anyone Knowledgeable?

So, I'm looking into Permanent DOS attacks for a class, and I'm having a hard time coming up with concrete examples. There's a lot of information about Phlashing (flashing firmware to either brick the device, or put malicious firmware in its place, for those of you who don't know the term) but I'd like to have a broader set of examples. ...

A potential multi-agent system?

For an assignment I have to make a multi-agent system (very open ended, but a short project), something like predator/prey or traffic simulation? It will be written in Jason/Agent speak. I am at a loss for ideas as to what to actually implement (what is feasible?), as it can be anything, the more bizarre the better! ...

Finding if two elements in a pre-sorted array sum to equal a certain value

I'm working on a homework problem and I'm having some difficulties creating a O(n*logn) solution. I need to write a function that takes a pre-sorted array and a value to search for. I then need to find if any two elements of the array sum to equal that value. I need to create both O(n) and O(n*logn) algorithms for this. The O(n) w...

Rounding with static_cast<int> ?

Hi, I feel really silly asking this because I know how to do it 101 ways, but not the way it is defined in the book. (note, I know C++) So far, we have only gone over the very basics of C++. So basically, we know variables, assignment, and basic casting. In the book I am having trouble with this portion of the problem: prompt the us...

How do you stack buttons vertically on a JOptionPane with JDialogs?

Hello, I'm trying to stack three buttons vertically onto a JOptionPane using createDialog, but it's not quite working with a GridLayout. Also, I'm not sure how to get rid of the 'OK' button as well. You're probably wondering why I am doing it this way, but this is the way I was told to do it. I think I can use a JFrame, but I don't think...

Python Dictionary Binary Search Tree

I am struggling to get to know how to code a basic implementation using a dictionary and in-order traversal binary search tree in Python. The class have to be using the below structure. I would be very happy if someone could fill out the blanks (pass) in each function to get me started. class Dictionary: def __init__ (self): ...

How do I load an image file in Matlab?

I have to use Matlab to read a picture and make a joint histogram and I'm new to Matlab. When I try to read the Image by using imread function it does not work. h= imread('a.tif'); ??? Error using ==> imread at 363 File "a.tif" does not exist. Can anyone help me figure out this problem? ...

Cheapest path algorithm

I've learnt a dynamic programming algorithm to find the "cheapest" path from A to B. Each sub path has an associated cost. Each corner is calculated using D(i,j).value = min( (D(i-1,j).value + D(i,j).x), (D(i,j-1).value + D(i,j).y)) Where x and y are the costs of the path on the left of the node and below the node. I'm now having trou...

Algorithm for finding intervals inside an array

Hello, I have a list which contains n intervals [0,1] each interval looks like [a(i),b(i)] 0<=a(i)<b(i)<=1 , i = 1...n I need to find an efficient algo determining for each of the n intervals if it's contained inside other intervals. I tried many option but i can only find one in O(n^2) Any suggestions ? ...

Using the prompt for integers in assembly language

Hi by using the strings promptl BYTE "Enter a signed integer: ",0 prompt2 BYTE "The sum of the integers is: ",0 will It prompt a user for two integers using assembly language and how do I add the two integers using Assembly language? ...

Calculate cost of a phone call in SQL

Q1: A: There are two tables in a telecom SQL Server database – Customers and Rates as shown below: Customers PK CustomerPhoneNumber varchar(15) CustomerType int -the type of customer Rates FK CustomerType int - the type of customer CountryCode varchar(4) – th...

Struggling to use calloc and realloc to initialize arrays in C.

Hello, I'm struggling to use calloc and realloc for my array initializations. I'm trying to write a program which calculates a final sum from the command line arguments using fork() with a companion program. If I receive a odd set of integers from the command line such as: ./program 1 2 3 4 5. It should see that amount is odd and ini...

Help in a simple homework exercise

Hi. I need to create a method, in the following signature: int x (int y); That's the example of values that this it should return: x(3) = 1 x(4) = 1 x(5) = 2 x(6) = 2 x(7) = 3 x(8) = 3 x(9) = 4 x(10) = 4 ... Any ideas how could I do it? Thank you. EDIT: That's what I've got so far: static int x(int y) { return (y...

Bad Pointer? - C++

Hi there, I'm writing a string tokenization program for a homework assignment in C++, that uses pointers. However, when I run & debug it, it says that my pointer pStart, is invalid. I have a feeling that my problem resides in my param'ed constructor, I've included both the constructor and the object creation below. I would appreciate it...

Looking for poorly optimized code

Hello, I posted this on daniweb, but have revised my thoughts on the matter. Basically my 'Integrated Software Systems' class midterm is to take some code (either you wrote or someone else's) and optimize it. I thought to myself why not use this opportunity to enrich the open source community, I know it's really going to only be a fu...

Counting the Number of keywords in a dictionary in python

I have a list of words in a dictionary with the value = the repetition of the keyword but I only want a list of distinct words so i wanted to count the number of keywords. Is there a to count the number of keywords or is there another way I should look for distinct words? ...

How do you use a void pointer to generate 2D dynamic Array?

Does anyone know how to use a void pointer to generate a 2D array rather than an int pointer? For integer pointer, I do as follow: int **m; m = new int* [row]; for(int i=0; i< row; i++) m[i] = new int[col]; for (int i = 0; i < row; i++) for (int j = 0; j < col; j++) m[i][j] = rand () % 10; What...

How to do a non destructive queue examination in Java

Hello, I am helping my son with a college programming class, and I guess I need the class too. He has completed the assignment, but I don't believe he is doing it the best way. Unfortunately I can't get it to work with my better way. It's clearly better, because it doesn't work yet. He is being asked to implement some methods for a ...

Finding an appropriate data structure

Hello, I have N keys. I need to find a data structure which i can do with the following operations : building it in O(N) finding min in O(1) deleting the median in O(logn) finding the n/2+7-th biggest number I thought about using a minimum heap (building is O(n),minimum is O(1) - root). however, I'm having hard time finding a way...