homework

Computer science final year project ideas

I'm a Computer Science undergraduate student in UK and should be deciding the subject of my final year project soon. The school is pretty flexible with the subject... "The topic can be any area of the subject which is of mutual interest to both the student and supervisor. Topics can range from purely theoretical studies to practical wor...

Bubble Sort Homework

In class we are doing sorting algorithms and, although I understand them fine when talking about them and writing pseudocode, I am having problems writing actual code for them. This is my attempt in Python: mylist = [12, 5, 13, 8, 9, 65] def bubble(badList): length = len(badList) - 1 unsorted = True while unsorted: f...

How do I determine the standard deviation (stddev) of a set of values?

I need to know if a number compared to a set of numbers is outside of 1 stddev from the mean, etc.. ...

adding all files name from a specific folder

Like there is a folder say XYZ , whcih contain files with diffrent diffrent format let say .txt file, excel file, .py file etc. i want to display in the output all file name using Python programming ...

How to properly wait for foreground/background processes in my own shell in C?

In this previous question I posted most of my own shell code. My next step is to implement foreground and background process execution and properly wait for them to terminate so they don't stay as "zombies". Before adding the possibility to run them in the background, all processes were running in the foreground. And for that, I simply ...

functional and non-functional requirments ?

Hi. I found this case of study here about a game. I am studying a software engineering course, and we learned about the functional and non-functional requirements but what could be possible requirements? Any ideas ? the document is here Video Games and Software Engineering: A Case Study. ...

Implementing a chat server as a WebService

I have a school project in which I have to implement a chat application, who's server will be a java web service. The problem is that I've always thought of a web service as a way of calling remote functions, and I have no idea how to keep a "session" active on the web service, nor how to keep track of all the people currently in chat, r...

Singleton pattern - doubt in Head First Design Patterns book

Hi all, On page 175, there is an example of Chocolate Boiler class. Something like this: public class ChocolateBoiler { private boolean empty; private boolean boiled; public ChocolateBoiler { empty = true; boiled = false; } // and then three methods to fill, drain and boil which changes the // status...

algorithm for calculating the sum of value in the Array and Big O Notation

How to find an algorithm for calculating the sum value in the array?? Is is Something like this? Algorithm Array Sum Input: nonnegative integer N, and array A[1],A[2],...,A[N] Output: sum of the N integers in array A Algorith Body: j:=1 sum:=0 while j<N sum := sum + a[J] j:=j+1 end while end Algorithm Array Sum And how ...

MATLAB: Extract multiple parts of a matrix without using loops

Hi, I have a huge 2D matrix and I would like to extract 15 different 100x100 parts out of it. I have two vectors x and y where the top left indices of the parts are saved. I have used something like this: result = cam1(x(1:end):(x(1:end)+99), y(1:end):(y(1:end)+99)); but the result is just a 100x100 matrix instead of a 15x100x100. Wh...

Is this a full binary tree?

Hi, Here's the binary tree in question, poor quality image I know but hopefully it's legible. The leaves are a,b,c,d and the edges are labelled 0 or 1. EDIT: Transcripted tree . / \ a . / \ b . / \ c d It seems to me that it is a full binary tree, as every node is either a leaf or has two child ...

How to define class-specific << operator in C++

Given a class such as: class Person { private: char *name; public: Person() { name = new char[20]; } ~Person() { delete [] name; } } I want to print to print the name from an instance of this, using a statement like the following: cout << myPerson << endl; What do I need to do to define ...

Will someone help me understand logic?

Ok so I have to prove the following sequent: (p -> r) ^ (q -> r) |- p ^ q -> r I understand why that is clearly correct and I also understand the rules of natural deduction. What I don't understand is how I go about proving it. Here is the model answer provided: 1. (p -> r) ^ (q -> r) |- p ^ q -> r premise 2. p ^ q ...

Average instruction time

Lets say we have an average of one page fault every 20,000,000 instructions, a normal instruction takes 2 nanoseconds, and a page fault causes the instruction to take an additional 10 milliseconds. What is the average instruction time, taking page faults into account? ...

Creating Makefile in Windows

I have a folder named 'X'. In X I have two subfolders named 'src' and 'include'. The 'src' folder contains a C file 'main.c', and the 'include' folder contains a file 'main.h'. I want to write a makefile to build these files(from folder X) in windows command prompt. I have tried a lot but with no effect. First of all I need the make fi...

How to combine two FORs into one

This might be stupid, but I'm want to know if it's possible, lets start with 5x5 a matrix int[][] x = new int[5][5]; Random rg = new Random(); now let's fill it with Pseudo Random information for(int i=0;i<5;i++){ for(int j =0; j<5;j++){ x[i][j] = rg.nextInt(); } } but how can I do this right with one Single ...

Intersection of a line and a Sphere?

I have a simple object that allows you to assign three properties (x,y,z) (lets call this object a "point", because that is what it is). I then have a second object with a method that accepts two instances of the first object, and returns the distance between the two "points" in three dimensional space. i also need a method that will a...

How could this C fragment be written more safely?

Hi, I have the following C code fragment and have to identify the error and suggest a way of writing it more safely: char somestring[] = "Send money!\n"; char *copy; copy = (char *) malloc(strlen(somestring)); strcpy(copy, somestring); printf(copy); So the error is that strlen ignores the trailing '\0' of a string and therefore it ...

What kind of problems may occur when executing a JSP page?

Hi, So I have an example question as follows: Explain how a JSP page is executed and what kind of problems may occur. I'm fine with the first part, compile the static html and the scriptlets to java to be served by the servlet etc. But I'm stumped by what problems may occur? The JSP page is held in memory... so maybe that may exhau...

EJB - confused about Home/Remote -- LocalHome/Local interfaces

Revising some past exam papers for an exam mainly focus on component-oriented design and J2EE, I have come across the following question: A preliminary investigation of scenario 3: “Exchange Request” suggests that two EJBs will provide a suitable solution: a session bean called EnterExchangeRequest to control the processing and an entit...