Lecture 1 Ch 1
Course Structure and Grading Components
The course syllabus is the foundational document that contains essential information regarding structure, grading, and policies. It must be read in its entirety.
Grading is divided into four primary components:
Research Online on D2L: These assessments feature multiple attempts to encourage mastery.
Labs: Sessions focused on hands-on coding. These are not tests but opportunities to practice with assistance from a Graduate Teaching Assistant (GTA) and a Undergraduate Research Assistant (URA).
Attendance is required to receive feedback on code.
Reevaluations: If a student is unsatisfied with a score, they may identify the mistake, correct it, and request a reevaluation from the TA.
Group Programming Assignments: Designed to foster cooperation.
All members of a group receive the same grade.
Groups are not assigned; students must find their own partners during active sessions or labs.
Exams: There are exams in total.
These are individual online tests conducted synchronously at specific times.
Exams require close monitoring via webcam and screen recording.
Mock Exams: Scheduled during class time before every actual exam to allow students to practice and understand question formats first-hand.
Course Policies and Academic Discipline
Late Submissions: These are generally not accepted. Exceptions are only permitted under specific circumstances, such as medical duties or illness documented by a medical note.
Standard Excuses: Personal activities, such as being "on board," are not considered acceptable excuses for missing deadlines.
Syllabus Quiz: A quiz intended to verify understanding of course requirements.
The quiz is due today at .
Multiple attempts are allowed to achieve the desired grade.
Deadlines: All deadlines are fixed and summarized in the final section of the syllabus. No separate reminders will be provided for individual quizzes, labs, or assignments. Use of personal reminders, such as Google Calendar, is recommended.
Introduction to Programming Principles and C
Language Choice: C# is the tool used to design and implement precise programming principles.
Primary Objective: Programming is a method for solving specific problems. Implementation in a language like C# only occurs after the problem is carefully understood and a solution method is developed.
Problem Solving Workflow:
Understand the problem.
Develop a method (algorithm) to solve the problem.
Implement the method in a programming language (C#).
Execute the implementation on a computer.
Capabilities and Limitations of Computers
Computer Capabilities:
Performing very fast calculations and many operations simultaneously.
Utilizing memory to store data and programs.
Repetition: Machines can repeat the same steps continuously for durations ranging from months to years without the fatigue that affects humans.
Abstract Computing Model:
Input: The computer receives data.
Computation: The computer runs calculations.
Output: The computer reports the result.
Computer Limitations:
Lack of Intuition: Computers are not magic and cannot guess intentions. Instructions must be perfectly specific and clear.
Finite Resources: Even powerful machines can run out of or .
Complexity: Some problems, such as weather forecasting, are too complex to solve with accuracy.
Insolubility: Some questions lack a general algorithm.
The Halting Problem: There is no general algorithm to determine whether a given program will run forever or eventually stop.
Fundamental Algorithm Properties and Performance
Definition: An algorithm is a clear sequence of executable steps that eventually stops and produces an output.
Core Properties:
Precision: Steps must be unambiguous; the computer cannot guess.
Executability: Steps must be within the processing capability of a program.
Termination: The method must eventually stop.
Validity: The output must specifically solve the assigned task.
Performance Metrics:
Running Time: The amount of time required for an algorithm to produce an output. Efficiency is measured in the worst case or on average relative to the size of the input.
Memory Consumption: The amount of memory used during execution. Memory is consumed whenever the algorithm needs to "remember" a value.
Problem-Solving Case Study: Maximum Value Tasks
Input Set: A sequence of integers (e.g., ).
Task: Identify the maximum number in the sequence.
Data Reduction Strategy: When confronted with large datasets (e.g., thousands of numbers), reducing the data to a small set helps characterize the manual verification process.
Verification Criteria: To verify if a candidate (like a claim made by a generative AI) is the maximum:
The candidate must exist within the sequence.
No value in the sequence can be larger than the candidate.
Assumption Strategy: To simplify complex tasks, programmers often use assumptions. A common assumption is that the candidate is already guaranteed to be in the sequence, allowing the programmer to focus on checking that no other value is larger.
The Maximum Value Search Algorithm
Algorithm Steps for Finding Maximum:
Set the "Current Maximum" to the first number in the sequence.
Note: Setting the initial value to is incorrect, as the sequence might contain only negative numbers (e.g., ). Using the first element ensures the candidate is valid.
Examine every remaining number in the list one at a time.
Compare the values: If the value currently being examined is larger than the "Current Maximum," replace the "Current Maximum" with this new value.
Repeat until the end of the sequence.
The final value held in "Current Maximum" is the output.
Constraint: The input sequence must be non-empty. If the list is empty, there is no "first number," and the program will crash because computers cannot intuit a starting value.
The Concept of Roles in Programming Scripts
Algorithms can be viewed as scripts where certain variables play specific roles.
Current Maximum: A role that stores the largest value encountered so far throughout the traversal.
Current Value: A role representing the piece of data being examined at the present moment.
Interaction: These roles interact via comparison operations to determine if an update to the memory (roles) is required.
Advanced Algorithm Modificati on: The Top Three Values Task
Task: Identify the top largest values in a sequence instead of just one.
Method A (Repeated Search): Find the maximum, remove it, and run the maximum algorithm again on the remaining set. Repeat times.
Inefficiency: If a list has elements, this method requires passing through the data roughly times.
Method B (Simultaneous Tracking): Traverse the list once while maintaining roles:
Largest,Second, andThird.Update Logic to Avoid Overwriting:
If the
Current Valueis greater thanLargest:Update
Thirdto take the value ofSecond.Update
Secondto take the value ofLargest.Update
Largestto take theCurrent Value.
Else if the
Current Valueis greater thanSecond:Update
Thirdto take the value ofSecond.Update
Secondto take theCurrent Value.
Else if the
Current Valueis greater thanThird:Update
Thirdto take theCurrent Value.
Comparison: Method B is superior because it completes the task in one pass through the data, whereas Method A requires multiple passes.
Questions & Discussion
Question on Maximum Value: When presented with the sequence , what should be the output for the maximum number?
Response: The output should be .
Question on Dynamic Input: If the sequence is changed to include , what should be the output?
Response: The output is .
Verification of AI Claims: If an AI claims that is the maximum of a set where exists, is the claim true?
Response: No, because a larger number found within the sequence contradicts the claim.
Verification Logic: What if the AI claims is the maximum, but that number is not in the sequence?
Response: The claim is rejected because the maximum must be part of the sequence.
Minimum Value Logic: How would the algorithm change to find the minimum value?
Response: The roles are renamed (e.g., "Current Minimum"), and the comparison is reversed to check if the current value is smaller than the stored minimum.
Edge Cases for Top Three: Do repeated values count? What if the list has fewer than items?
Response: These are specification questions for a designer. For current purposes, it is assumed that repeated values do not count and inputs always contain at least unique values.