homework

Overwriting lines in file in C

Hi, I'm doing a project on filesystems on a university operating systems course, my C program should simulate a simple filesystem in a human-readable file, so the file should be based on lines, a line will be a "sector". I've learned, that lines must be of the same length to be overwritten, so I'll pad them with ascii zeroes till the en...

What is the most efficient way to determine if a directed graph is singly connected?

I am working on an assignment where one of the problems asks to derive an algorithm to check if a directed graph G=(V,E) is singly connected (there is at most one simple path from u to v for all distinct vertices u,v of V. Of course you can brute force check it, which is what I'm doing right now, but I want to know if there's a more eff...

deriving regular expressions from a regular language

Given the language below, how do i find a regular expression for the language L = {a ^n b ^m | n => 1, m =>1, nm =>3} ...

how to run/compile java code from JTextArea at Runtime? ----urgent!!! college project

I have a JInternalFrame painted with a BufferedImage and contained in the JDesktopPane of a JFrame.I also have a JTextArea where i want to write some java code (function) that takes the current JInternalFrame's painted BufferedImage as an input and after doing some manipulation on this input it returns another manipulated BufferedImage t...

SwingWorker in Java (beginner question)

I am relatively new to multi-threading and want to execute a background task using a Swingworker thread - the method that is called does not actually return anything but I would like to be notified when it has completed. From all the tutorials that I have seen online about using SwingWorkers are created such as new SwingWorker<String, ...

Event Handlers Not Getting Called? - wxWidgets

Hello all, I'm working on a program for my C++ programming class, using wxWidgets. I'm having a huge problem in that my event handlers (I assume) are not getting called, because when I click on the button to trigger the event, nothing happens. My question is: Can you help me find the problem and explain why they would not be getting cal...

how to fix my error saying expected expression before 'else'

This program is intended to read a .txt file to get a set of numbers, and write to another two .txt files called even and odd as follows: #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int i=0,even,odd; int number[i]; // check to make sure that all the file names are entered if (argc != 3) { prin...

How can I find the Nth largest value without using Perl's sort()?

I have written following code in Perl: #!/usr/bin/perl @array = (3,6,8,1,2); my $second_largest = 0; my $largest = 0; for (@array) { if($_ > $largest) { $second_largest = $largest; $largest = $_; } if($_ > $second_largest && $_ < $largest) { $second_largest = $_; } } print "Second largest::".$s...

comparison of sorting algorithms

When do we prefer a) bucket sort, and b) radix sort over comparison sorts like bubble sort insertion sort selection sort merge sort quick sort? ...

Read in double type from txt file - C++

Hi there I'm in the midst of a university project and have decided to implement a method that can accept information from a text file (in this instance called "locations.txt"). input from the text file will look like this: London 345 456 Madrid 234 345 Beinjing 345 456 Frankfurt 456 567 The function looks like this currently (and you...

Use of iterators over array indices.

Hello all, I just wanted to know what is the main advantage of using the iterators over the array indices. I have googled but i am not getting the right answer. ...

trying to find a web service

i am trying to find a web service that allows a user to send a company name (or better still will return a list of all company names, thus allowing the user to select one) and then get the share price, this will then feed in to another api - yahoo currency converter to work out the price of the share the issue i am having is that i cann...

[MATH]Project an axis to a plane

how do i project the X axis to a plane if the plane is defined by three points? see pic here: http://129.25.16.135:2080/v6.5/books/usb/graphics/iconventions-local-surfaces.png The default local 1-direction is the projection of the global x-axis onto the surface. If the global x-axis is within 0.1° of being normal to the surface, the loc...

Java: How to have an ArrayList as instance variable of an object?

All, I'm working on a class project to build a little Connect4 game in Java. My current thinking is to have a class of Columns that have as instance variable a few integers (index, max. length, isFull?) and one ArrayList to receive both the integers above and the plays of each players (e.g., 1's and 0's standing for X's and O's). This...

Help Understanding Big O

I am trying to find a good explanation to quickly understand Big O and Theta theory. I always feel an explanation can be given in a million different ways, and I guess I'm seeking that one explanation that finally makes sense. I know this is a n00b question but any help would be appreciated... ...

how to identify the n,i,x, and e bit settings(SIC/XE)?

I have a project for my System Software class, we have to produce a subroutine to decompose a line of source into 4 components: label, op code, operand1, and operand2, and identify the n,i,x and e bit settings. I'm having a problem trying to figure out the nixbpe bit. thank you in advance for your help here are some examples: Compon...

Iterative and incremental development - difference at all?

Are Iterative and incremental software development models the same premise, just known as two different things? ...

Scheme homework help

Okay so I have started a new language in class. We are learning Scheme and i'm not sure on how to do it. When I say learning a new language, I mean thrown a homework and told to figure it out. A couple of them have got me stumped. My first problem is: Write a Scheme function that returns true (the Boolean constant #t) ifthe parameter i...

Queues and the term 'Count' - What Does Count Do Exactly Again?

I know 'dequeue' and 'enqueue' for Queues (remove and add respectively), but what is 'count'? Does that return the total number of items in the Queue, or only the top item in the queue? I think I may be getting 'count' confused with the 'peek' used in Stacks - which returns the latest node at the top of the stack. ...

Avoiding RTTI In Java

Hi, If I have a superclass, say Animal, and two subclasses: Zebra and Giraffe, If I decide to define a Vector of Animals: Vector <Animal> animals = new Vector(); and I want to say: You can add Giraffes, but you must own at least one Zebra first. What is the best way to do this without using RTTI? (instanceof) ...