Please help with my data structures and algorithms class

Well, perhaps I’m the lone voice in the wilderness, but I’ve never seen that OOP takes a new and different way of thinking. I’ve only seen the traditional and typical arrogance of the young, and of Computer Programmers in particular.

As in “I, a very young and inexperienced computer programmer, having only learned C, find OOP very difficult. It follows that older and more experienced programmers must find it even more difficult”

WRT to the original poster: If the course requires Java, they should have said so. If it doesn’t require Java, they should allow submissions in any language. This first problem does not require Java, it’s a cut-and-paste programming excercise. Very similar to the first excercise in the first programming subject I ever did, which had no programming requirement at all. ( I failed that excercise because I did not understand the question. )

It is possible to teach a data structures and algorithms class without specifiying a programming language. All the old data structures and algorithyms books were written that way. However, it looks likely that this DS & A subject will be using beginners Java.

A Java reference book would be nice to have. Personally, I think some guidence from a tutur and some fellow students would be better. So far, you’ve got that here, so it looks like you’re OK to continue.

Sure it does. Here is what it says:

Then I registered for the course and ordered the books and found it was “Data structures and Algorithms IN JAVA” and I kind of freaked.

I am muddling through it. Very kind people have offered to help me and look at all the help I am getting on this board.

I will use the code formatting to post here. I didn’t know there was one. The code in my homework is all properly indented, it is nearly impossible to understand without the indentation!

I miss Visual Basic. :frowning: I loved that course so much I’d glad to take it again instead of this crap. I mean, while I am doing it, and sort of getting it, I am still not 100% sure what this is actually accomplishing. Aargh. Mustn’t think like that - just gotta make it to July 11 (it’s an 8-week course).

Thank you all again. I have read each post thoroughly. I will get a few reference books and some people have volunteered to help me, and I have contacted my college to get a tutor. With all of this I should be able to at least pass the course.

Expecting students to learn the language completely on their own is reasonable in a fairly advanced CS course, not this one, which seems like a second-semester required course.

Anaamika: Understanding data structures and algorithms is what separates people who know how to design their own software to solve their own problems from people who muddle through merely typing code to realize someone else’s design. Data structures plus algorithms adds up to software, and that is true regardless of language.

Oh please, lambda calculus and turing machines are proven equivalent. Not to mention there are certainly ways to minimize locking primitives with procedural-derived models such as those shown in Communicating Sequential Processes (implemented to varying degrees by Erlang and Go). (I know you’re using hyperbole, but I sense a grain of sincerity in there, sorry if that sounded harsh).

Edit: Data structures and algorithms are very useful (and are the essence of programming), and can be done in theory land without any programming. The benefit of adding programming like Java is that it allows you to see results. Think of it as a lab vs homework in chemistry or physics. Making you use a specific language is, IMO, just a benefit for the people who have to grade your code. It would really suck if the TAs had to install Prolog, and Ruby, and OCaml, and VB .net, and… just to grade all the student’s assignments.

Out of curiosity, was it Visual Basic 6, or Visual Basic .NET? If it was the former, they are doing students a great disservice by even offering a class in a dead language that teaches few accepted best practices in modern languages.

Anaamika, keep going! You’ll get it down.

When I was in college, we had a couple of students who couldn’t program their own solutions, and were always asking one of us nerds for help on their homework. We’d show them, they’d copy it down, and then turn in the same program we wrote. It got old. Eventually, the teacher found out what was happening, and so, after we turned in our assignment, we had to write a description of our algorithm.

That turned out to be one of the better lessons I learned in that class: make sure you can describe your algorithm in a simple manner.

So, here is the simple description of the algorithm:

If there are no elements in the array, return -1.
Otherwise, set the variable "lngMax" to the value of the first element in the array.

Loop through the elements, starting with the second element in the array and continue through to the last element in the array.
    If the value of the current element is higher than "lngMax", then replace "lngMax" with that value.

After looping through the elements, return the value stored in "lngMax".

Some people “think in code”. Me? I think in words and do what BobArrgh mentions first. “I do this, and then I need a function that does <x> which then returns data in format <y> so then I can…”

= = = = =

In the late 70’s my first few class were in assembly language, everything I did after that in school in the early 80’s was in C. Every language I’ve encountered since then I can boil down fairly quickly. No big deal. New languages are just rehashes of previous languages shrouded in some new lofty paradigm. (yawn). Often they get in the way of doing actual work. I find the squandering of resources almost comical.

Hey Derleth, I like this : “Machines are a distraction and procedural programming is a virus that infects otherwise promising young programmers and corrupts and perverts their precious bodily fluids.” - I have a question. Do you actually work for a living?

Some people can travel around the world in a walk around the block. Others can travel around the world and never leave their own heads.

I think like this too. :slight_smile: I do not think in code. I never planned to be a programmer.

BobArrgh, thankfully, I can sort of follow the code. I’m not completely clueless, but basically I read code like I read Hindi - slowly, and with my finger. I’ll get there, but I certainly cannot glance at it and go “WOW! THAT’S WRONG!”

In that for loop J should be set to 0. As it is you are ignoring the first element in the array. The code will work as is, as long as the greatest number is not the first element.

max is being primed with the first element ( [0] ).

That’s what I get for not reading carefully enough.

Don’t feel bad, I almost posted the same thing until I double checked. It’s a common beginner mistake, so if you’re just skimming it because the lack of tabs make it hard to read, when you just see

for (int j = 1…

it’s easy to assume.

Spoken like a true person of leisure.

I think I’ve seen that on an inspirational poster with a waterfall and/or cat. Are you saying you’re a manager? :slight_smile:

:smiley: Too funny Space Vegetable, too funny. :smiley:

Anaamika, keep going! I’ve long been convinced that programming is really a way of breaking down a larger problem into smaller and smaller chunks until you have something you can solve easily, then putting all the bits of the solution together. Of course you need to learn some syntax, but really the verbal reasoning that **BobArrgh **mentioned is the basis of everything. If you can get that part clear, converting it into code is relatively easy.

I’m also helping my flatmate through a programming course for newbies (which they do in C, for some strange reason) and one of the things I emphasised is also what I call “being the compiler” - step through your code mentally, with a pencil and paper if you need to, keeping track of what you’re trying to do at each stage, and checking that you are getting the results you expect. I also (unintentionally) invented the catchphrase “less complaining, more compiling” which I trot out at every opportunity. You might enjoy reading about her adventures with introductory programming here and here.

So I never came back and posted, and thought I would do so now - I got an A in the class! I sweated and toiled, using a Java training class I found on the Internet, tutors, and friends. I did most of the assignments all by myself and then ran them and ran them and ran them until they worked. A couple I needed major help with, and I got it.

Whew!

Congratulations! It’s such a thrill when you can take something that seemed esoteric and strange and make it sit up and beg.