Loops Time Complexity - 7

Duration: 18 min

This video lesson is available to enrolled students.

Return to /learn/TPSC-ASSISTANT-TECHNICAL-OFFICER/algorithms/time-complexity-analysis/iterative-loops-code/asset-loops-time-complexity-7 after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. About Course: About the Course
  2. Paper 2 | Digital Logic: Digital Systems & Boolean Basics, Logic Gates & Hardware, Boolean Expression, Boolean Minimization, Combinational Circuit, Sequential Circuits, Number System, Number Representation, Floating Point Rep
  3. Paper 2 | Computer Organization And Architecture: Basics of COA, Cache Memory Organization, Input Output Organisation, Pipelining, Control Unit Design, Instr Formats & Modes, Programming the Basic Computer
  4. Paper 2 | Analog And Digital Communication: Introduction to Communication Systems & Random Signals, Analog Communication Systems, Information Theory & Digital Communication Fundamentals, Digital Modulation & Detection Techniques, Error Control, Synchronization & Multiple Access Techniques
  5. Paper 2 | Programming in C: C Fundamentals, Control Flow, Functions, Arrays & Pointers, Storage Classes, Structures & Enums, DMA, Macros, Scoping & File Handling
  6. Paper 2 | Data Structures And Programming: Introduction to DS, Array, Stack, Queue, Linked List, Tree, Graphs, Hashing, Java, OOPS with C++, Java Fundamentals, Array, String, IO & References
  7. Paper 2 | Algorithms: Algorithm Analysis, Sorting Algorithms, Time Complexity Analysis, Greedy Algorithms, Dynamic Programming, Minimum Spanning Trees, Shortest Path Algos
  8. Paper 2 | Compiler Design: Intro to Compilers, Lexical Analysis, Grammar & CFG, Syntax Analysis: Top-Down, Syntax Analysis: Bottom-Up, Semantic Analysis & SDT, Intermediate Code Gen, Code Optimization, Run Time Environment
  9. Paper 2 | Operating System: Introduction to OS, Process Management, CPU Scheduling, Process Synchronization, Threads & Process Creation, Deadlock, Memory Management, Virtual Memory, Disc Scheduling, File Management, Unix OS, Linux OS
  10. Paper 2 | Databases: Basics of DBMS, ER Diagram, Relational Model & Functional Dependencies, Keys & Integrity Constraints, Normalization (1NF - BCNF), Decomposition Properties & 4NF, Relational Algebra, SQL, Relational Calculus, File Organization & Indexing, Transaction Management, Concurrency Control
  11. Paper 2 | Information Systems and Software Engineering: Fundamentals of Software Engineering, Software Requirements and Quality Assurance, Software Design, Estimation and Metrics, Software Testing, Software Maintenance and Configuration Management
  12. Paper 2 | Computer Networks: Introduction to CN, Data Communication, DLL: Access Control, DLL: Flow Control, DLL: Error Control, DLL: Framing, Data Link Layer - Ethernet, Net Layer: IPv4 & Proto, Net Layer: IP Addressing, Net Layer:Routing Protocol, Transport Layer Services, TL: Congestion & UDP, Application Layer, Hardware Basics
  13. Paper 2 | Internet & Web Technologies: Website, Browser & Services, Internet Fundamentals, Web Design & Development, Protocols & Services, Web Publishing & Hosting, Server Side & Security, Emerging Technologies, HTML Basics, JavaScript-Basics, CSS, XML, HTML5
  14. Paper 2 | Cyber Security And Emerging Technologies: Emerging Tech Trends
  15. Paper 2 | Cloud Technology: Cloud Computing
  16. Paper 2 | Probability and statistics: Probability, Statistics
  17. Paper-1 English: Vocabulary, Preposition, Articles, Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Sentence Correction (Error Correction), Sentence Completion (Fill in the blanks), Cloze Test (Cloze Passage), Sentence Construction
  18. Paper 1 General Mental Ability & Logical reasoning: Ratio and Proportion (Ratios), Divisibility Rules, Data Interpretation, Mixture and Alligation, Permutation and Combination, Logarithm, Number System, HCF LCM, Sequence and Series (Series), Speed Time and Distance, Series (Number and Letter Series) (Numerical Relations and Reasoning), Coding Decoding, Data Sufficiency, Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning), Percentage, Average, Powers and Exponents (Surds and Indices), Algebra, Profit and Loss, Simple Interest and Compound Interest, Time and Work, Pipe and Cistern, Mensuration and Geometry, Mental Ability, Age Problems, Partnership, Arithmetic, Speed Mathematics and Basic Mathematics, Syllogisms, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Seating Arrangements, Blood Relations, Directions (Direction Test), Analytical Reasoning (Counting Figures Reasoning), Puzzle Solving (Puzzles), Calendar, Clock, Cubes & Dices, Selection Decision Table (Decision Making), Logical Sequence Of Words, Venn Diagram, Analogy
  19. Paper-1 General Knowledge & Current Affairs: State Wise GK, History, Geography, GK- Current Affairs, Static General Knowledge
  20. Full Length Mock Test:
AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

This lecture segment focuses on analyzing the time complexity of for loops where the iterator variable is updated by taking its root in each iteration. The instructor systematically derives the number of iterations required for the loop to terminate by tracing the mathematical reduction of the variable. The core concept involves transforming square root operations into fractional exponents and solving for the iteration count k using logarithms. The lecture demonstrates that loops with root-based decrements exhibit a time complexity of O(log log n), which is significantly faster than standard logarithmic or linear loops. The analysis covers two specific examples: one where the variable is square-rooted (i = sqrt(i)) and another where it is 5th-rooted (i = ^5√i). The instructor uses algebraic manipulation and logarithmic properties to establish the relationship between the input size n, the root operation, and the total number of iterations.

Chapters

  1. 0:00 – 2:00 00:00-02:00

    The instructor introduces the first problem, a for loop defined as 'for(i = n; i >= 2; i = sqrt(i))'. He begins the analysis by identifying the initial state where 'i' equals 'n'. On the screen, he writes down the loop condition and draws a vertical line to separate the problem statement from the complexity calculation. He establishes the termination boundary by writing 'n >= 2' on the right side, indicating that the loop continues as long as the variable is greater than or equal to 2. This sets up the framework for calculating how many times the square root operation must be applied before 'i' drops below 2.

  2. 2:00 – 5:00 02:00-05:00

    The instructor traces the evolution of variable 'i' through successive iterations. He writes out the sequence of values: starting at 'n', then becoming 'sqrt(n)' or 'n^(1/2)', and subsequently 'n^(1/4)'. He explicitly demonstrates the algebraic rule that taking the square root of 'n^(1/2)' results in '(n^(1/2))^(1/2)', which simplifies to 'n^(1/4)'. On the right side of the screen, he sets up a recurrence relation to find the number of iterations 'k', writing the condition 'n^(1/2^k) >= 2'. This step-by-step derivation shows how the exponent in the base 'n' is halved with each iteration, forming a geometric progression of exponents.

  3. 5:00 – 10:00 05:00-10:00

    Continuing the analysis, the instructor extends the sequence of values to include 'n^(1/8)' and generalizes the pattern for the k-th iteration as 'n^(1/2^k)'. He lists specific conditions to check termination, such as 'n >= 2', 'n^(1/2) >= 2', and 'n^(1/4) >= 2'. The focus shifts to solving the inequality 'n^(1/2^k) >= 2' for 'k'. He applies logarithms to both sides of the equation, writing 'log n^(1/2^k) >= log 2'. Using logarithmic properties, he simplifies the exponent to '1/2^k * log n', eventually deriving a relationship that allows him to solve for the total number of iterations required for the loop to terminate.

  4. 10:00 – 15:00 10:00-15:00

    The instructor transitions to a second example, changing the loop condition and update rule. The new code is 'for(i = n; i >= 5; i = ^5√i)'. He repeats the derivation process for this k-th root operation. He writes the sequence of values as 'n', 'n^(1/5)', and 'n^(1/25)', generalizing the k-th term as 'n^(1/5^k)'. He sets up the inequality 'n^(1/5^k) >= 5' to determine when the loop stops. By applying logarithms with base 5, he solves for 'k', showing that the number of iterations is proportional to the logarithm of the logarithm of n. The screen displays 'Time Complexity = [log_2 log_2 n] + 1' and concludes with the Big-O notation 'O(log log n)'.

  5. 15:00 – 17:55 15:00-17:55

    In the final segment, the instructor solidifies the derivation for the 5th root loop. He writes out the algebraic step '(n^(1/5^k))^5 = n^(1/5^(k-1))' to verify the exponent reduction. He explicitly solves for 'k' using nested logarithms, writing 'log_5 log_5 n'. The analysis confirms that regardless of the root constant (whether square root or 5th root), the time complexity remains 'O(log log n)'. He points to the loop structure and the final complexity result on the screen, emphasizing that root-based decrements lead to doubly logarithmic time complexity. The lecture concludes with the general formula for this class of loops.

The lecture provides a rigorous mathematical derivation for determining the time complexity of loops with root-based iterator updates. The central method involves expressing the variable's value after k iterations as n^(1/r^k), where r is the root constant. By setting this expression greater than or equal to the termination threshold and applying logarithms, the instructor isolates k. The key takeaway is that taking roots repeatedly reduces the exponent exponentially, leading to a complexity of O(log log n). This is distinct from standard decrement loops (O(n)) or division-based loops (O(log n)). The visual evidence shows the instructor writing specific algebraic steps, such as '(n^(1/2))^(1/2) = n^(1/4)', and solving inequalities like 'n^(1/5^k) >= 5'. The consistent result across different root values confirms that the base of the logarithm does not affect the Big-O classification, only the constant factor.

Loading lesson…