In the beginning was the Tao. The Tao gave birth to Space and Time. Therefore Space and Time are the Yin and Yang of programming.
Programmers that do not comprehend the Tao are always running out of time and space for their programs. Programmers that comprehend the Tao have enough time and space to accomplish their goals.
How could it be otherwise? – The Tao of Programming
https://iudatastructurescourse.github.io/course-web-page-fall-2024/
Write your name on a “name tent” and place it at the front of your desk
Slack: ask and answer questions
Before each lecture, read the assigned chapters. Do the textbook exercises as you read the chapters. The lecture should feel like a review with a few extra tidbits. Humans learn by repetition. If you don’t read, then you’re going to have a hard time understanding the lecture.
Labs are every week. They will include a mixture of programming exercises, lecture review, help with homework and projects, and 15 minute quizzes.
Homework (textbook exercises), 6 total for the semester
Projects, about 1 per month, groups of 2-4 students. To complete the projects, you’ll typically need a firm understanding of the lectures from the previous two weeks and the Homework.
IntelliJ: Learn to use an Integrated Development Environment (Text Editor + Debugger)
Autograder for submitting assignments
Deduce proof assistant.
Optional: learn github for managing group work
ChatGPT/AI: you can use it but beware that if you use it to avoid learning, then you are likely to perform poorly on the midterm exam and final exam (60% of the course grade).
Find the section of the Tecumseh Trail Marathon with the greatest net increase in altitude.
change: -25, -100, +100, -25,-75,-125,+100,+100,-25, +75, -50, -100
0 1 2 3 4 5 6 7 8 9 10 11
We want the contiguous subsequence with the largest sum. This is also known as the Maximum Subarray Problem.
Brute force: try every pair of locations
The time it takes, given an input array of size n, is
n choose 2 = n * (n-1) / 2
which is roughly n².
Divide-and-conquer: Cut the array in half, then consider three cases:
Cases 1&2 are the same problem but smaller -> recursion Case 3 needs work:
Analysis of the time complexity:
The crossing-subarray is linear, that is, c * m where m is the size of the subarray.
Recursion tree:
c*n = c*n
/ \
c*n/2 c*n/2 = c*n
/ \ / \
c*n/4 c*n/4 c*n/4 c*n/4 = c*n
...
What’s the height?
At the bottom, at a leaf, we have n/(2^h) = 1. We want to solve for h, so we isolate the 2^h term on one side.
n = 2^h
Then we take the log of both sides. (Recall that log (2^x) = x for any x.)
log n = h
Total work is c * n * lg n, so the time for this divide-and conquer algorithm for maximum-subarray is is roughly
n lg n