homework

Dynamic Allocation of Memory

How malloc call managed by user-library. I need the explanation of "How memory is being allocated in user space when malloc is called. Who manage it. Like sbrk() is called to enter in kernel space". ...

merge sort without extra memory

is there any condition in which merge sort can be done without extra memory my prof said it has and he will give bonus point on that. ...

Will public access modifiers limits flexibility in changing code?If so give some examples..

Will public access modifiers limits flexibility in changing code?If so give some examples.. ...

Basic animation in Java for a screensaver app of sorts

I was assigned to make an animated screensaver as a programming project for my Advanced Programming course. The objective is to have several moving components inside an undecorated, fullscreen frame, but I'm going step-by-step and doing it one component at a time. Here's my source code so far: http://pastebin.com/dc722188 Feel free to...

Abstract Factory Question

Hello, I am trying to understand the Abstract Factory design pattern. I am having a lot of trouble with it. I am trying to use the following example to develop a UML class diagram: Car designers can design many different types of cars. Cars can have two doors, or they can have four doors. Cars can be four-wheel drive, or they can be tw...

How to execute external programs from qmake?

I am trying run a program from a qmake .pro file which modifies the final binary. I have already tried system(...) but it does not work. The reason I want this is because by default some properties of the binary prevent debugging and it is inconvenient to do it manually every time. I can do this from simple makefiles. Here is my .pro fi...

Accessor and Mutator Methods confusion

OK, basically the question was Accessor and Mutator Methods Suppose that the class Pet has a variable/field called name that is of type String> Write an accessor method getName() that returns the value of name Enter your answer in this box and I wrote the code as following: public getName(String name) { return...

Modifying variable value from method

Hi, was wondering where im going wrong, any ideas? Modifying variable value from method Implement a method empty() in the TicketMachine class that simulates the effect of removing all money from the machine It should have a void return type and the body should simply set the total variable/field to zero. Does this method need any pa...

Calculating average in interchangable range?

I know it's because of n, but n is supposed to be any variable, and left as n, this is what I have: def average(n): if n >= 0: avg = sum((range(1:int(n)))/float(len(range(1:int(n))))) print avg how do I fix it? ...

Confused on this question

Revision of mutator method definition Write a mutator method setAge() that takes a single parameter of type int and sets the value of variable age Paste your answer in here: public int setAge(int age) { return age; } Comments: * Test 1 (0.0 out of 1) The compilation was successful The output should have been: ...

Mutator returning a value

Mutator returning a value Add a new method emptyMachine() to the TicketMachine class that is designed to simulate emptying the machine of money It should both return the value in total and reset the value of total to zero. Paste the whole method into the space below public int emptyMachine() { System.out.println("# " + tota...

little help, bit confused

Correct the following erroneous definition of method getAge() public void getAge() { return age; } Paste your answer in here: public int getAge(int age) { return age; } Mark: 0 out of 1 Comments: * Test 1 (0.0 out of 1) Person.java:15: getAge(int) in Person cannot be applied to () String s = (p.getAge(...

changing a program in c, so it takes an optional command line argument *infile*

Now I do have a hw question for everyone...I've been staring at this for a couple of days kind of tinkering and playing around but even with that I end up with a load of errors... What I'm trying to do is take the program below and change it so that it takes an optional command line argument infile. If infile is given, then copy infile ...

Last day same week as first day

Hey All, What's the easiest way to determine if the last day of the year falls in the same week as the first day of the next year? Thanks, ...

Unable to find solution for a practice problem in codechef

Here is the problem from code chef : A set of N dignitaries have arrived in close succession at Delhi and are awaiting transportation to Roorkee to participate in the inaugural ceremony of Cognizance. Being big sponsors of Cognizance, it has been deemed unsuitable by the organizing team to arrange for more than one dignitary to travel ...

Simple if statement in Java

How do i write an if statement in Java that displays Goodbye! if the variable word contains a letter d? Thanks to everyone. ...

Circular Array C++

Hello, The code below is my own implementation a push_front method for my items array. I was wondering if someone could help me figure out how to implement the method so that i am just moving the indexes up or down. I need my items to stay in the array, rather then dumping them into a "front" varaible: stack::stack(int capacity) : item...

Palindrome Question

I had a question regarding a basic program I was writing said whether a word such as racecar is a palindrome or not. All my methods which reverse the string, strip the punctuation work but the one that determines if it is a palindrome does not. /** * Determines if a series of letters makes a palinedrome * * @param str All punctuat...

Finding the highest 2 numbers- computer science

I'm trying to figure out an algorithm to find the highest 2 numbers in a list of numbers. The highest number can be found in n-1 stages, perhaps by doing the fist step of a bubble sort or something along those lines. To me it seems that finding the next highest number as well could be found in a total of 1.5n comparisons on average. ...

Is there any mistake in this Java code?

class Creature { private int yearOfBirth=10; public void setYearOfBirth(int year) { yearOfBirth = year; } void setYearOfBirth(Creature other) { yearOfBirth = other.yearOfBirth; // is this correct it compiles fine } int getYearOfBirth() { return yearOfBirth; } public static void main(S...