Rashakil Fol 978 Super Senior Demiposter Team Colleague

That depends whether you're interested in cryptography or cryptography engineering.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What ideas have you considered and why did you reject them?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

When I use the term, it means what aspire1 said, except that you can shift the elements N places, for some value of N.

Either way, "many rotations" gets the same meaning, and the combined effect of many rotations is the same as that of one of rotation, or a small number of aspire1's variety.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Go look at the generated assembly.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The inner loop should run sqrt(n) times. Is that the same as n^0.5 times?

Is the sqrt(n) the same as n^0.5? Are you really asking that? Okay, yes it is.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

How many times does it run through the inner loop?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Another place might be classes that are completely internal to your library, like pure abstract classes.

So you're repeating what I just said.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Making variables non-private is only an issue for public APIs.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What's the powerset of the empty set?

Given x and given the powerset of xs, what's the powerset of (x :: xs)?

Bam, use recursion.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

i can, and i already proved it. Why don't you make your own signature and don't be jealous. ahaha.

The person was probably a low-quality "genius" then. Or maybe you defeated him at wrestling.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

@naraue: you criticize people like your a super genius... ohhh... your too full of yourself... you think your so smart?

She is a super genius.

And oh, by the way, you can't defeat a genius through hard work.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Hi I am ravi, this is my first personal interview in my career. Please comment me over my answers and my way of answering:)

No, I'm going to make some general commentary about society and seem really obnoxious but that's just the effect of stupidity rubbing off on me.

Q: Tell about yourself?
Me: I am N.Ravikumar coming from Unjapalayam; I am pursuing my B.Sc Information Technology degree in Dr.NGP Arts and Science College. I love programming and blogging.

Okay.

Q: what are the different stages in SDLC?
Me: Requirement Analysis -> Design -> coding -> Testing -> Implementation and Maintenance

What? WTF is SDLC? Is that some Indian codeword that they teach? Oh, it means Software Development Lifecycle. And your answer's wrong because there are plenty of different approaches to the question of how to develop software. It seems like you're describing the waterfall model, which is the worst one. I can't understand how an education system could churn out people who give such answers. And why would anybody even ask such a braindead question? It's not as if a candidate is going to have trouble adapting to whatever some particular company does for its development process.

Q: what are the advantages of C++ over C?
Me: C++ is an Object Oriented Programming Language while C is a Procedure oriented language
Q: Other than that?
Me: Sorry madam, I don’t know.

You didn't answer the question, you completely fail. You didn't even try …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I can agree that any book by Strang is good, but I don't think a linear algebra book is the right choice. I say this because I actually had one before going to college -- it was similar in scope to your recommendation, and it didn't serve me very well.

The book I'm dreaming of should be (relatively) easy to understand and provide enough information to give me some idea of what will hit me when I finally head off to Uni.

I'm assuming you're a CS major or something like it. I dual majored in CS and Math.

First of all, you should recognize that you'll be fine. You don't need any preparation for the mathematics you'll use in computer science. The only piece of math that's really really necessary for undergraduate computer science, other than basic algebra, is an understanding of modular arithmetic and an understanding of big O notation, and they're not prerequisites -- you'll be taught about both when you need them.* I still recommend being comfortable with modular arithmetic now, though, because that's just a natural life skill people should have.

I recommend Reading, Writing, and Proving. It's actually designed for math majors, not CS majors, for a sort of "introduction to proofs" class. It's not a book with a bunch of math facts or what not, it's a book about thinking rigorously. I think it's the most relevant boost in mathematical ability that a future computer science student can …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I mean the direct code.

google "openjdk hashmap code"

Here's your code. http://www.docjar.com/html/api/java/util/HashMap.java.html

Rashakil Fol 978 Super Senior Demiposter Team Colleague

For example, suppose you have a function

int f(int n) {
  if (n == 0) {
      return 1;
  }
  else {
      return n * f(n-1);
  }
}

We want to measure its cost. But before we do so, we'll say that its cost is O(t(n)) so that we can use it in the formula.

if (n == 0) { // O(1) conditional test
      // O(1)
  }
  else {
      // O(1) + t(n-1)
      return n * f(n-1);
  }

So t(0) = O(1) and t(n) = O(1) + t(n-1)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Create a recursive formula for the time complexity and figure it out from there.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Hey, you're right, it is easy for me.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Let's look at this one. I'm going to ignore the swap for now.
Iteration2:

public static long dominoes(long x, long y){
		long temp;
		double koeficient = 0, faktor;
		for(long i=0; i<=x+y; i++){
			koeficient = 1;
			for(int j=1; j<y+1; j++){
				faktor = ((double)((i+1)-j)) / (double)j;
				faktor = koeficient * faktor;
				koeficient = faktor;
			}
		}	
		return (long)koeficient;
	}

