# Please help with my data structures and algorithms class

**URL:** <https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142>\
**Category:** Factual Questions\
**Created:** [May 24, 2014, 1:24am UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142 "2014-05-24T01:24:49Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Melbourne](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Melbourne](https://boards.straightdope.com/u/Melbourne)\
**Post date:** [May 25, 2014, 9:27am UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/21 "2014-05-25T09:27:35Z")

</div>

> [@Senegoid](#):
>
> OOP programming seems different enough from older “procedural” programming (like VB, sort-of) that it takes a new and different way to thinking to learn it.

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.

---

<div class="post-metadata">

**Author:** ![Anaamika](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@Anaamika](https://boards.straightdope.com/u/Anaamika)\
**Post date:** [May 25, 2014, 3:35pm UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/22 "2014-05-25T15:35:19Z")

</div>

> [@Little\_Pig](#):
>
> I find it hard to believe that there were no prerequisites listed anywhere in the course description for this class.

Sure it does. Here is what it says:

> [@](#):
>
> This study is intended to help students develop an understanding of Data structures and Algorithms, which are fundamental to computer science and software engineering. The real-world performance of software is strongly influenced by:
> 
> 1. The choice of appropriate data structures for storing the software’s data in order to effectively store, manipulate, and retrieve the data values;
> 2. The use of algorithms that are appropriate and efficient across the various layers of system implementation.
> 
> This study will focus on good principles of algorithm design, elementary analysis of algorithms, and fundamental data structures. The emphasis is on the selection of appropriate data structures and designing correct and efficient algorithms to operate on these data structures.  
> To reinforce student learning, the deliverables of this study will be assignments and a final term project.
> 
> Prerequisites: A programming language study.

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. ☹ 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.

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [May 25, 2014, 8:34pm UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/23 "2014-05-25T20:34:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jragon](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jragon](https://boards.straightdope.com/u/Jragon)\
**Post date:** [May 25, 2014, 8:44pm UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/24 "2014-05-25T20:44:10Z")

</div>

> [@Derleth](#):
>
> How It Really Works is the untyped lambda calculus. 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 use the paradigm, mind you, but I deny it my essence, Mandrake. Only though side-effect-free absolutely composable functions can our Purity Of Essence be restored. That’s why I only drink Haskell and pure grain alcohol… where was I? Oh, yes: Side effects are the enemy of comprehensibility and parallelism. Even if you sneer at the plebs who can’t keep track of 50 state variables across a 10,000 line program, your state-mutating masterpiece is going to be limited to a single core on a single machine without the Main Effort required to add locking primitives, suffer deadlocks, and re-write everything to add locking primitives _correctly_ this time.

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.

---

<div class="post-metadata">

**Author:** ![ptr2void](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ptr2void/32/3406_2.png) [@ptr2void](https://boards.straightdope.com/u/ptr2void)\
**Post date:** [May 25, 2014, 8:48pm UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/25 "2014-05-25T20:48:18Z")

</div>

> [@](#):
>
> I miss Visual Basic.

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.

---

<div class="post-metadata">

**Author:** ![BobArrgh](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bobarrgh/32/2881_2.png) [@BobArrgh](https://boards.straightdope.com/u/BobArrgh)\
**Post date:** [May 25, 2014, 10:34pm UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/26 "2014-05-25T22:34:25Z")

</div>

**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".
```

---

<div class="post-metadata">

**Author:** ![Jragon](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jragon](https://boards.straightdope.com/u/Jragon)\
**Post date:** [May 26, 2014, 2:12am UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/27 "2014-05-26T02:12:02Z")

</div>

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…”

---

<div class="post-metadata">

**Author:** ![Little\_Pig](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@Little\_Pig](https://boards.straightdope.com/u/Little_Pig)\
**Post date:** [May 26, 2014, 3:14am UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/28 "2014-05-26T03:14:50Z")

</div>

> [@Derleth](#):
>
> And they should have known better even back then. There are different styles of language, with vastly different approaches to writing software, and … well, you’re a programmer, so compare Prolog to APL to Cobol. Do you really think someone conversant in one will be much use in any of the other two without a lot of re-orientation and starting mostly from scratch?
> 
> Java is less OO than some OO languages, although I agree it takes it too far. VB is pretty OO as well, in fact, especially [VB.Net](http://VB.Net) (which is different enough from Original VB that old-style VB programmers call [VB.Net](http://VB.Net) “Visual Fred”: They think the name should change as much as the language has.)
> 
> Besides, OO is 99.9% procedural at heart. In fact, it allows the worst excesses of procedural programming (global state, side-effect-heavy programming) to flourish within the confines of an object, so a veritable army of low-skilled programmers can work on a project without immediately causing it to collapse.
> 
> How It Really Works is the untyped lambda calculus. 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 use the paradigm, mind you, but I deny it my essence, Mandrake. Only though side-effect-free absolutely composable functions can our Purity Of Essence be restored. That’s why I only drink Haskell and pure grain alcohol… where was I? Oh, yes: Side effects are the enemy of comprehensibility and parallelism. Even if you sneer at the plebs who can’t keep track of 50 state variables across a 10,000 line program, your state-mutating masterpiece is going to be limited to a single core on a single machine without the Main Effort required to add locking primitives, suffer deadlocks, and re-write everything to add locking primitives _correctly_ this time.

= = = = =

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?

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [May 26, 2014, 4:38am UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/29 "2014-05-26T04:38:31Z")

</div>

> [@Little\_Pig](#):
>
> = = = = =
> 
> 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.

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.

---

<div class="post-metadata">

**Author:** ![Anaamika](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@Anaamika](https://boards.straightdope.com/u/Anaamika)\
**Post date:** [May 26, 2014, 3:25pm UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/30 "2014-05-26T15:25:49Z")

</div>

> [@Jragon](#):
>
> 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…”

I think like this too. 🙂 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!”

---

<div class="post-metadata">

**Author:** ![whyizjay](https://avatars.discourse-cdn.com/v4/letter/w/e495f1/32.png) [@whyizjay](https://boards.straightdope.com/u/whyizjay)\
**Post date:** [May 26, 2014, 4:11pm UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/31 "2014-05-26T16:11:30Z")

</div>

> [@Anaamika](#):
>
> I thank you all for your help. Sadly, my library is closed all weekend, so i will muddle through as best I can through this weekend’s assignment with your help and then on Tuesday head over there and pick up a bunch of books to help me along.
> 
> VB made so much sense to me and I really enjoyed the course. But people teach themselves Java all the time! And I am not dumb…just not that great at programming.
> 
> BTW, here is my answer to that question. Thoughts?
> 
> I put it right before this section:

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.

---

<div class="post-metadata">

**Author:** ![RaftPeople](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@RaftPeople](https://boards.straightdope.com/u/RaftPeople)\
**Post date:** [May 26, 2014, 4:18pm UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/32 "2014-05-26T16:18:04Z")

</div>

> [@whyizjay](#):
>
> 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] ).

---

<div class="post-metadata">

**Author:** ![whyizjay](https://avatars.discourse-cdn.com/v4/letter/w/e495f1/32.png) [@whyizjay](https://boards.straightdope.com/u/whyizjay)\
**Post date:** [May 26, 2014, 4:21pm UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/33 "2014-05-26T16:21:08Z")

</div>

> [@RaftPeople](#):
>
> max is being primed with the first element ( [0] ).

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

---

<div class="post-metadata">

**Author:** ![Jragon](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jragon](https://boards.straightdope.com/u/Jragon)\
**Post date:** [May 26, 2014, 8:37pm UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/34 "2014-05-26T20:37:08Z")

</div>

> [@whyizjay](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![Little\_Pig](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@Little\_Pig](https://boards.straightdope.com/u/Little_Pig)\
**Post date:** [May 27, 2014, 2:29am UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/35 "2014-05-27T02:29:43Z")

</div>

> [@Derleth](#):
>
> 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.

Spoken like a true person of leisure.

---

<div class="post-metadata">

**Author:** ![Space\_Vegetable](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Space\_Vegetable](https://boards.straightdope.com/u/Space_Vegetable)\
**Post date:** [May 27, 2014, 3:03am UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/36 "2014-05-27T03:03:27Z")

</div>

> [@Derleth](#):
>
> 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 I’ve seen that on an inspirational poster with a waterfall and/or cat. Are you saying you’re a manager? 🙂

---

<div class="post-metadata">

**Author:** ![Little\_Pig](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@Little\_Pig](https://boards.straightdope.com/u/Little_Pig)\
**Post date:** [May 27, 2014, 3:29am UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/37 "2014-05-27T03:29:42Z")

</div>

> [@Space\_Vegetable](#):
>
> I think I’ve seen that on an inspirational poster with a waterfall and/or cat. Are you saying you’re a manager? 🙂

😃 Too funny Space Vegetable, too funny. 😃

---

<div class="post-metadata">

**Author:** ![Dervorin](https://avatars.discourse-cdn.com/v4/letter/d/eb8c5e/32.png) [@Dervorin](https://boards.straightdope.com/u/Dervorin)\
**Post date:** [May 27, 2014, 1:03pm UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/38 "2014-05-27T13:03:56Z")

</div>

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](http://inamerryhour.wordpress.com/2014/02/22/how-c-built-the-pyramid/) and [here](http://inamerryhour.wordpress.com/2014/04/13/mooc-overload-or-the-day-the-code-came/).

---

<div class="post-metadata">

**Author:** ![Anaamika](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@Anaamika](https://boards.straightdope.com/u/Anaamika)\
**Post date:** [August 25, 2014, 8:14pm UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/39 "2014-08-25T20:14:51Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Inner\_Stickler](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/inner_stickler/32/318_2.png) [@Inner\_Stickler](https://boards.straightdope.com/u/Inner_Stickler)\
**Post date:** [August 25, 2014, 8:28pm UTC](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142/40 "2014-08-25T20:28:56Z")

</div>

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

[Previous page](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142.md?page=1)

[Next page](https://boards.straightdope.com/t/please-help-with-my-data-structures-and-algorithms-class/689142.md?page=3)
