session: "5101-design-analysis-of-algo/2026-08-16 0000 DAA 16 Aug 1st"
title: "DAA 16 Aug 1st"
date: "2026-08-16 00:00"
duration: "1h 25m"
language: "en"
model: "deepseek-ai/DeepSeek-V4.1-Flash-1017"
parts: 3
transcript_chars: 58855
generated: "2026-11-23T23:17:58+05:30"
DAA 16 Aug 1st
Overview
This class introduces what an algorithm is (using a "making a burger" counterexample and sorting as a positive example), then moves into the fundamentals of data: what it is, why it must be organized, and the formal notion of a data structure. It covers the taxonomy of data structures (primitive vs non-primitive; linear static/dynamic vs non-linear) and the four core operations (traversal, searching, insertion, deletion), with arrays, linked lists, stacks, queues, trees and graphs as examples. The class closes with course logistics: reference books, Moodle slides, the HackerRank lab, and attendance rules. It is the first, foundational session of the course, setting up later topics such as correctness verification, asymptotic analysis, trees and graphs.
Learning outcomes
- Distinguish an algorithm from a mere step-by-step process using the two necessary conditions (well-defined steps; applicability to variable input with correct output).
- Define data and explain why organizing data (via data structures) speeds up search, insertion and deletion.
- Classify data structures as primitive/non-primitive, linear (static/dynamic) vs non-linear, and give an example of each.
- Explain contiguous vs non-contiguous memory allocation using arrays and linked lists, including head/start and null pointers.
- Describe stack (LIFO) and queue (FIFO) with real-world analogies, and distinguish tree from graph via the closed-boundary/loop criterion.
- List and differentiate the four core operations on any data structure: traversal, searching, insertion, deletion.
- Compare linear and non-linear data structures on implementation ease, traversal, memory utilization and time complexity.
- Set up and use HackerRank with an IITP email ID, and know the course logistics (books, slides, attendance).
Core concepts
Algorithm (working characterization)
A step-by-step process that is applicable for a variable set of input and always produces a correct output; it must have well-defined steps, and the ordering/flow of steps is managed. It matters because the entire course is about designing and analyzing such processes. It connects to the burger counterexample (which fails the conditions) and to sorting (which satisfies them), and leads into correctness verification and asymptotic analysis later.
Sorting as an algorithm
Arranging numbers in ascending or descending order. It matters as the canonical example of a procedure that works for any input size and always returns a correct result. It connects to the "variable input" condition of an algorithm and to later complexity analysis.
Data
Any set of information that can be stored, analyzed, and used for decision making; it can take many forms — numbers, words, images, or any other input recordable digitally or manually. It can be a quantity, information, graph, measurement (e.g., kilometers), observation (e.g., sun rises in the east), fact, or number. Sources include databases, social media, sensors, and surveys. It matters because data structures exist to organize it.
Data structure
The logical or mathematical model of a particular organization of data — a logical arrangement of elements so that memory can be accessed fast; the data itself is stored in memory in a different way. It matters because proper organization makes search, insertion and deletion faster. It connects to the taxonomy and to the four core operations.
Choosing a data structure
Two criteria: (1) it must be rich enough in structure to mirror the actual relationship (e.g., a queue for a ticket line at a PVR; an array for five numbers); (2) it should be simple enough that one can effectively process the data (e.g., linked list preferred for larger values, arrays for very small sets of information).
Primitive vs non-primitive
Primitive data structures are basic structures such as int, float, double, long double, real number. Non-primitive data structures are collections of primitive data structures, divided into linear and non-linear.
Linear data structures (static vs dynamic)
Linear: data organized in sequential order, stored one after another; access is one after another (sequential). Static: the structure is fixed once defined at the beginning of the program and cannot be modified during execution (e.g., an array of size 10). Dynamic: allows inserting new space or removing empty spaces during execution (at run time) — e.g., linked list; also stack and queue.
Non-linear data structures
Primarily tree and graph; order is not sequential but hierarchical (or some other non-sequential fashion). Tree: root node with left and right children; every subtree is a tree itself; no loop/closed boundary. Graph: has loops/closed boundaries; a tree is a subset of a graph without loops. Most of today's AI algorithms are non-linear (graph networks, etc.).
Array
Elements stored one after another in contiguous memory; the contiguous memory is allocated before execution of the program; the dimension cannot be changed once the program is running. Indexing may be 0-based or 1-based (the instructor uses 0-based afterwards). 2D arrays are multiple 1D arrays connected in a plane (rows and columns); storage can be row-wise and remains sequential.
Linked list
Stores elements in non-contiguous order; each node stores the data/information and the address of the next node. The last element stores a null pointer (end of list). A specialized pointer called head (sometimes start) indicates the first node. Allows dynamic insertion/deletion; deleted node space returns to free memory; extra nodes can be allocated on demand.
Stack and queue
Stack: linear, last in first out (LIFO); analogy of chapatis (eat the last stored first); used in solving algebraic expressions and where an operation must be delayed. Queue: service from the front, insertion at the rear/back; first in first out (FIFO); analogy of a ticket window. Both are also known as derived data types/structures. Priority queue (influential persons served first) is the exception, to be discussed later.
Four core operations
Traversal, searching, insertion, deletion. Insertion adds a new record; deletion removes an element from a pre-existing one; searching identifies a particular record or key; traversal visits all elements/nodes exactly once. Searching and traversal differ: traversal's target is to visit all nodes exactly once; searching's target is to identify a particular record.
Linear vs non-linear comparison
Linear: sequential/linear attachment (array directly, linked list via address pointer); types array, linked list, stack, queue; easy to implement; traversal is a single level (single run); memory utilization non-efficient (array of 20 storing 2 wastes 18); time complexity increases with input size. Non-linear: hierarchical arrangement (trees); types tree, graph; difficult to implement; data cannot be accessed in a single run (multiple runs due to hierarchy); each item attached to many others; memory requirement reduced significantly; used for AI algorithms/graph networks.
Data analysis (mentioned, not covered)
Involves statistical or computational tools to identify patterns, trends, and relationships within data; used to draw conclusions, make predictions, and inform decision making — covered in AI/ML subjects.
Computational complexity estimation / asymptotic analysis
The analysis done after designing an algorithm (named as the next step after algorithm); theta, omega and Big-O to be discussed in the next Sunday class.
Formulas and maths
- Sorting example list: \(5, 10, 7, 3, 20, 2 \rightarrow 2, 3, 7, 10, 20\) — the input list and its ascending sorted output; used to illustrate sorting as an algorithm.
- Second example list: \(3, 9, 2\) — stated as also sortable; used to show sorting works on other inputs.
- Array address example: \(104, 108, 112, 116, 120, 124\) — consecutive, fixed addresses of array elements; used to show contiguous allocation.
- Address arithmetic: addresses \(100, 104, 108, 112\) because an integer needs at least 4 bytes; in most cases 8 bytes are used for an int, giving \(100, 108, 116, 124\) — used to explain how contiguous addressing works (instructor: do not worry about addressing details).
- Linked list address chain: \(104 \rightarrow 108 \rightarrow 128 \rightarrow 132\), last pointer null — non-contiguous addresses linked by pointers; used to show dynamic storage.
- Binary representation example: \(4\) is represented as \(1\,0\,0\) — used in Q&A to explain that binary conversion is a background/memory-organization matter, not a data-structure matter.
- Asymptotic analysis: theta, omega and Big-O — complexity notations; to be used when analyzing algorithms (next Sunday class).
Worked examples
- Burger vs algorithm: burger-making is a step-by-step process, but reducing the input changes the result (taste compromised) and its steps are not well defined → not an algorithm; it can be called a process flow.
- Sorting: regardless of input size, the sorting procedure always returns a correctly sorted array — illustrating applicability to variable input.
- Desktop files analogy: many Word documents flooded on the desktop require searching here and there; if organized date-wise or in folders by aspect, fetching the data is easy — i.e., organized data gives faster search/insert/delete.
- Queue example: a ticket window line at a PVR maps directly to the queue data structure because it reflects the actual situation.
- Array vs linked list: array for five numbers / small sets; linked list for larger values; array size fixed at declaration (e.g., 10) vs linked list allowing space changes at run time.
- Array example: values 5, 10, 20, 25, 30, 35 at indexes 0 1 2 3 4 5 (alternatively 1 2 3 4 5 6 in some languages).
- Linked list in fragmented memory: six elements to store; free spaces 1–6 are not contiguous (something in between is occupied), so an array cannot be used. Values a, b, c, d are stored at 104, 108, 128, 132 respectively, linked by pointers, with the last pointer null. If D is deleted, that space automatically becomes free. To store an extra element e, if location 104 is available it is allocated and the previous last element's pointer goes to 104, with the new last element's pointer set to none.
- Array wastage example: declare an array of 10 but use only two locations — the other eight are wasted/engaged until the program ends.
- Almirah analogy (contiguous vs non-contiguous): an almirah with ten shelves (1–10). To store an array of size five, acquire shelves 1–5. But if six locations (2, 3, 7, 9, 10, 1) are already engaged and you want an array of size four, you cannot store it because the cells are not available in contiguous order; a linked list can store in different locations.
- Insertion in a static array: declare array size 10, initially store two elements, then store another eight — that is allowed. Predefined declaration of size permits insertion and deletion within that size.
- Traversal example: array data 10, 20, 3, 4, 22 — traverse all elements; searching for 3 directly identifies it and declares whether it is available in the array.
- Stack analogy: chapatis stored first, second, third, fourth, fifth, sixth …; eaten last first, then second last, third last, fourth last.
- Queue analogy: ticket window — persons 3, 4, 5, 6, 7 served in order; a new person is added at the back; processing from the front, insertion at the rear.
- Graph closed boundary example: 0 attached to 1, 1 attached to 4, and 4 also attached (back to 0) — a closed boundary; node 3 has no closed boundary.
- Attendance mechanism (as described): Moodle runs in the background and records information; snapshots of who is attending are taken roughly every 15 minutes (four or five chances); those present throughout are marked. Watching a recording does not count as attendance. 75 percent attendance is allowed.
Questions asked in class
- Q (Robin?): Uses Python for data structures; Python is slower than C++/Java and sometimes submissions fail with runtime errors on HackerRank. What to do?
A: Deadlines are not tight (around a week); there is no five- or ten-minute limit. In the last semester most students did Python and submission was very easy with no bug; if an issue comes up, it will be resolved.
- Q (Puneet Ghosh): Which language will be used?
A: Totally up to you; HackerRank lets you change the language at runtime (Python, C, C++, etc.). Labs are two hours with only three or four questions targeted. Primarily the instructor will prefer C, but depending on the class's strength/demand, Python may be used; if something is in C/C++, all steps will be explained.
- Q (Akhil Raj): If all data is stored as 0s and 1s, how are primitive/non-primitive (e.g., Boolean) classifications made?
A: The binary conversion is a background thing. Data structure is the logical organization of data; how a value (e.g., 4, or a float) is stored in memory is part of memory organization, not data structure. When you reach the memory location you find the binary equivalent, not the number.
- Q (Bhanu Kumar): Is Cormen sufficient for this semester?
A: That book is not just for this semester — it suffices for whatever algorithms/data structures/advanced algorithms you study in your life; it cannot be completed even in three semesters.
- Q (Bhanu Kumar): How to choose electives?
A: Totally your decision; only some electives run at a time depending on which professor offers them. Offered electives are shown on Moodle; other electives are disabled.
- Q: Is there a PDF of the subject/reference book list?
A: No PDF as such, but the PPT will be shared.
- Q: What is HackerRank (totally new to it)?
A: A coding platform: you get a coding question and write code in Python, C, C++, or any language to solve it — like an exam where you write the answer, but here you write code.
- Q (Ankit Sakshena): Can the reference book be found in the central library?
A: [unclear] — the transcript ends mid-question.
- Recap of classification (student: Dashmook Ulas Maruti): student restated primitive/non-primitive → linear/non-linear → within linear, static/dynamic based on whether storage can change during execution; non-linear like tree and graph. Instructor: "yes yes yes sure that's good."
- Python lists (Anthony Satish J): since Python lists allow changing the number of elements at run time, is it dynamic? — Yes, it is dynamic; in Python most of these support dynamic arrangement; Python arrays are primarily a dynamic type.
- HackerRank language support (Sonam Chanda): for people from non-CS backgrounds, will there be a fast-track course on Java/C? — No worries; all steps will be explained — e.g., how insertion sort works, what the inputs are, each step explained before asking students to do it; it will be a kind of booster course for those not from a CSC background or not working in that language.
- Do arrays/linked list/stack help with Python? — Not directly; as the previous person asked, Python mostly offers dynamic things, so the array kind of stuff is not there.
- Attendance and schedule: how is attendance recorded if someone sleeps or joins 10–15 minutes late? — Moodle runs in the background and records information; snapshots are taken roughly every 15 minutes (four or five chances); those available at all chances are marked present. Exact mechanism not known beyond this. Watching recordings does not count; 75 percent attendance is allowed.
- Revised curriculum: is there a revised syllabus for 2026? — Search "IIT Patna MTech curriculum, CSC curriculum" on Google. The 2024 curriculum was revised and is valid for six to seven years, so it will be the same.
- PPT before class (Parambhir): sometimes the PPT is prepared late at night; the instructor will try to upload it a day before, but in most cases the PPT is not ready in advance.
- Graph closed boundary: explained as above (tree has no second path of attachment; graph has a cycle such as 0–1–4–0). Even three nodes forming a triangle with the rest tree-like makes it a graph.
- Contiguous vs non-contiguous memory (Sabuch Das): explained with the almirah example (above).
- Insertion in a static array: if the size is predefined at declaration, insertion and deletion within that size are allowed — the student's confusion resolved.
- Textbook (Cormen): the PDF will be uploaded on Moodle.
- Class schedule (from a student's comment): M.Tech students are engaged 7–8 hours each day; Saturday and Sunday are engaged, and even late evenings of Monday and Wednesday may be engaged. The schedule is customized for hybrid students so they can attend classes on Saturday and Sunday.
- Sanjeev Kumar: Are the lectures enough to learn data structures and algorithms and design, since work may leave no time to read books? — Yes, the lectures and what the instructor provides will be enough. Books are only needed for doing something extraordinary; exams, quizzes and other assessments will come from his activities only.
- Debashish: How will marks be translated on the header — calculated per question, or is there partial marking? — Partial marking is already done: if some test cases pass, you get partial marks. The instructor will later decide which lab's marks to take, in favor of the students.
- Debashish (follow-up): If unable to attend live classes, is watching the recorded session acceptable? — Yes, attendance will be marked for recorded sessions. The instructor is not aware of the exact mechanism but will ask the team and let students know, probably in the next lecture.
- Anujay Saraf: (1) As working professionals informed that watching recordings gives attendance — is it the same here? — It is common for all courses; the exact mechanism of capturing attendance from recorded video is unknown to the instructor, but a mechanism exists. (2) Since the lecture uses PPT plus written annotations, can the same PPT be uploaded? — Yes, the annotated PPT will be uploaded, which will help while re-watching the recording. (3) Coming from an electronics (non-CS) background, is learning core C/C++ mandatory? — No, it is not needed; just attend the lab and lectures. The instructor notes that