Let's add annotations, giving the cost of each line.

public static long dominoes(long x, long y){
		long temp; // O(1)
		double koeficient = 0, faktor; // O(1)
		for(long i=0; i<=x+y; i++){
			// an O(1) cost for (i <= x+y) and (i++)
			koeficient = 1; // O(1)
			for(int j=1; j<y+1; j++){
				// an O(1) cost for (j < y+1) and (j++)
				faktor = ((double)((i+1)-j)) / (double)j; // O(1)
				faktor = koeficient * faktor; // O(1)
				koeficient = faktor; // O(1)
			}
		}	
		return (long)koeficient; // O(1)
	}

When we have successive statements with cost O(x) and O(y), their combined cost is O(x + y). Let's first remove the pieces of code that we've accounted for.

public static long dominoes(long x, long y){
		// O(1)
		// O(1)
		for(long i=0; i<=x+y; i++){
			// O(1)
			// O(1)
			for(int j=1; j<y+1; j++){
				// O(1)
				// O(1)
				// O(1)
				// O(1)
			}
		}	
		return; // O(1)
	}

You'll note that the lines of code don't modify i or j. If there was some line that said "i = i * i", we wouldn't want to delete that because it would affect the number of iterations of …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I also forgot to ask before... What is the time complexity of BigInteger (in Java)?

Addition is O(n) where n is the number of bits in the BigInteger, and multiplication depends on the algorithm used: http://en.wikipedia.org/wiki/Multiplication_algorithm . That depends on the Java implementation. I don't know about division.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Thanks for your reply but could you please tell me what is clojure??.As this is the first time i am hearing about it..:-Osome basic infos about clojure.:-/

Search for it on Google. It's a nice language that has access to all the Java libraries.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Hi frnds...
I am doing ma collg 1st yr and i am of CSE department(comp sci engg) and i want to do some additionals course on languages.I am already studying c nd c++ in ma sub and in add on to that i wanna study some other language as i am more interested in developing programs..plz reply me soon frnds w8ing 4 ur replies
;)

Learn Clojure.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

When you run a Theta(n) operation n times, it takes Theta(n^2) time to do. I mean in general if you run an operation that takes n seconds n times, it's going to take n*n seconds.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I'm not so sure I expected the Array.Sort to go through any particular order, but I expected it to only compare spots in which a file actually existed. If I declare the array to be 64 spaces large, then only fill 5 of them, and tell it to do an Array.Sort does it sort even blank spaces?

There's no such thing as a 'blank space.' An array with 64 elements will contain 64 elements. Some of them will be null, because that's what they were initialized with -- but that's no different than if you had assigned null to any particular element. Array.Sort will try to sort the entire array.

If that's the case I guess I could just as easily push each one to a List<File> and then call Array.Sort on that.

Yes. You shouldn't preallocate arrays and then put several values in them, you should just use List<>.

sknake commented: This pains me to +rep you, but it is deserved. +5
Rashakil Fol 978 Super Senior Demiposter Team Colleague

The "second" file from the list? Are you saying you're expecting Sort to look at the elements of the list in some particular order?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Basically as soon as it gets to the "Array.Sort" line it crashes where "int b" is declared in the "FreePtrCompare" class saying that File y is null object/pointer reference. which it is, but I'm not entirely sure why that isn't being passed through correctly.

If File y is null, what do you expect to happen? What is y.fsPos supposed to do when y is null? (Hint: it throws an exception.)

Apologies for the snark.

You should modify your Compare method to explicitly handle the case where parameters are null.

Edit: or you could remove nulls from the array that you're sorting, if that's the right thing to do.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Why is it Theta(n)? Isn't it still O(1) since it's still a constant number of steps done twice? Or does the fact that it's repeated mean it's linear where n is the amount of repeated operations?

No, when n is the size of the array, resizing takes Theta(n) time because you have to copy all the elements.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

This should cause extra usage in the time of the algorithm. However, I don't know how to convey this on paper with asymptotic notation :( Hmm...

You would just write that each push and pop wolud take Theta(n) time. (And so the average time per operation is Theta(n) which is bad because we'd like it to be O(1).)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

MS Visual C++ Express. It should work.

Edit: as a stopgap, if you're short on time, you can run single-file C++ programs at http://codepad.org/ . But it's in your best interest to get a compiler up and running on your own machine.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

A Taylor series isn't really a good way to compute this function unless you're looking for asymptotic accuracy around a particular point, rather than general accuracy along the whole thing. Also, it's a good idea to start by folding the number down to the interval [0,pi]. But suppose we did want to go with a Taylor series because that's all we knew of.

static double cos(double x) //calculate cosine
        {
            // move x to value in [0, pi] with equal answer
            x = Math.Abs((x + Math.PI) % (2 * Math.PI) - Math.PI);
            const double tf = 1.0 / 24.0, vtz = -1.0 / 720.0, fzhtz = 1.0 / 40320.0, fukit = -1.0 / 3628800.0;
            double p = x * x;
            // use Horner's method instead, just because.
            return 1 + p * (-0.5 + p * (tf + p * (vtz + p * (fzhtz + p * fukit))));
        }
    }
}

