Rashakil Fol 978 Super Senior Demiposter Team Colleague

See http://www.daniweb.com/techtalkforums/post183580-17.html which might give you some idea of how to solve the problem.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

So, what is the behavior of the function when the list is empty? Can you define the behavior of the function in relation to a function call on a list that is closer to being empty? The function is defined recursively; a recurrence relation is just another way of writing a recursive function definition, only in math notation instead of pseudo-code.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

So, what is the problem? Why can't you do it? What do you think the answer is?

Do you think you'll just get answers just by posting questions? We don't do people's homework here.

If you need help, explain what ideas you might have about what the solution would be.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Having buttons move around the window and stop in the middle, all in the way, is annoying.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

It depends on how your tree is structured. Do leaf nodes contain pointers to their parents? Or is it that parents contain pointers to their children, and that you're only given the root node and the addresses of the two particular leaf nodes? In the former case, you can do this in O(h) time with constant memory usage.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You have interpreted the problem correctly. Your instructor is a complete idiot with a personality disorder.

(a) Show that any algorithm that can decide whether a given array includes such an element, and if so find it must check all the elements in the array."

I would add and remove commas: "Show that any algorithm that can decide whether a given array includes such an element and, if so, find it, must check all the elements of the array."

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Then get good in programming.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Well, I was kind of joking when I said straightforward :)

But anybody with a good understanding of basic algebra could be taught how to do this and understand how it works.

Also, anybody capable of following instructions can be taught how to do this by hand.

And if you can do this by hand, you better be able to write a computer program that can do it, too, if you call yourself a programmer.

There are still a few important subtle issues, though. One is that of double roots. If you have a double root, then one of your partial fractions must contain a squared denominator. (And with a triple root, you'll also have a cubed denominator, etc.) For example,
[tex]\frac{3x+4}{x^2+10x+25}[/tex]
expands into
[tex]\frac{3}{x+5}-\frac{11}{(x+5)^2}[/tex]
This is arguably not really a partial fraction expansion; you might say the problem has no solution.

Not only does that issue add some complexity to the program, it raises the question: how do you detect a double root? Well that's an annoying problem, if you're finding solutions numerically. So I would recommend finding some magical polynomial root finder algorithm, at least, that recognizes multiple roots (somehow), and use that. But don't even trust that.

So finding partial fraction expansions is a very tricky problem, and it's sensitive to numerical inaccuracy. The good news is, if you do have multiplicated roots but can't recognize them because of numerical inaccuracies, you'll notice when your numerators blow …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Yeah, there's a simple and straightforward algorithm for this.

The first step is to understand how to represent a linear system of equations with matrices and how to solve that with a computer program.

Once you understand that, you'll need some way to be able to find all the roots of a polynomial (so that it can be factored). You can't do this exactly -- some solutions will need to be approximate, i.e. 'numerical'. And of course you'll need to use complex numbers.

Then, you'll need to understand how to implement polynomial division (and then implement that on a computer).

Once you've done that, it's a simple matter of taking a rational expression and using polynomial division to turn that into the sum of a polynomial and a remainder, a remainder that looks like [tex]\frac{A_0 + A_1 x + A_2 x^2 + \cdots + A_{n-1} x^{n-1}}{B_0 + B_1 x + B_2 x^2 + \cdots + B_{n} x^n}[/tex] and then find the roots of the bottom polynomial to factor the bottom into [tex]\alpha (x - z_1)(x - z_2)\cdots (x - z_n)[/tex], at which point you can conclude that we're looking for an expansion of the form [tex]\frac{C_1}{x - z_1} + \frac{C_2}{x - z_2} + \cdots \frac{C_N}{x - z_n}[/tex] At this point, just add the fractions together (symbolically), and then you'll get expressions in C_1, C_2, etc in a system of equations with teh A_n's on the right side, which you know how to solve since it's just …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

In some distributions you can, if you're on the AMD64, i.e. x86-64 architecture, since it's a superset of x86 -- there are issues that come up, like the fact that you need thirty-two-bit libraries /and/ sixty-four-bit libraries installed on the system.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

And what do you need to know? Specifically, what gaps of knowledge prevent you from using the information at http://en.wikipedia.org/wiki/Interpolation to figure this out?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

So you admit then that you acquired a substantial portion of it illegally? :P

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I have found Mac OS X to be a good environment for programming. It's like Linux multiplied by Everything Just Works, plus decent fonts, thoughtful UI, better support for the keyboard, better support for everything, and a nice version of Carbon Emacs. Of course, you can't install it everywhere...

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If I were to consider VB.net, I'd end up using C# instead. Then again, C# isn't in the C family, except in a loose syntactic sense... but okay. Usually, you'll want to use a language with automatic memory management (i.e. garbage collection), which means you'll want to use VB, C#, Java, or some other thing that is not C or C++.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

flag = (x <= 10) ? true : false

You could just write flag = (x <= 10); And you're sorely mistaken if you think your post helped the original poster.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

In UNIX-like systems, a file descriptor is a small integer associated with an open file stream. You can use procedures like read and write to read and write to a particular file stream, and in order to do this, you need to provide the file descriptor for the open file you want written to. The procedure open is used to open files, and it returns the integer that should be used as the file descriptor (or in case of error, returns -1).

The standard C library, with procedures like fopen, fread, and fwrite uses 'FILE pointers', pointers of type FILE*, to refer to open files.

I don't know what Windows uses for OS-specific input/output.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

There's an infinite number of purposes, and only a finite number of languages, so at least one language has to be the best for an infinite number of purposes.

While Python is a decent language, it just doesn't seem to shine at any particular thing. I'd use it if one of its libraries had some ability that happened to be direly useful to me at the moment.

For interacting with the OS (especially Unix OSes), I feel very comfortable with Perl -- more comfortable than with anything else. I can't recommend against Perl. But I keep looking at Lua (haven't used it) and it just seems very nice.

