homework

How to add to beginning of a linked list in Java

I am creating a linked list function for homework that adds at any index except last, but I don't understand how to make a conditiontargetList.addToIndexAt(81,0); without sentinel nodes EDIT Okay, I fixed all of the problems, except for one. This time, the code runs the code states that the result is 81,0,0,0,0, which means that after r...

I want to parse multiple strings into variables from a .txt file in java. What's the easiest way to do it?

What's the best way to do it? Should I use the File class and scanner? I've never done it before and cant seem to find a solid guide for it online so I figured I would ask here. Thanks! ...

Reversing Doublely Linked Deque in C

I'm having trouble reversing my doublely linked deque list (with only a back sentinel) in C, I'm approaching it by switching the pointers and here is the code I have so far: /* Reverse the deque param: q pointer to the deque pre: q is not null and q is not empty post: the deque is reversed */ /* reverseCirListDeque */ void revers...

SingPath Python Help - cosine problem

Any help? I have the following: import math def cosine (a): x = (a * math.pi) / 180 return math.cos(x) The problem: Create a function that calculates the cosine of an angle (in degrees). The math module contains a function math.cos that uses radians to calculate the cosine. You will need to convert the angle to radians ...

How to replace letters in a string with underscores?

Say I got a random word like WORD, i want to replace each of the letters of the word with _. How can I do it? Also, say if there is a space between the word like WO RD, I don't want it to replace the space with _. ...

FA for regular expression

Give an FA for the set of the strings with alphabet {a,b} that contain both or neither aa and bb as substrings. It means FA accept all strings without aa and bb as substrings. correct me if I wrong and give me some hint. Thanks all. :D ...

Recursion Tracing...

Lets assume I have a loop for Foo. int Foo(int n) { if (n <= 1) return 2; else return Foo(n-1) * Foo(n-2) * Foo (n-3); } How many call will occur If i Call Foo(3) and what would be the result... Thanks ...

How to use Perl to parse specified formatted text with regex?

Dear Perl gurus: Question abstract: how to parse text file into two "hashes" in Perl. One store key-value pairs taken from the (X=Y) part, another from the (X:Y) part? 1=9 2=2 3=1 4=6 2:1 3:1 4:1 1:2 1:3 1:4 3:4 3:2 they are kept in one file, and only the symbol between the two digits denotes the difference. ==...

regular expressions - my expression

(ab+ba)* accepts all zero or more a 's followed by zero or more b 's and also zero or more b 's followed by zero or more a 's. so what's is the reject state of this RE ? Just think about the strings that is not accepted by (ab+ba)*. ...

Sort comma separated values from file.

How to sort comma separated values in file comparing only first element in each row. ...

What are the meanings of these regular expressions in JavaScript?

1) ^[^\s].{1,20}$ 2) ^[-/@#&$*\w\s]+$ 3) ^([\w]{3})$ Are there any links for more information? ...

Updating Record In Text File

I am working on my uni project on C#. It requires me to create a student management system in C# console. I have to use text file for saving data. I can add data and retrieve data in text file but unable to update any student record. My question is how I can update specific student record in text file? For example my program will ask use...

Replacement of random string/char array characters using match ups.

while (1) { char j; if (x[j] == y[j]) Here I am trying to start a loop where I want to able to match any of the characters from char array 'x' with char array 'y'. If the characters do match from x to y then I want to keep them as they are and if they don't I want to be able to replace them with a star '*'. (e.i. x = [a,p,f] an...

C++ Functions and Passing Variables

Possible Duplicate: C++ passing variables in from one Function to the Next. The Program is working but when it comes to getUserData it asks for the same information 4 times and then displays the results with negative numbers. I used test numbers for number of rooms 1, 110 for sqrt feet in the room, 15.00 for cost of paint. /...

templates and function objects - c++

i have a problem with this class. the goal is to make the main function work properly. we were supposed to implement the "And" function object so that the code will work. i can't find what is the problem with our solution. (the solution start and end are marked in comments in the code before the "main" function) can you please help? than...

I have a question about OOP .I Need Your help !!

Please see the code below : package bk; public class A { protected void methodA() { System.out.println("Calling the method A !"); } } // And I have an another package : package com; import bk.A; public class B extends A { public void methodB() { System.out.println("Goi phuong thuc B !"); } pu...

Huffman Tree Encodeing

So i must say that i love this site because its sooooo helpful and now i have another question! my Huffman tree which i had asked about earlier has another problem! here is the code: package huffman; import java.io.FileNotFoundException; import java.io.FileReader; import java.util.ArrayList; import java.util.PriorityQueue; import java...

programing pseudocode

I'm trying to make the game KenKen in Python. I need some help with the pseudocode. What data types required to store and process the game information as it progresses and completes? ...

Implementing RSA in python

Hi All, i am trying to implement RSA in python(i am new to python) for my course, the problem i have is the code i have written does not work for numbers with more than 4 digits. any idea why this is happening? please advice p =0 q=0 n=0#modules phyPQ = 0 e = 0 #public key exponent d = 0#private key exponent c = '' m = '' def getPrimes...

Java Bit-Shift Operations question?

I have this statement: Assume the bit value of byte x is 00101011. what is the result of x>>2 how can I program it and can someone explain me what is doing? Bye and thanks for answering ...