See pages 115 and 116 here for a comparison of a Taylor approximation with one that strives for a different metric of accuracy.

Rashakil Fol 978 Super Senior Demiposter Team Colleague
//load client details
            prevData = getFormData.DisplayData();

            for (int i = 1; i <= 3; i++)
            {
                
                switch (i)
                {
                    case 1: C_name = prevData[i].ToString(); break;
                    case 2: D_name = prevData[i].ToString(); break;
                    case 3: B_type = prevData[i].ToString(); break;
                }
            }

First of all, again, you should be iterating i from 0 to 2, not from 1 to 3.

Second, how do you know (at the time this code runs) that gemData has been written to? If you were getting an index error back when you had your indexes going from 0 to 2, it's because gemData had never had a three-element list written to it, because Preview_Meth was never called.

As an aside, your "for-switch" construct is a bit of a coding horror, and you should just write the three statements as follows. Also, .ToString() was superfluous too, because the values are already Strings.

C_name = prevData[0];
D_name = prevData[1];
B_type = prevData[2];
Rashakil Fol 978 Super Senior Demiposter Team Colleague

You can compile and run the program if you want to see if it works.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Yes, read through the Time Complexity of Algorithm thread. It's a very old thread and has practical and theoretical answers.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

For this specific mechanism, you could make a function that converts your ArrayList to a byte[] and then passes that through an MD5 or SHA1 algorithm or whatnot. See System.Security.Cryptography.SHA1, for example.

You should not rely on the behavior of GetHashCode being consistent on different computers unless you can find documentation guaranteeing that its behavior is. Also, GetHashCode is a hash function that produces duplicate hash codes for different values -- it's not a cryptographically strong hash, the way that SHA1 or MD5 are, which means the probability of getting two values that have the same hash is (in the long run) very high.

There are other ways to solve this problem that don't use hashes. You can keep a version number instead (every time you change the array list, you have to increment the version number) -- if the version number hasn't changed, then the clients don't need to be updated. I don't know how .NET remoting works; another way to send information about the ArrayList is to send a description of how the ArrayList has changed -- using some kind of tuple that says things like "insert blah at index 23" and "remove item at index 14". I don't know how .NET remoting works; you might want to investigate the possibility that it does this kind of thing (version numbers or hashing especially) automatically.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

atoi(text[0]) will not work because atoi expects a char*, not a char. That half of NeoKyrgyz's answer was basically useless and dumb.

If you want to convert the character "c" representing the decimal digit n to the integer n, you can do so with (c - '0') . That's the same as what NeoKyrgyz said, because '0' is just a fancy way of writing 48 . You'll note that '0' == 48, '1' == 49, ..., '9' == 57. If text is a string containing "0R14", then text[0] will evaluate to 48.

atoi is for converting c-style strings containing sequences of digits into numbers, e.g. "123" -> 123

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The happy police strike again. It was good knowing you serkan -- I will make it very dry for you.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

hey can someone tell me how to make 10 nodes in the code tht i have made...thts the one way i could think of...

Try figuring it out yourself. Then maybe you'll learn something.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What courses are available and which ones are good depends on which school you're going to. There is a lot of variety in the ways various computer science departments teach.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Why don't you keep track of how many values the user has entered, and use some mechanism to see if that number's 10?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I like the sound of that, but I'm afraid it's way beyond my level. Mind explaining what it does? :)

It uses the function System.Linq.Enumerable.Where, which takes an IEnumerable<T> and a function of type Func<T, Bool> and returns an IEnumerable<T> that contains all the values for which the function returns true.

Since it's an extension method, you can write path.Split('\\').Where(s => s.Length > 0) , which is equivalent to Enumerable.Where(path.Split('\\'), s => s.Length > 0) . The expression s => s.Length > 0 here is a function that takes a string and returns a boolean.

You could implement it like this

public static class Enumerable {
// pardon my indentation
public static IEnumerable<T> Where<T>(this IEnumerable<T> source, Func<T, Bool> predicate)
{
    foreach (T element in source)
    {
        if (predicate(element))
        {
            yield return element;
        }
    }
}

}