I think anything but PHP is tolerable. It's not like you're only allowed to learn only one language -- I end up using different languages for different things, anyway.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I do not know what you mean by 'scripting language,' so I'll take it to mean 'a language with garbage collection, rapid development, and general ease of use.'

PERL, Python, LUA, PHP etc.

Perl is a good language for short programs that need to chop text around, and it's a trippy language to learn, too. Python is a somewhat decent language, big on batteries but small on power. (I'm such a language bigot, aren't I?) PHP is utter crap. Well, I'm being a bit mean about PHP, since people use it to do useful things, but it's just about the most poorly designed language that is frequently used today. It's basically a retarded version of C++, and that's only a bit more powerful and versatile than assembly language.

Lua is an excellent programming language, and of the four you have mentioned, I recommend it the most. The reasons are simple: it's simple, and it's got closures, first class functions, and proper tail calls. But this is still not my recommendation...

the most powerful and versatile scripting language.

It is quite simple: every other language you will see in this thread has a set of features that is a subset of the features of Common Lisp. I recommend learning Lisp for a few reasons:

1. It's the most powerful and versatile language*. (Or maybe some other variant of Lisp is; this is just standardized and the most popular.)
2. If you learn Lisp, you'll never have …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Not only can you store larger numbers with doubles, the numbers are stored with more precision.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Realize that if you have 128 binary digits, you won't be able to store that in a long or long long datatype.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

That's because it's a hard question. It was on my DSA final. Because it's an O(log k) algorithm, you can bet that it involves jumping pointers around in a binary search-esque pattern.

You might also want to try assuming that k <= n for now. (If k > n, you can call a function that finds the 2n-k+1'th largest element.)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Um... what's your point?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

getch() returns an int, not a char. And there is an open parenthesis missing in the if condition.

int c; 
if( (c==getchar())!='\n')
<snip>

I don't see why two people assume that == is the desired operator between c and getchar(). For one, (c==getchar()) will never return a value equal to '\n'. And of course Deacon J's use of == is nonsensical.

a new stack is allocated

A new stack frame. There's just one stack (in C, anyway), and you normally don't make copies of it.

Grunt commented: Read Between The Lines :) +1
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Um, the last post in this thread was July 6.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I guess I am mainly a piano geek. Here is me playing with Tetris music. http://youtube.com/watch?v=SkrVnfHsmK8

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Make a program that takes a BF program (a simple programming language) as input and outputs how many steps it takes to run, without actually running the program.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Why, because you lied on your résumé about your abilities?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

