classnotes RTX 4070 Ti SUPER · faster-whisper · DeepSeek

5101 - Design & Analysis of Algo

← 5101 - Design & Analysis of Algo

DAA_16 Aug_ Lab

Date 2026-08-16 Length 1h 32m Words 11,844 Segments 755
⤓ Download transcript (.txt with timestamps) ⤓ Plain transcript (.txt) ⤓ Transcript (.md)

Summary


session: "5101-design-analysis-of-algo/2026-08-16 0000 DAA 16 Aug Lab"

title: "DAA 16 Aug Lab"

date: "2026-08-16 00:00"

duration: "1h 32m"

language: "en"

model: "deepseek-ai/DeepSeek-V4.1-Flash-1017"

parts: 3

transcript_chars: 57384

generated: "2026-11-23T23:19:42+05:30"


DAA 16 Aug Lab

Overview

This lab session introduced arrays and basic array algorithms in Python, starting with HackerRank account setup and a poll of students' coding backgrounds. The class covered why array indexing starts at 0 (the offset idea), the address-calculation formula, and two problems: finding the minimum and maximum element of an array, and "Array Hunt 2" (linear search for a target value). The session used step-by-step dry runs so students without a coding background could follow, and doubts were taken after each problem. It sits at the start of the course as the foundation for data structures and algorithm analysis.

Learning outcomes

Core concepts

HackerRank setup and naming convention

Students register with a personal or IITPathna email ID; if the IITPathna account gives a "doesn't exist in a tenant" error, they join via personal email. The user ID follows roll number_name; if that does not fit, use the roll number only followed by an underscore, and the roll-number part may be left empty if unknown. This matters because the instructor uses the ID to evaluate submissions and for final grading.

Arrays and indexing

An array is a data structure that stores multiple values in a single variable, usually in an ordered sequence, written inside square braces. Each element has a position called an index, starting from 0. Arrays replace many separate variables (e.g., marks of five students) with one variable that a loop can traverse. This is the foundation for both problems solved in class.

Why indexing starts at 0 (offset)

An array index represents the distance (offset) from the beginning of the array — the first element is at offset 0, the second at offset 1, and so on. This connects to the term offset from computer organization and architecture; zero indexing fits naturally with offsets and simplifies address calculation. The instructor noted that one-indexed languages/systems also exist and a language could be designed to start arrays at 1.

Base address and element size

The address of an element is computed from the base address, the index, and the size of each element (an integer is taken as 4 bytes). This links the abstract index to actual memory layout.

Min/max problem

Given n and n integers, find the minimum and maximum element. The instructor said linear search, binary search, "anything" may be used — the goal is just to find the minimum and maximum. The solution initializes both minimum and maximum to the first element and scans the rest.

Python input handling

input() takes values from the user but returns string values only. int() converts a string to an integer (a type error occurs if a string is passed where an integer is expected). split() splits input by space, map() maps each value to a data type (here string to int), and list() (or square brackets) creates the array. Hardcoding values in brackets would force every user to edit the values, which is why user input is used.

Data types and control flow in Python

The four data types listed are int, float, string, and bool (examples: 15.0, 2, hi/hola). A for loop iterates through the list element by element; range() is a predefined function that stops at last value minus one; if takes a boolean value produced by comparisons; print() outputs to the console/terminal. Python also has predefined min() and max() functions analogous to int.

Linear search ("Array Hunt 2")

Scan each element one by one from left to right to find the target value. Print the zero-based index of the first occurrence of x if it exists; otherwise print -1. == compares values while = assigns; indentation with the tab button defines blocks; break stops the loop once the target is found. A comment is text written so other developers know what the program does and is not executed.

Formulas and maths

Worked examples

Array storage example: marks stored in one array variable with positions 0, 1, 2, 3.

Address example: array with base address 1000 and 4-byte integers; addresses 1000, 1004, 1008, 1012 correspond to offsets 0, 1, 2, 3. Offsets illustrated with the array 10, 20, 30, 40: 10 is at offset 0, 20 at offset 1, 30 at offset 2, 40 at offset 3.

Min/max problem format: first line contains integer n (number of elements); second line contains n space-separated integers. Constraints: n between 1 and $10^5$ (one lakh); elements are integers in the range $-10^9$ to $10^9$. Output: two integers separated by a space — first the minimum, then the maximum.

Simple min/max example: array 1 2 3 4 5 → minimum = 1, maximum = 5.

Min/max dry run: array -3 0 7 -2 9 4, n = 6.

Linear search Example 1: Input 5, then 2 4 6 8 10, target 8. Dry run: is 2 equal to 8? No → next. Is 4 equal to 8? No → next. Is 6 equal to 8? No → next. Is 8 equal to 8? Yes → return its index. Indices: 2 → 0, 4 → 1, 6 → 2, 8 → 3. Output: 3.

Linear search Example 2: Input 6, then 1 3 5 7 9 11, target 4. 4 is not in the array → output: -1.