And calling that function doesn't evaluate the interior -- it returns an IEnumerable<T> such that when you enumerate it, the interior is evaluated step by step.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Whoops, I meant path.Split(new[] { '\\' }, StringSplitOptions.RemoveEmptyEntries) .

And if you wanted to filter the empty entries manually, you'd probably do path.Split('\\').Where(s => s.Length > 0).ToArray()

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Just use path.Split('\\', StringSplitOptions.RemoveEmptyEntries) .

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You need using System.Linq; at the top of your file.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Er, actually not in theory. The current query seemed to work but maybe it was coincidence. I wanted to sort the Y values (descending) for each group of X values, then choose the first X,Y value (therefore the furthest down on the screen) to feed to another method. Perhaps I'm still confused about the IEnumerables that emerge from the LINQ query and how to access them properly.

Except when doing joins, I prefer to avoid the LINQ syntax and just use the Enumerable extension methods directly. It makes the behavior more clear, sometimes.

If you want things grouped by X and then each individual group sorted, you should do this:

var groups = invaders
    .GroupBy(invader => invader.Location.X)
    .Select(group => group.OrderByDescending(invader => invader.Location.Y));

If invaders looks like this: [(1,2), (1, 3), (1,1), (3, 5), (2, 4), (3, 4)] , then groups should look like this: [[(1, 3), (1, 2), (1, 1)], [(3, 5), (3, 4)], [(2, 4)]] (but you might want to double check that I'm right).

If you want LINQ syntax for that, you'd write

var groups = from invader in invaders
             group invader by invader.Location.X into g
             select g.OrderByDescending(invader => invader.Location.Y)

but I don't have a C# compiler on this computer so maybe I forgot something. This is equivalent:

var groups = from invader in invaders
             group invader by invader.Location.X into g
             select (from invader in g orderby invader.Location.Y descending select invader);
Rashakil Fol 978 Super Senior Demiposter Team Colleague

It should work for List<Microsoft.Xna.Framework.Rectangle> , which implements IEquatable<Microsoft.Xna.Framework.Rectangle> . Maybe you're expecting the code to modify the original list object. It doesn't do this; it instead creates a copy that lacks duplicates.

Rashakil Fol 978 Super Senior Demiposter Team Colleague
var Column = from all in invaders group all by all.Location.X into grpResult orderby grpResult.ElementAt(0).Location.Y descending select grpResult;

foreach (var v in Column)
Console.WriteLine(v.ElementAt(v.Count()-1).Location.ToString());

You can and should use v.Last() instead of v.ElementAt(v.Count()-1) . Using v.Last() also only iterates through the collection once, which is sometimes something to be aware of (and sometimes a needless microoptimization) and anyway it's less code.

Edit: And I think you have it all wrong. Your code groups by the X value and sorts the collection of groups by the groups' first Y values. That's what you want?

jonsca commented: Some long overdue rep +1
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Blah blah blah, why don't you answer the question instead of linking to some reference site.

linkpraveen: if you use a List<Invoice>, for example, it's impossible to have anything in that list which is not an invoice. If you just used an ArrayList, you would increase the probability of making a mistake and putting something of the wrong type in. Generics also let you make guarantees that somebody's passing something sensible into your function. For example, consider the function

T MaxBy<T>(List<T> values, Comparer<T> comparer);

This function can guarantee that you've supplied a comparer intend to operate on things of type T. Without generics, you'd have to write something like

object MaxBy(ArrayList list, Comparer comparer);

where a Comparer is a delegate that takes two objects as arguments. You might accidentally use a wrong delegate or change the type of the elements stored in a list you're using somewhere, and the compiler would never warn you about the error. You'd have to compensate for the lack of generics by writing more careful unit tests. Also, you'd have to double-check the documentation of more APIs.

So there is the general question asking what are the most common practical uses of generics. The most common is the simple use of generic collections, like List<T>, HashSet<T>, Dictionary<TKey, TValue>, T[] (which formally speaking in .NETenese isn't a generic collection), IEnumerable<T>, and so forth. The second most common use I see is the use of generic function types. I.e. Func<T>, Func<A, T>, Action<T>, …

sknake commented: great answer +14
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Instead of keeping variables first_address , second_address , and third_address , and so on, make an array of addresses and walk through the array until one succeeds or until they all have failed.

serkan sendur commented: welcome +7
Rashakil Fol 978 Super Senior Demiposter Team Colleague

ISingleResult<T> : IEnumerable<T>, so just use System.Linq.Enumerable.ToList.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

D is too complicated (but cool), Ada is too much crap, Haskell is awesome and has an awesome community except there's a huge learning curve which is awesome and epiphinaical itself, Object Pascal is whatever. F# is... an excellent .NET language. Obviously.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

ROFL