don't have any problems with calculus or math.

That's great news.

but i'm ailttle bit concerned because i have no programming knowledge what-so-ever, and i mean zip.

That doesn't matter. You might surpass these students who have 'programming knowledge' quickly. What separates students in computer science programs isn't how much preexisting knowledge they have; it's their creativity and ability for abstract logical thinking. Either you'll 'get it', or you won't. Some people will die when they introduce recursion. Others will die when they introduce pointers (but McGill uses Java in the intro course, so never mind). Others will die on exposure to more theoretical classes. You might not know what I'm talking about right now, but you'll see.

just can't imagine myself graduating and having a good solid knowledge of programming, cause ... there's just so much to know.

The main thing that you will need to learn (if you haven't already) is applied thinking. Comp sci (and mathematics too) requires exactly that. Good programmers don't get good from knowledge.

And don't worry about your prospects in the job market. You're going to McGill, for crying out loud. [edit: well, worry, but don't lose sleep.]

I don't know what gives me this feeling about you from reading only two short posts of yours, but I think you will do better than more than half your classmates. You'll be fine.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

That's not bad at all. You'd have to store user 3's membership information for each of the 1000 groups anyway, and you'd have to delete that anyway, so this is a linear multiple of the amount of work you'd have to do.

And if by 1000 groups you're including compound groups, then don't store the masks for every user for compound groups; just calculate them user-by-user whenever you need to know all the users that are members.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I've never seen it before. But, you know, it has no advantage over Quicksort, unless it'd kill you to use the (log n)/(log 2) words of auxiliary memory needed for quicksort.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Oh wow, it seems like they described my personality very precisely!

The thing is, I picked the boxes using rand().

WolfPack commented: he he he +3
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Tea. Earl Grey. Hot.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

There is no cost to complexity (imo). And the complexity (and technology) is optional. So the answer's yes.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Haskell, with the integer datatype implemented from scratch:

First, let's implement a datatype for storing integers.

> data IntType = Zero
>              | Succ IntType
>              | Pred IntType
>                deriving Eq

Then we'll want to implement comparison for integers.

> instance Ord IntType where
>     compare (Pred xt) (Pred yt) = compare xt yt
>     compare (Pred _)  _         = LT
>     compare _         (Pred _)  = GT
>     compare Zero      Zero      = EQ
>     compare (Succ xt) (Succ yt) = compare xt yt
>     compare (Succ _)  _         = GT
>     compare _         (Succ _)  = LT

Integers should be enumerable too...

> instance Enum IntType where
>     toEnum 0 = Zero
>     toEnum n = accume n Zero
>         where accume 0 k = k
>               accume n k
>                   | n < 0 = accume (n+1) (Pred k)
>                   | n > 0 = accume (n-1) (Succ k)
>     fromEnum k = adder 0 k
>         where adder n Zero = n
>               adder n (Pred kt) = adder (n-1) kt
>               adder n (Succ kt) = adder (n+1) kt
>     succ (Pred kt) = kt
>     succ k         = Succ k
>     pred (Succ kt) = kt
>     pred k         = Pred k
>     enumFrom x = iterate succ x
>     enumFromTo x y
>         | x == y    = [x]
>         | otherwise = x : enumFromTo (succ x) y

And we need to perform arithmetic.

> instance Num IntType where
>     x         + …
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Brainfuck:

+++[>++++[>++++<-]<-]>
++++++++++>
+.<.>+.<.>+.<.>+.<.>+.<.>
+.<.>+.<.>+.<.>+.<.>
--------.-.<.
Rashakil Fol 978 Super Senior Demiposter Team Colleague

WaltP, if group X is assigned the user mask 1000101, that means that user 1, 3, and 7 are members of group X.

Suppose group X has users 1,3,7, group Y has users 2,4,7, and group Z has users 3, 5. Then the user masks for X, Y, and Z are 1000101, 1001010, and 0010100, respectively.

Suppose group GGK consists of people who are either in X and Y, or are in group Z. Describing GGK the way you have been, you'd say (X && Y) || Z.

Then compute (X & Y) | Z (where these bitwise operators are taken from C and other languages). Well, the value X & Y contains all the users in groups X and Y: X & Y equals 1000000, after all. Then (X&Y)|Z equals 1010100. So users 7, 5, and 3 are members of the group GGK.

If you had a group and wanted to implement a way of combining groups and then to test arbitrary users to see if they're in the group, the strategy for implementation would depend on the programming language you're using. It would be easier in functional programming languages.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You can make a mask representing what users are in each group: for example, for G1, that would be 10001, for G2, that would be 10101, and so on. Then combine these masks using regular bitwise operations.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Also, if you're using C++, there's no reason you should be writing typedef struct { ... } foo; . Just write struct foo { ... }; .

Rashakil Fol 978 Super Senior Demiposter Team Colleague

PS. What should i do?

Drop the class?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Wasn't there something sometime during one of your classes that interested you?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The help file should have everything you need. And why (the hell) would you want to learn QBASIC next?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

[tex]\lim_{N\to\infty}{N^2 \over 2} + {N \over 2} = N^2[/tex]

Don't use fake mathematics. For starters, N^2/2 is nowhere near N^2. And even if you wrote N^2/2, the distance away as N appoaches infinity would be infinity also.

The reason the function is [tex]O(N^2)[/tex] is that, with [tex]N_0 = 5[/tex] and [tex]k = 1[/tex], it's true that [tex]\frac{N^2}2 + \frac{N}2 \leq k N^2[/tex], for all [tex]N \geq N_0[/tex]. Other values would work for [tex]N_0[/tex] and [tex]k[/tex], too.

Your intuition is correct, of course; it would be correct to say that
[tex]\lim_{N\to\infty}\frac{\frac{N^2}2 + \frac{N}2}{N^2} = \frac12[/tex]. And that is also sufficient to prove big-O-ness (since that proves the previous statement).

WolfPack commented: Thx for the correction +3
Rashakil Fol 978 Super Senior Demiposter Team Colleague

The best language for a beginner, in my opinion, is Java. I haven't seen a language yet that displays all the concepts of OO in such a friendly and understanding manner.

I don't understand this OO-mindedness that people have. Learning CS isn't about learning how to think in an object-oriented fashion, or how to organize things in that particular fashion (because that's just one way of doing it). It's really only about learning how to solve problems -- being able to state problems precisely, and being able to encode algorithms that you could perform ad hoc into precise definitions. This ability comes from thinking about problems, and particularly, thinking about different ways of describing problems and their solutions. It also helps to have a general understanding of how important parts of the computer, like operating systems, work. And for that it greatly helps to have used vastly different languages, from C to Lisp.

If you want proof then just look around at what language the universities are switching to. If you can master Java and understand it's elements and features, then you've got it made. You can go into about any programming language and it's just learning syntax from there.

This is just patently untrue. Besides rudimentary forms of BASIC, the only popular languages you could jump to are C# and Python, unless you want to willfully limit yourself to a subset of other languages' abilities.

Universities switching to Java is a good thing? I don't feel like …

Rashakil Fol 978 Super Senior Demiposter Team Colleague
Rashakil Fol 978 Super Senior Demiposter Team Colleague

That code wouldn't work at all anyway; the values of m, a, b, and c never change.

And it seems completely oblivious to triplets like 20,21,29.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I like how they get their terminology wrong, misusing the word, 'set'.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Sort the numbers and take it from there.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

man getpwuid

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What part do you need help on?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Your Personality Profile

[img]http://images.blogthings.com/worldsshortestpersonalitytest/black.jpg[/img]

You're stupid, obsessive, and dimwitted.
People avoid talking to you because you're so annoying.
You live a shell of a life, ignorant of the world around you, too tired and insolent to improve your circumstances.

While others socialize, you download porn off of Usenet.
You waste hours reading blogs, when you should be working.
Your parents have told you they wish you were never born.