Course web page for Data Structures H343 Fall 2022
View the Project on GitHub IUDataStructuresCourse/course-web-page-fall-2022
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
Brooke Augustine
TBD
https://iudatastructurescourse.github.io/course-web-page-fall-2022/
Write your name on a “name tent” and place it at the front of your desk
Slack: ask and answer questions if not on slack, send me email
Before each lecture, read the assigned chapters. Do the textbook exercises as you read the chapters. Do the pre-lecture exercise. 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.
Learn to use and Integrated Development Environment such as IntelliJ (Text Editor + Debugger)
Autograder for submitting assignments
Optional: learn github for managing group work
Find the section of the Tecumseh Trail Marathon with the greatest net change in altitude. Show TecumsehMarathon.pdf.
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