# Search Results

• ### Homework with allocate subnet IP address

##### - by Don Lun
I'm having difficulty solving a subnet allocation homework problem. Assume that a university has an address block 128.205.224.0/19. It has to allocate addresses for 2 departments' networks, each of size 1800, and for 4 offices, of sizes 550, 600, 650, and 750 nodes respectively. Assuming that the university network allocates addresses sequentially from the beginning of the allocated allocated address space, what are the prefix allocations for these subnetworks? I first thought in this way: There should be 6 subnets in the network. So I need 3 bits for the subnets. So 3 + 19 = 22 bits should be the network bits. Then there are only 10 bits left. 2^10 = 1024 < 1800, so this cannot work. Could you guys give me a hint or some thoughts for solving this problem?

• ### Help understanding Reverse Polish Notation for homework assignment?

##### - by Yassin
I have been asked to write a simple Reverse Polish Notation calculator in C as part of a homework assignment. I'm having difficulty understanding RPN. Can you please help me understand Reverse Polish Notation? Also, any tips on how to approach this problem would be greatly appreciated.

• ### Scheme homework help

##### - by John
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 is a list containing n a's followed by n b's. and false otherwise. Here's what I have right now: (define aequalb (lamda (list) (let ((head (car list)) (tail(cdr list))) (if(= 'a head) ((let ((count (count + 1))) (let (( newTail (aequalb tail)))) #f (if(= 'b head) ((let ((count (count - 1))) (let (( newTail (aequalb tail)))) #f (if(null? tail) (if(= count 0) #t #f))))))))))) I know this is completely wrong, but I've been trying so please take it easy on me. Any help would be much appreciated.

• ### parsing a list and producing a structure of that

##### - by qzar
;; structure representing homework points ;; nr: number - the number of the homework ;; points: number - the number of points reached (define-struct homework (nr points)) ;; parse-homework: (list of number pairs) -> (list of homework) ;; The procedure takes a list of number pairs and produces a list of homework structures ;; Example: (parse-homework (list (list 1 6) (list 2 7) (list 3 0))) should produce (list (make-homework 1 6) (make-homework 2 7) (make-homework 3 0)) (define (parse-homework homework-entries) (if (and (= (length (first homework-entries) 2))(= (length (parse-homework (rest homework-entries)) 2))) (make-homework (first homework-entries) (parse-homework (rest homework-entries))) (error 'Non-valid-input "entered list is not of length two")) ) (parse-homework (list (list 1 6) (list 2 7) (list 3 0))) This code produces the error length: expects 1 argument, given 2: (list 1 6) 2 I really appreciate every explanation that you can give me to get in in this scheme-stuff... Thank you very much

• ### Scheme homework problem, need help.

##### - by poorStudent
Okay one of my homework problems is to take a list of lists and return the car of each sublist as a list. I have it to where I can print out the values, but it's not a list. To be honest, I have no clue how to output lists. Here's what I got: (define (car-print alist) (if (null? alist) (newline) (begin (write (car (car alist))) (display " ") (car-print(cdr alist))))) This is a cheap way to do it, perhaps some help on actually solving this problem would be much appreciated. Not necessarily the full answer but steps to get there. Thanks.

• ### Code refactoring homework?

##### - by Hira
This is the code that I have to refactor for my homework: if (state == TEXAS) { rate = TX_RATE; amt = base * TX_RATE; calc = 2 * basis(amt) + extra(amt) * 1.05; } else if ((state == OHIO) || (state == MAINE)) { rate = (state == OHIO) ? OH_RATE : MN_RATE; amt = base * rate; calc = 2 * basis(amt) + extra(amt) * 1.05; if (state == OHIO) points = 2; } else { rate = 1; amt = base; calc = 2 * basis(amt) + extra(amt) * 1.05; } I have done something like this if (state == TEXAS) { rate = TX_RATE; calculation(rate); } else if ((state == OHIO) || (state == MAINE)) { rate = (state == OHIO) ? OH_RATE : MN_RATE; calculation(rate); if (state == OHIO) points = 2; } else { rate = 1; calculation(rate); } function calculation(rate) { amt = base * rate; calc = 2 * basis(amt) + extra(amt) * 1.05; } How could I have done better? Edit i have done code edit amt = base * rate;

• ### C# Homework - control structures (for, if)

##### - by Freakingout
I got a homework assignment today: "Create a program that calculates out how many ways you can add three numbers so that they equal 1000." I think this code should work, but it doesn't write out anything. using System; namespace ConsoleApp02 { class Program { public static void Main(string[] args) { for(int a = 0; a < 1000; a++) { for(int b = 0; b < 1000; b++) { for(int c = 0; c < 1000; c++) { for(int puls = a + b + c; puls < 1000; puls++) { if(puls == 1000) { Console.WriteLine("{0} + {1} + {2} = 1000", a, b, c); } } } } } Console.ReadKey(true); } } } What am I doing wrong? Any tips or solution?

• ### Unix [Homework]: Get a list of /home/user/ directories in /etc/passwd

##### - by KChaloux
I'm very new to Unix, and currently taking a class learning the basics of the system and its commands. I'm looking for a single command line to list off all of the user home directories in alphabetical order from the /etc/passwd directory. This applies only to the home directories, and not the contents within them. There should be no duplicate entries. I've tried many permutations of commands such as the following: sort -d | find /etc/passwd /home/* -type -d | uniq | less I've tried using -path, -name, removing -type, using -prune, and changing the search pattern to things like /home/*/\$, but haven't gotten good results once. At best I can get a list of my own directory (complete with every directory inside it, which is bad), and the directories of the other students on the server (without the contained directories, which is good). I just can't get it to display the /home/user directories and nothing else for my own account. Many thanks in advance.

• ### [Homework] Online programming editor

##### - by VDVLeon
Hi, For a school project i need to write or use a online programming editor. It is a part of a bigger project. I thought of a java application, php/html/javascript or flash. I have a couple of things i could do: Find a good working application and edit it so it works with the rest of the project Find good parts for a editor and make it working my self (syntax highlighter, auto-indent, autocompletion, etc.) Combination of those two Does anybody know a good editor or have tips for this project or a editor? Thanks for reading, Leon

• ### sequential search homework question

##### - by Phenom
Consider a disk file containing 100 records a. How many comparisons would be required on the average to find a record using sequential search, if the record is known to be in the file? I figured out that this is 100/2 = 50. b. If the record has a 68% probability of being in the file, how many comparisons are required on average? This is the part I'm having trouble with. At first I thought it was 68% * 50, but then realized that was wrong after thinking about it. Then I thought it was (100% - 68%) * 50, but I still feel that that is wrong. Any hints?

• ### Scheme homework Black jack help....

##### - by octavio
So I need to do a game of blackjack simulator, butt can't seem to figure out whats wrong with the shuffle it's suppose to take a card randomly from the pack the put it on top of the pack. The delete it from the rest. so : (ace)(2)(3)(4)(5)...(k) if random card is let say 5 (5)(ace)(2)(3)(4)(5)...(k) then it deletes the 2nd 5 (5)(ace)(2)(3)(4)(6)...(k) here is the code: (define deck '((A . C) (2 . C) (3 . C) (4 . C) (5 . C) (6 . C) (7 . C) (8 . C) (9 . C) (10 . C) (V . C) (Q . C) (K . C))) ;auxilliary function for shuffle let you randomly select a card. (define shuffAux (lambda (t) (define cardR (lambda (t) (list-ref t (random 13)))) (cardR t))) ;auxilliary function used to remove the card after the car to prevent you from removing the randomly selected from the car(begining of the deck). (define (removeDupC card deck) (delete card (cdr deck)) ) (define shuffle2ndtry (lambda (deck seed) (define do-shuffle (lambda (deck seed) (if (> seed 0)( (cons (shuffAux deck) deck) (removeDupC (car deck) deck) (- 1 seed)) (write deck) ) ) ) (do-shuffle deck seed))) (define (shuffle deck seed) (define cards (cons (shuffAux deck) deck)) (write cards) (case (> seed 0) [(#t) (removeDupC (car cards) (cdr cards)) (shuffle cards (- seed 1))] [(#f) (write cards)])) (define random (let ((seed 0) (a 3141592653) (c 2718281829) (m (expt 2 35))) (lambda (limit) (cond ((and (integer? limit)) (set! seed (modulo (+ (* seed a) c) m)) (quotient (* seed limit) m)) (else (/ (* limit (random 34359738368)) 34359738368)))))) ;function in which you can delete an element from the list. (define delete (lambda (item list) (cond ((equal? item (car list)) (cdr list)) (else (cons (car list) (delete item (cdr list))))))) (

• ### Probability Homework Help

##### - by Alon
A child is tasting two types of chocolate. The probability that he will like the first type if he liked the second type is 5/6. The probability that he will like the second type if he liked the first type is 3/8. It is known that the probability that the child won't like the second type of chocolate is doubled than the probability that he won't like the first type. What is the probability that the child like at least one of the two type of chocolates? So I tried: 1-[P(not like the first type AND not like the second type)] which is like: 1-[P(not like the first type)*P(not like first type / not like the second type) + P(not like the second type) which equals: P(not like first type / not like second type) But now, I don't have the data of the conditional probability. In addition, I'd like to see how could it solved using a computer programming language. Any ideas? Thank you.

• ### Can you hep me with my Perl homework?

##### - by riya
Could someone write simple Perl programs for the following scenarios: convert a list from {1,2,3,4,5,7,9,10,11,12,34} to {1-5,7,9-12,34} to sort a list of negative numbers to insert values to hash array there is a file with content: C1 c2 c3 c4 r1 r2 r3 r4 put it into an hash array where keys = {c1,c2,c3,c4} and values = {r1,r2,r3,r4} There are testcases running each testcase runs as a process and has a process ID. The logs are logged in a logfile process ID appended to each line. Prog to find out if the test case has passed or failed. The program shoud be running till the processes are running and display output.

##### - by sil3nt
Hey there, this is part of a question i got in class, im at the final stretch but this has become a major problem. In it im given a certain value which is called the "gold value" and it is 40.5, this value changes in input. and i have these constants const int RUBIES_PER_DIAMOND = 5; // relative values. * const int EMERALDS_PER_RUBY = 2; const int GOLDS_PER_EMERALDS = 5; const int SILVERS_PER_GOLD = 4; const int COPPERS_PER_SILVER = 5; const int DIAMOND_VALUE = 50; // gold values. * const int RUBY_VALUE = 10; const int EMERALD_VALUE = 5; const float SILVER_VALUE = 0.25; const float COPPER_VALUE = 0.05; which means that basically for every diamond there are 5 rubies, and for every ruby there are 2 emeralds. So on and so forth. and the "gold value" for every diamond for example is 50 (diamond value = 50) this is how much one diamond is worth in golds. my problem is converting 40.5 into these diamonds and ruby values. I know the answer is 4rubies and 2silvers but how do i write the algorithm for this so that it gives the best estimate for every goldvalue that comes along??

• ### Help with Btree homework

##### - by Phenom
I need to do a preorder traversal of a Btree, and among other things, print the following information for each page (which is the same thing as a node): The B-Tree page number The value of each B-Tree page pointer (e.g., address, byte offset, RRN). My questions are: 1. How do you figure out the byte offset? What is it offset from? 2. Isn't the RRN the same as the page number? Note: A Btree is NOT A BINARY TREE. Btrees can have multiple keys in each node, and a node with n keys has n+1 child pointers.

• ### Need help with homework(very short code)

##### - by b3y4z1d
I have a code, and I need to have it done until friday or so.I'd say 95% of it is finished,but the functions and the function-calling could use some grooming. It is really simple for anyone who knows C++ pretty well, but I'm a newbie and I just can't seem to get through this with the functions so if anyone could take a look and correct the few mistakes or add a line or two if needed I'd be very grateful. Here is the link to the full code, you'll understand the purpose of the code once you see it. I use Borland C++ by the way if it helps. Thanks in advance!

• ### Java Programming Homework

##### - by user1427476
Write a program to read in a file containing the names of the employ of a company and store them in an array of Strings named Employ []. Read another file containing the Salaries of each employ written in the same order and store them in another array of integers named salary[] (contents of both files are shown below). Finally create a file stating for example. Mr. XYZ receive \$75,500.00 per year (Note that salary is stored as integer but displayed here as double with a comma separating thousands. This formatting needs to be done using DecimalFormat Class)

• ### How to manually (bitwise) perform (float)x? (homework)

##### - by Silver
Now, here is the function header of the function I'm supposed to implement: /* * float_from_int - Return bit-level equivalent of expression (float) x * Result is returned as unsigned int, but * it is to be interpreted as the bit-level representation of a * single-precision floating point values. * Legal ops: Any integer/unsigned operations incl. ||, &&. also if, while * Max ops: 30 * Rating: 4 */ unsigned float_from_int(int x) { ... } We aren't allowed to do float operations, or any kind of casting. Now I tried to implement the first algorithm given at this site: http://locklessinc.com/articles/i2f/ Here's my code: unsigned float_from_int(int x) { // grab sign bit int xIsNegative = 0; int absValOfX = x; if(x < 0){ xIsNegative = 1; absValOfX = -x; } // zero case if(x == 0){ return 0; } //int shiftsNeeded = 0; /*while(){ shiftsNeeded++; }*/ unsigned I2F_MAX_BITS = 15; unsigned I2F_MAX_INPUT = ((1 << I2F_MAX_BITS) - 1); unsigned I2F_SHIFT = (24 - I2F_MAX_BITS); unsigned result, i, exponent, fraction; if ((absValOfX & I2F_MAX_INPUT) == 0) result = 0; else { exponent = 126 + I2F_MAX_BITS; fraction = (absValOfX & I2F_MAX_INPUT) << I2F_SHIFT; i = 0; while(i < I2F_MAX_BITS) { if (fraction & 0x800000) break; else { fraction = fraction << 1; exponent = exponent - 1; } i++; } result = (xIsNegative << 31) | exponent << 23 | (fraction & 0x7fffff); } return result; } But it didn't work (see test error below): Test float_from_int(-2147483648[0x80000000]) failed... ...Gives 0[0x0]. Should be -822083584[0xcf000000] 4 4 0 float_times_four I don't know where to go from here. How should I go about parsing the float from this int?

• ### What are the five built in groups in Windows Server 2008?

##### - by Papuccino1
I think they're: Administrator Group Machines Accounts I'm kinda of lost here. What are the five groups that come built into Windows Server 2008 for administrating your server?

• ### Kids don’t mark their own homework

##### - by jamiet
During a discussion at work today in regard to doing some thorough acceptance testing of the system that I currently work on the topic of who should actually do the testing came up. I remarked that I didn’t think that I as the developer should be doing acceptance testing and a colleague, Russ Taylor, agreed with me and then came out with this little pearler: Kids don’t mark their own homework Maybe its a common turn of phrase but I had never heard it before and, to me, it sums up very succinctly my feelings on the matter. I tweeted about it and it got a couple of retweets as well as a slightly different perspective from Bruce Durling who said: I'm of the opinion that testers should be in the dev team & the dev *team* should be responsible for quality Bruce makes a good point that testers should be considered part of the dev team. I agree wholly with that and don’t think that point of view necessarily conflicts with Russ’s analogy. Yes, developers should absolutely be responsible for testing their own work – I also think that in the murky world of data integration there is often a need for a 3rd party to validate that work. Improving testing mechanisms for data integration projects is something that is near and dear to my heart so I would welcome any other thoughts around this. Let me know if you have any in the comments! @Jamiet

• ### Where to find Android Development Homework Problems

##### - by antonlavey
Ok so I am starting off with android development and I have found a bunch of useful tutorials so I am set there. What I am looking for is a resource that provides homework style problems to do and has the answers downloadable so I can check my solution against the "official" solution. So for example instead of the notepad tutorial it would be: "Build an application that you can create, edit, delete notes, ...etc.". Ideally the "official" solution would have some explanation as to why they built it the way they did. (so a tutorial at the tail end) Anyone know of any resources that provide their tutorials in this format? Thanks.