homework

Clojure: How to generate a 'trie'?

Given the following... (def inTree '((1 2) (1 2 3) (1 2 4 5 9) (1 2 4 10 15) (1 2 4 20 25))) How would you transform it to this trie? (def outTrie '(1 (2 () (3 ()) (4 (5 (9 ())) (10 (15 ())) (20 (25 ())))))) ...

Lock-Free, Wait-Free and Wait-freedom algorithms for non-blocking multi-thread synchronization.

In multi thread programming we can find different terms for data transfer synchronization between two or more threads/tasks. When exactly we can say that some algorithm is: 1)Lock-Free 2)Wait-Free 3)Wait-Freedom I understand what means Lock-free but when we can say that some synchronization algorithm is Wait-Free or Wait-Freedom? I ...

I need to search for a "customer" in a db, what would be a good design here?

Hi! We're a couple of students trying to implement a design to search for customer-information in a database. When the GUI-class is asking for any customer with the surname "Jensen", would a customer-class then create many objects for each customer with that surname, give all those objects to the GUI-class, let the GUI-class e.g change s...

c++ constructers and destructers

hi guys, i have got all but one last instance. here's my code: void main() { Animal bozo("Bozo", 408, 400); // name, cagenumber, weight cout << "This animal's name is " << bozo.getName() << endl; bozo.destroy(); } i've declared the class for Animal and functions like name, cageno and weight. as t...

Which programming language is more suitable for socket programming?

I will have a cloud computing class this semester, and one of the requirements about the course to know about socket programming. First thing that I came up in my mind for this question was Java. I know Java has a strong socket programming library; but I anyway want to ask your opinion. What do you guys think? ...

Convert kilobytes to bytes in PHP

Hi, how can I convert kilobytes to bytes in php? Let's say I get the value 22.2 kb and I want to return this in bytes. Thanks, Max ...

get every combination of strings

I had a combinatorics assignment that involved getting every word with length less than or equal to 6 from a specific combination of strings. In this case, it was S = { 'a', 'ab', 'ba' }. The professor just started listing them off, but I thought it would be easier solved with a program. The only problem is that I can't get a good alg...

Interval Function

I need to write a function that returns a value within an interval [a..b] after applying a delta. void foo(a, b, val, delta); Example1: value = foo(0, 360, 120, -240); value: 240 Example 2: value = foo(360, 0, 60, 340); value: 40 I have been able to code this behavior but I would like to compare my implementation with a (most likely)...

How to develop random Analysis Programme?

How to develop random Analysis Programme for selecting students for addmissions in 1st standard among 700 students distributing 24% to general, 11% to SC 5% to St,0.5% to PH? ...

Snap point to a line - Java

Hi, I have two gps coordinates which link together to make a line. I also have a gps point which is near to, but never exactly on, the line. My question is how do I find the nearest point along the line to the given point? Many thanks ...

Calculate net mask and subnet address from broadcast and address inside subnet

Hi, i'm need to calculate net mask and subnet addr using broadcast addr and host address from this subnet. I must use only bitwise operations not comparing of string representation, sysadmin tools and so on. I have some formulas for calculating addresses. but i dont know, how using it with my source data. ^ -- is bitwise xor ~ -- ne...

Verbose list comprehension in Python

I have a list of integers and I want to create a new list with all elements smaller than a given limit. a=range(15) #example list limit=9 #example limit My approach to solve this problem was [i for i in a if i < limit] To me the beginning 'i for i in' looks pretty verbose. Is there a better implementation in Python? ...

error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'Rectangle' (or there is no acceptable conversion)

im required to write a function to overload the ==operator to compare width, height and colour. i need to return 'Y' if its equal and 'N' if its not. this is my code which i think its correct but keeps getting the error in the title. i've done searches and nothing came close to comparing 3 data as most examples are for comparing 2 da...

How to prove by induction that a program does something?

I have a computer program that reads in an array of chars that operands and operators written in postfix notation. The program then scans through the array works out the result by using a stack as shown : get next char in array until there are no more if char is operand push operand into stack if char is operator a = pop from stack ...

How do I create a list in Oz?

I'm trying to create a list in Oz using the following code: local Loop10 Xs in proc {Loop10 I} Xs={List.append Xs I} if I == 10 then skip else {Browse I} {Loop10 I+1} end {Browse Xs} end {Loop10 0} end The Mozart compiler shows that the code is accepted, but no Browse window opens up. All ...

What is a stack pointer used for in microprocessors?

I am preparing for a microprocessor exam. If the use of a program counter is to hold the address of the next instruction, what is use of stack pointer? ...

How to write a SQL Query for the following

I have 3 tables Teams, Players and TxP Teams table has the columns TeamName and TeamID(Primary Key) Players table has the columns PlayerName and PlayerID(Primary Key) TxP table has the columns PlayerID, TeamID I would like to write a query to get the result set as PlayerName, TeamName ...

Converting array characters in C Programming

why do I get a from the console with the following code? char array1[] = "Hello World"; char ch = array1; printf(" %s" , ch); (we are instructed not to do this with a pointer....) ...

Converting Letters to Numbers in C

Hello, I'm trying to write a code that would convert letters into numbers. For example A ==> 0 B ==> 1 C ==> 2 and so on. Im thinking of writing 26 if statements. I'm wondering if there's a better way to do this... Thank you! ...

how to manage a compiler project ?

I am a CS student and I have a compiler project this year. I want to know how to manage my project with my three partners. I know that the compiler has many level and process, and I want to make use of these features to mange my project. Thanks for any tips/pointers/resources you can provide for me to start. ...