Dry run of the linear search code (array 2 4 6 8 10, target 8, n = 5):

Questions asked in class

"How to find the roll number?" (for someone who joined with a personal ID) — The instructor does not know how that person joined; from the email ID, the first part is the name (e.g., if the name is Palak, it is Palak), then underscore, then the email ID. The roll-number part can be left empty if unknown.

"Can you disable the notification sound?" — Yes.

"Can you speak only in English?" — The instructor agrees to speak English but says he will also speak some Hindi in between.

"Why does an array start at index 0?" — Answered via the offset explanation and address calculation (distance from the beginning of the array; offset 0 for the first element).

Registration error ("doesn't exist in a tenant") — No issue; join through the personal email ID instead.

"Two questions are showing after signing up" — You can go ahead and solve them.

Doubts policy — Doubts are taken after solving each question (solve one question, take doubts, solve the next, take doubts again), not during the solving.

Mohamad: first name and last name? — That is not in the question at all.

Mayank (MCA student): do MCA students need a different HackerRank account or lab session, since account creation mentioned Mtech? — HackerRank won't differ; use the same. Name the account with your roll number (and name) so the instructor can evaluate submissions later.

Prabhul: used AI to find the solution; asked about the for loop (partly inaudible) — The instructor's for loop approach is simple, fantastic and fast. The AI solution "didn't even return" properly and used the predefined min and max functions instead; he advises looking at his own solution.

Krishna Chandra Arora (senior software engineer, 7 years, C#/Java/C++): is it okay to solve the questions in Java now and switch to Python later? — Yes, you can solve using Python, there is no issue; solving in Java right now is also fine. He also advised that AI/cloud-code tools hallucinate a lot even in enterprise editions, so strong coding knowledge is required to verify suggested changes — no use relying on AI while solving questions.

Utkarsha Sarma (zero coding background): feels FOMO; asked for the solution to be shown on the HackerRank page. — The solution was already pasted in the chat; Python is "just an English language," nothing like rocket science; if it's still unclear, it can be solved in class later. The instructor agrees to solve the next question on the HackerRank page.

Ayusha: UI question — she sees only contest questions and two challenges (one being max/min), not the same UI as shown. — Not an issue; the instructor has half the screen, so the view differs, but it is the same question (input format/output match).

Robin: purpose of the map function — is it converting string to int? — Yes, it is conversion (implicit conversion); the instructor also explains the predefined min/max functions.

Robin/Ravine Singh: why do we have to map? — Because input() takes in a string value; strings cannot be processed/compared as numbers in the loop ("you can compare only with the numbers value"), so the input is mapped to integers with map(int, ...).

Shraddha Khamat: a HackerRank test case failed and someone on the chat helped fix it — how do we submit next time if a test case fails while listening to recordings? — It should not happen again since the account is already taken. A submission with a failing test case is still considered, but since test cases cannot be shown, think about what edge cases are missing; if about 50 percent or more of the test cases pass, it is considered. These assignments are considered for final grading.

Submission window (shown on screen) — One week starting from the 11th (class time) until the 23rd (end of time). The instructor can see login counts, signup counts, view contest submissions, results, how many test cases passed, and the leaderboard.

Sorrow Kumar Pande: in the max/min problem, if a number is found to be minimum, can't we skip checking whether it is maximum (e.g., with break or something)? — No — you must check each and every element: a number that is minimum at that moment may be the maximum among upcoming numbers ("who knows"). continue exists as a keyword to skip, "but there is no use of that"; using it would give an incorrect answer. Also, breaking in the max/min loop would stop checking the remaining values.

Dipika: can I submit the code in C++ — is Python mandatory? — No, you can submit in C++ or any of the languages available in the compiler.

Uday Banu Kumar (new to programming): where should I write the code? — Choose a language (e.g., Python), remove the comment, write the code, click "Run Code"; if it runs, good; if there is an error, debug it yourself or with the activity; then submit — if all test cases pass, you can submit.

Uday Banu Kumar: book suggestion for Python beginners? — Not books but YouTube: a video by "Campus X" — search "Campus X Python" on YouTube and study there.

Anand Gupta — said his doubt was cleared by the previous person's question.

Key takeaways

Exam-style questions

1. Why does array indexing start at 0? Use the offset idea and compute addresses for an array with base address 1000 and 4-byte integers.

Outline: Index = distance (offset) from the beginning; first element at offset 0; zero indexing fits offsets and simplifies address calculation. Address = base + index × size → 1000, 1004, 1008, 1012 for indices 0–3; e.g., index 2: 2 × 4 = 8 → 1008.

2. Write the logic to find the minimum and maximum of an array of n integers, and dry-run it on -3 0 7 -2 9 4.

Outline: Initialize min = max = array[0]; for i in range(1, n): if array[i] < min update min; if array

Transcript

One line per segment, [hh:mm:ss] timestamp first.

loading…