Related
At once I am not particularly angry about this issue, maybe it is not for this site). So I recently became interested in artificial intelligence, but Mey concerned about how to do it, I wrote a small program that imitate it:
import java.util.Scanner;
public class ai1 {
/**
* #param args
*/
public static void main(String[] args) {
System.out.println("Ask fo me: ");
Scanner sc = new Scanner(System.in);
String line = sc.nextLine();
if(line.equalsIgnoreCase("hello")){
System.out.println("hello friend)");
}
}
}
But as you know, that such a program would be a lot of construction:
if{
}
The more it will take a very long time and just can not write. What do you think, how you can still make a prototype artificial intelligence, that he gave something original?
Maybe you have any ideas?
Just say, I'm not trying to make the analogy of the brain, I just want to write the Intellectual interlocutor who can learn and talk with me for a long time. Thank you in advance for your answers.
UPD
Java may not be very suitable for this, but it's the only thing that I know of)
UPD 2
Maybe there are examples of such programs interlocutors, or sites where a lot of material as they build
(It is desirable that they were on Java)
UPD 3
The main question that I'm interested in how to make it learner
I respectfully disagree with Greg0ry's answer. If you really want to learn about neural nets, implement one yourself. It's not that hard, but it will take you a few days. You should be prepared to read a lot. It took me a few days of writing some sample code and reading before I was able to design my network. But let me tell you, it's worth it! There are also a lot of resources out there. A good starting example is to implement an XOR gate using neural networks, which should give you a good starting-point.
If you're interested, you can check out my example code here. It's quite simple since it was a hobby project and it's not as complicated as the other projects out there. I also have a video that explains the backpropagation algorithm.
Couple of years ago I was in similar situation, I was astonished with neural nets and wanted to implement them myself. But after all this time I can only advice - don't bang your head against the door that is already opened. Reuse somebody else work - in particular I can advice using FANN which, as far as I'm aware, might have some wrappers to JAVA (it's C++ library).
edit
As mentioned above you do not need to implement neural networks by yourself in order to understand it; I encourage you to check this video out: machine learning
This is just a single lecture of quite nice course provided by free on-line learning initiative of MIT, Harvard and number of other universities - check out here
Indeed there is much more to truly understand neural networks than just implementing it. You might successfully implement it, maybe even some nice learning algorithm and still you would not understand what you are doing. I'm telling this basing on my experience - I thought once that I will understand things just by building it and I can tell you this is a waste of time. Do study first to truly understand the subject, become an expert of it and while studying use open source materials provided by number of communities - like FANN and then, once you understand the field you may want to implement something to solve your specific problem and what more important you may improve solution developed by community of your choice so others can make use of your time and intelligence!
So I wish you happy studying :-)
I was wondering if anyone could please point me the right direction on how to approach the scheduling problem.
I have a teacher/student timetable problem, where I have teachers that teach certain subject at certain times and students that have preferences as of which class they want to take an when. The goal is to create a timetable not necessarily optimal solution.
I looked around here and there is a great number of discussions here on this website on this topic and the ones that I found go from super general to excessively difficult and I am currently unable to understand which programming/logic concepts to use to at least conceptualize the program work-flow.
Could anyone that dealt with similar problems explain how these types of problems are dealt with. I do not need the code (although pseudo-code would be awesome), but some guidelines ie step#1 - do this, step#2 - do that, step#3 - do etc....
Also, are there any libraries that are available that can do scheduling with preferences effectively and that have fairly straightforward inputs?
Many thanks!!
here is the outline of a problem that I have.
Let's say I have a group of salespeople:
The goal is to create a schedule that pairs buyer and seller subject to time availability and preferences.
This is a course time-tabling problem, right?
Can I accomplish with Drool Planner?
Take a look at the curriculum course scheduling problem which schedules lectures of teacher and students into timeslots and rooms. Take a look at my open source implementation in Java or just download and run the example.
I 've configured the construction heuristic First Fit Decreasing with the metaheuristic Tabu Search. I tried other configurations too, see my benchmarker config.
First you should make a list of resources for your problem. Then you should write down the constraints and set up a mathematical model. Finally you can use some optimization tool to generate solutions.
Of course this is not as easy as it seems to be. This page may give you some insight about possible solutions.
Matlab has a Global Optimization toolbox which lets you do genetic algorithm optimization with a very simple, point-and-click GUI that has helpful documentation. From what wikipedia says, your problem is just the kind to solve with a GA.
If you don't have access to the toolbox, you should be able to find genetic algorithm libraries for java, or worst comes to worst you can write your own. It won't be as extensive and it will take some work, but it shouldn't be terribly hard to make a simple one.
So for the summer I decided that I may as well start learning algorithms before school starts. I've been told that the class is fairly fast paced, and that algorithms isn't something you should take lightly (I have a tendency to do this with all the course work during the semester lol).
The book we're going to use is this Algorithms (4th Edition).
Anyway, this is my problem.
I'm almost third way through the book, but I just realized what I was doing. For example, I would read and re-read the sections I don't quite understand. Then if I feel confident enough, I would try to reproduce the same algorithm in java from my head. But by doing this, my code looks almost exactly like the ones in the book..in java.
I can't say I'm just memorizing code after code--I do understand the concepts and they help me code these algorithms--but I feel like I'll only be able to implement these algorithms in java. I should note that I only know java at the moment.
tldr: I'm learning algorithms as if I'm learning to play the guitar--repetition after repetition. But by doing so I feel like I'm being more fixated that I'll only able to implement these in java. How exactly would you learn algorithms if the book you're using is language-specific?
Thanks in advance.
Don't Confuse Yourself
You're studying Java, so write them in Java. Especially if Java is your first language. Don't confuse yourself for now, as you are trying to learn 2 things at once: how to progam in Java, and how to progam. You're learning both a new language and a way of thinking. Don't do too much but adding another language to the sauce for now.
Diversify
Later on, or if you feel confident enough that you can take on another language simultaneously, then it would obviously be beneficial to learn another one and try to replicate the algorithms without looking at the book.
Reproduce and Extend
What we could recommend you is to look for derivates of the algorithms. Known variants, that have been documented, and where you could just read the description of the variant so you can try to implement it from the "base" version, without needing to read the book.
For instance, if your book introduced you to a linked list, you should be able to come up with the algorithm for a doubly-linked list or a circular linked list without reading more than a description of the desired outcome. Or there's something about the original concepts that you clearly misunderstood.
Try First, Read-On Later
I'd recommend you actually even try to implement the algorithms described in your book before they show them to you. The point of seeing Sedgewick's algorithm is to see a canonical implementation, which is considered a standard blueprint. If you just read the section leading up to the implementation (which hopefully is displayed first), then just sit down with the book, and try to figure out how you could do that. If you can't do that at all, then you're too far ahead in your book and should backtrack and start again from scratch.
Thing about algorithms, they're essentially language-agnostic. There's really nothing stopping you from doing Sedgewick's examples in C, Python or some other language.
If you really don't know any other languages, concentrate on Java. Sure, its a bit repetitious, but those bits will stick in your head in a good way and come test time, you'll be glad for the information.
You're in an interesting position right now, since the kind of thinking required to write programs is very different from normal thinking. Add to that the fact you're learning a whole new language with a different syntax, punctuation and the like. Practice really does make perfect, since there are many bits and pieces to remember.
Oh, if you want practice with algorithms, try out project euler, code kata and other challenge sites. These little challenges can help you familiarize yourself with the language as well as get comfortable with the type of thinking required.
First, congrats on taking your first steps on learning how to code. I would say that you are already ahead of your peers by starting to look ahead during the summer.
As far as your fears on only being able to implement algorithms in Java, you have already demonstrated that it will not be a problem for you. It sounds like you are passionate enough to get started early so you should have no problem implementing a solution in multiple languages. Additionally most of the languages with C/C++ (Java and C# to name a few) like syntax will be similar enough that you will be able to translate your knowledge seamlessly.
The best advice that I can give is to CODE, CODE, CODE!! Don't just read about the algorithms actually implement them.
You don't say how well you know the mathematics behind the algorithms. That will be key in determining your facility with the code.
Sedgewick's books are very good. I'd feel free to pick some and check out other books as well, like "Numerical Recipes" and "Numerical Methods That Work". See if another point of view can clarify for you.
If you don't feel like you're getting enough out of copying Java, see if you can translate them into another language, maybe Python or purely functional alternative. If you can do that, you'll know you've got it.
I would either try to learn another language to verify that you can actually port it to another language (javascript would be my vote because it is simple and useful on the front and backend) or write the algorithms out in pseudocode since that is more language agnostic. Most languages will have the code look pretty similar. The only thing to be very careful about is when you are relying on some aspect of the language (such as generics or iterators in java) which you may not be able to use in another language and that could leave a gap in your understanding.
Another way to verify that you actually understand the algorithm is to make slight changes in the problem and make sure that you can adjust the algorithm to still work. For example if it is a sorting algorithm then try to sort by several different attributes rather than just one, if it is a graph algorithm make the graph a digraph and see how things should change.
I'm learning algorithms as if I'm learning to play the
guitar--repetition after repetition.
Then you are not learning algorithms. You are learning repetition. Two different things. The usage of a programming language by an algorithms book is a secondary factor. It is just a vehicle of instruction, an implementation detail.
What you should be focusing is on understanding the structure, logic and mathematical characteristics of an algorithm (and possibly the data structure(s) associated with it.)
That's what your focus should be.
But by doing so I feel like I'm being more fixated that I'll only able
to implement these in java.
But that is because you are focusing on just how the algorithm is being coded (in Java in this particular case.) You are focusing on an implementation detail.
When you learn to drive, you don't focus on how you learn to drive a Honda Civic or a Nissan Maxima. You learn the essence of what driving is, the rules of thumbs, the necessary precautions and the laws governing driving a vehicle.
Same with learning algorithms. You don't learn "Algorithms in Java" no more than "Algorithms in Haskell". You learn Algorithms first and foremost, the vehicle (sans very specialized cases) is secondary.
You should be focusing on what the algorithm does, how and why. Questions like "how/why does it work?" and most importantly *"what are the performance characteristics?", those are the things you should be focusing on.
Every good algorithms book (Sedgewick's included) carry that message. That's what you should focus on. How you get to that re-focusing, that's a function of one's personal learning strategies.
How exactly would you learn algorithms if the book you're using is language-specific?
By not focusing on the language. Focus on the structure, focus on the data structures involved, the invariants, pre-conditions and post-conditions. Understand asymptotic behavior described in Big-O (or Big-Omicron), Little-O/Little-Omicron and Omega notations.
You are learning algorithms, not programming in Java via coding algorithms.
If you can't do this mental leap, it means you do not have sufficient practice or abstract analysis. It is not an insult, but an observation and an advice. Coding, the usage of a programming language is typically secondary to the mathematical analysis of computing, the focus of Computer Science (of which Algorithms is a part thereof.)
NOTE I've done Java for over 10 years, and though I like it for work, I strongly believe it is a poor tool for learning programming or CS topics.
One is better served by learning Algorithms with either A) a procedural, systems-level programming language like C or Ada, or a high-level pseudo-assembler simulator, or B) a functional language like Lisp or Haskell.
Object-Oriented features in pure/pseudo-pure OO languages simply get in the way.
Algorithms are mathematical structures with a nature descriptive of the how (operationally) and/or the what (mathematically). The former is perfectly suited for procedural programming, the later for functional programming.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I come from a background of 1 year programing in html/css/javascript/jQuery and 6 months in Java's JSP Servelets.I am in the 2nd year of college and in the last semester of the second year I didn't passed Functional Programing course in which we were learning Haskell(maybe mostly because i mised 90% of the clases). Seems in my second year I will also have a course in witch Haskell is involved so learning just the basics wont be enough.
What I am interested in is:
-the differences between OOP programming and function programming
-what book is recommended for a beginner in functioning programing using Haskell(I cant seem to make head or tail of what the professor wrote)
-where to go to practice the language after I'm done with the book
-what can I do with Haskell and cant do in Java
-do I need a lot of Math for understanding Haskell(My college professor used a lot of math related stuff in hes course)
the diferences beetween OOP programming and function programming
From your background, you probably don't know enough about OOP for comparisons to be useful. Just forget about it and learn functional programming as itself.
what book is recomended for a beginer in functioning programing using Haskell(I cant seem to make heade or tales of what the profesor wrote)
Everyone else keeps mentioning Learn You A Haskell for a reason. :]
where to go to practice the language after I'm done with the book
On your computer? Get the compiler, get a code editor, start programming. Learning by doing is the best way.
what can I do with Haskell and cant do in Java
Trivially, nothing. Both languages are capable of doing anything you might want to do, the end.
And again, you haven't spent enough time with Java for comparing the languages to be helpful anyway, so just learn Haskell as itself.
do I need alot of Math for understanding Haskell(My coledge profesor used a lot of math related stuff in hes course)
Not really. A little bit of discrete math and formal logic helps, though, but that's the sort of stuff you should get in any CS program anyway.
If you missed most of the lectures, then I haven't got a lot of sympathy. But I'll try to help.
1: Differences in OOP and Functional: big question. For now, I would try to approach Haskell with an open mind rather than trying to understand it in terms of its difference from OOP.
2: "Learn you a Haskell" and "Real World Haskell" are both available on the Net.
3: Work through the exercises in the books. Then look at the exercises in Project Euler.
4: Both are general purpose languages, so any application can be written in both. Haskell enables greater type safety and shorter code.
5: No, but the maths helps you understand it at a deeper level. I picked up the relevant math as I went along. Look up maths terminology on Wikipedia, and don't sweat it too much.
Start with Learn You a Haskell for Great Good. Also, look at the design of the jQuery library, as many of its features are designed around functional programming techniques.
Also, I highly recommend that you spend some time brushing up on your English skills as well. In my opinion, programming is a least as much about language as it is about math. From your comments so far, I suspect that your approach to both has been somewhat sloppy. That's going to be the hardest thing to overcome. As a general rule, programming systems are quite rigorous, and one way or another you'll need to learn to be more precise in the way you organize your thoughts.
i go with the opinions above - missing lectures is a bad thing and good English is a nice skill to have.
Of course - the already mentioned Learn you a Haskell for great good - is the location to start with.
Here are recordings of an exercise class in Germany, but the spoken language is English (with german accent).
And one thing you also should be aware of is: Hoogle, one if not the greatest things when it comes to learning haskell (imho) - a type searchable documentation:
if you search for a function that pulls out the end of a list - but you don't know the name:
hoogle: [a]-> a
lists all functions that have the given type signature - last, which is the function you looked for, is one of them.
Another thing - helping me develop my haskell skills is - syntastic in vim, a syntax checker, which sped the "compile - check - run"-cycle up by a massive amount, and hlint - a linting tool, that makes code much more readable - and shows you unnecessary stuff you added to your code, I really learned stuff from tiding up my code that way.
For starting with IO - there's this great article. It is also a great introduction how experienced functional programmers think.
And for advanced stuff and getting to know monads there is the Monad Reader recent stuff, older stuff a worthy thing to attack, I've heard, especially #13.
if you already know and like Java have a look at Clojure
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
So do I really need to learn about them ? Isn't there an interesting way to learn about stacks, linked lists, heaps, etc ? I found it a boring subject.
**While posting this question it showed some warning. Am I not allowed to post such a question ? Admins please clarify and I will delete it :/
Warning :: The question you're asking appears subjective and is likely to be closed.
okay..I get it
So what is THE best way to learn them ? What book do I refer ? What website ?
It's compulsory to learn about data structures if you want to be a programmer. Data structures are your bread-and-butter - if you don't understand things like the behavior, uses, and run-time complexity ('big-O') of at least the basic structures (arrays, linked lists, stacks, queues, trees (binary / n-ary, self-balancing varietes), hash-tables, heaps, graphs) and the algorithms that run on them (insert / locate / delete), you won't know which is appropriate to use under what circumstances.
Every trade has its tools; these are ours. Data structures are the most basic underpinnings of almost any algorithm that you're going to learn. Unless you want to be a cargo cult programmer, you need to understand how they work.
Whether or not there are interesting ways to learn about them is a separate question entirely... :)
I would go even so far as to say that most of programming revolves around manipulating data structures, it is the foundation of computing after all: you get some data, you process it, you possibly give output. All the data usually reside in data structures and choosing inappropriate structures will have the bigger impact the bigger the project.
As you get more experience you will find that algorithms and datastructures are invaluable to your day-to-day development, and actually pretty interesting.
By learning about them now you will learn:
Which data structure is appropriate for which context, i.e. when to use a single-linked list, when to use a stack, when to use a queue, when to use a tree
Which algorithms are appropriate for which purpose, such as tree depth-first search or breadth-first search.
Space and time complexity of algorithms, for example why is a quicksort sometimes the best solution, and sometimes heapsort.
Overall it'll teach you the beginnings and fundamentals of computer science, even if you never have to implement a stack again you'll know the kind of thought and consideration that goes into it. If you then ever have to implement your OWN data structure (and chances are you will, quite often), you will know what to do and what not to do.
If you want to be a successful programmer, data structure is a must. How will you program if you don't know data structures and algorithms?
Whether you like it or not, all programming is built around data structures. You may never have to write one, but you will have to choose which one to use many times. It is not really a requirement to programming in general, but if you want to excel in the field, understanding of the basics is a must.
Anyone can build a shed without knowledge of materials or construction techniques. You can even work in a house placing bricks and mortar under the orders of someone else, but if you want to build a house yourself, you do need to understand materials and techniques.
Data structures are the programming materials. Algorithms are techniques. Will you use data structures? You will use the simplest ones in a daily basis, each so often you will need to solve a problem where an specific data structure is required, and while you may manage not to build your own bricks, you will need to understand whether you need bricks or a concrete wall for your purposes.
If you want some evidence for the importance of data structures, take a look at the Google hiring process. Whatever you think about Google as a company, there is no denying that they have some very good people working for them. Their interview process is setup to determine the candidates knowledge of data structures and algorithms. Because when it comes down to it, that is what is at the core of programming, no matter what language you are working in or what domain you are programming for.
If you are planning a career as a professional programmer, you need to know the fundamentals, not just how to crank out code that "works". Otherwise, your just playing.
Is it compulsory to learn about arithmetic to be an engineer?
If you take the attitude of "is it compulsory" with regards to any of the building blocks of programming languages, you're probably not cut out to be a coder. Regardless of "compulsory" or not, you should always be looking for new concepts to learn and seeing if it'll improve your coding style/standard.
But in answer to your question: yes.
I'd say it's compulsory at some point in your development to have a firm grasp. I'm not necessarily sure the standard Data Structures course is the best way to learn. Sometimes, the best way to learn them is "I have problem X. For some reason, it's taking my algorithm a long time to solve X. How can I make this faster?"
One book I'd highly recommend is Programming Pearls. It has some really good analyses, backed by a lot of examples of where the real-world motivations for the solutions came from. It presents the problems in an interesting manner, and never teaches by giving you a laundry list of data structures.
Yes 99% of books on Data Structures are boring and exercises contrived. They feel like they are just making up problems that server no practical purpose :(
This book is the one exception to the rule I've come across. You will have a naive but working RPG game by the end of the book:
Data Structures for Game Programmers
Read the above book and you will solve your chicken and egg problem and see you really can't do much without data structures after all.
Well, this may sound a little awkward but I wouldn't say it is COMPULSORY to learn Data Structures to be a - regular- developer. Seriously! Of courser if you study then hard it will give you a lot of insights and knowledge on several programming aspects and that's always good. But compulsory ... well, I think it is just too much. VERY GOOD would be enough.
Let me explain why. It is not that often, for today, to write Data Structures code because - let's face it - it would be RE-writing, RE-inventing what we already know for so many years! What I would say it is COMPULSORY is to study just the general theory of them and the APIs/libraries that are already commonly in use (and tested and optimized) like the Collections API in Java. You must know by heart the differences between a List and a Set (in Java for instance) and their capabilities and proper usage but you don't need to know exactly HOW they are implemented - checking every private method and attribute - to deal with most common, day to day, coding problems. You will do just fine without all the "guts" of Data Structures for the general stuff. We face different challenges now.
But don't get me wrong - neither think I am crazy or naive! Off course there are situations that you will need to implement yourself some sort of custom data structure (maybe your own BalancedBinaryTreeMap!). You got to be prepared for everything.
I am just arguing about being compulsory or not. Again, I don't think is compulsory but it is indeed very good.
Cheers.
I suppose you could learn programming without learning a whole lot about data structures or algorithms. To make an equivalent example, think of it like if a carpenter knew how to build things, but didn't know about measurements and such. Would he be able to get a career in carpentry? Possibly, but let's say he needed to know the exact material he would need to complete a project. He'd probably get fired because he doesn't know what sort of material or measurements to use.
So with data structures and algorithms, you can say it's the ability to give exact measurements of an application and knowing what sort of performance you'll get out it.
Like a musician learning scales, data structures are part of the tools of the software trade. Sure you can work as a programmer without the knowledge but you're handicapping yourself. If I'm interviewing two people for a position and one of them understands and uses structures and the other can't even explain what a stack is, my choice is pretty clear.
If you want to be judged to be a competent, employable programmer, you need to learn your craft.
Is it compulsory to learn them?
No, you can program without them, just as it's not compulsory to break your code into functions.
That being said, if you want to be an effective programmer that can write at least decent code without getting your car egged by your coworkers, you want to at least be able to make a decent selection of library classes.
Every programmer should understand the tradeoff between a LinkedList and an Array, or why binary searches and binary trees are useful for sorted data. This isn't just about performance - it's about correctness too since you can't just put anything into a tree set.
Does it mean that you need to know how to implement your own AVL tree, build super-smart data structures, etc.? Not necessarily. It's a matter of how much you want to know what's going on "beneath the hood" and whether your tasks necessitate it.
I'm not a big fan of deep data structure and algorithms questions in interviews because the vast majority of developers don't need to implement these things, just to use library stuff. I prefer to ask job related questions in interviews. However, accept that if you don't learn those things you would face a tougher battle to get other jobs.
It should be, yes...
No body should force you to learn anything you don't want to learn.
If you're the type of person that is compelled to be the best that he/she can be at what he/she does, and you love what you do for a living, you'll learn everything there is to know on your own accord.
#happysoul: You should ask yourself WHY learning data structures bore you. Also, it would help if you also identify what DOESN'T bore you.
If you at least love to learn about algorithms, I'm sure we can all suggest a perfect marriage of the two that would be exciting to learn!
My recommendation for best algorithm/data structure combo for the most fun learning experience: graphs.