Fun question for all the CS nerdz out there:
What is the simplest and/or most efficient function you can write to determine whether a given string has balanced brackets or not?
- Balanced: “(This is balanced)”
- Not Balanced: “(((This is *not*) balanced.”
bool stringHasBalancedBrackets(string inputString)
The function should return true if the brackets are balanced, otherwise false.
(BTW, there is a great solution on Stack Overflow; I’m looking to see what everyone can come up with off the top of their heads.)
My CS300 professor at Portland State University just wrote a fantastic blog post about things he commonly sees in student source code – it’s a great read and helpful for reflecting on your own code and best practices:
I’ve read quite a lot of student code over the years. Some of it is quite good. A lot of it is full of predictable badnesses. These notes attempt to enumerate some of this badness, so that you may avoid it.
This is pretty C-centric in its current form. However, many of its lessons are multilingual. This is a living document, so don’t expect it to be the same next time you look at it. In particular, the numbering may change if something gets inserted in the middle. It is revisioned automatically by Drupal, so feel free to point at a particular revision if you care.
via Things I see in student code | FOB.
Excellent Computer Science resource with tutorials and Java code examples at mycsresource.net – this was very helpful to me in my CS courses…
Linked Lists are a very common way of storing arrays of data. The major benefit of linked lists is that you do not specify a fixed size for your list. The more elements you add to the chain, the bigger the chain gets.
There is more than one type of a linked list, although for the purpose of this tutorial, we’ll stick to singly linked lists (the simplest one). If for example you want a doubly linked list instead, very few simple modifications will give you what you’re looking for. Many data structures (e.g. Stacks, Queues, Binary Trees) are often implemented using the concept of linked lists.
via Linked Lists Tutorial, Examples, and Java code.