Binary Search v.s Ternary Search (Python)
In this video, I will explain ternary search using a while loop and then using the recursive way. Specifically, I will be demonstrating the ternary search algorithm in a program iteratively (using a loop) and then recursively (using recursion). The way ternary search works is that you have a number that you want to search for in an array or a list. This array must be sorted from least to greatest as a precondition. If the number exists in the sorted array, you return the location (which is the index) where that number occurs. We call this number "the target". If the target does not exist inside the array, you simply return -1. Ternary search is amazing, with logarithmic run time. What is recursion? Recursion is a function that calls upon itself. Here, we write a function that calls upon itself to ternary search an element or value inside an array using a for loop and using recursion. While it is easy to use a for loop or while loop to do this, it is important that you understand these recursion steps to have a strong foundation to learn more complex recursive algorithm in the future. In the next video, I will explain binary search and linear search which is very similar to linear search, and I will also explain why it is so useful. Link to the Binary Search and Linear Search videos in the Data Structure playlist: • Data Structures & Analysis of Algorithms LIKE & SUBSCRIBE: 🔴 My Channel: / quocdatphung 🔴 My second channel: / @clear_your_mind123

Program to Calculate Sum of 1+2+...+N (Loop v.s Recursion)

2.6.1 Binary Search Iterative Method

Exponential Search - better than Binary search? (Explained)

Binary Search tutorial (C++ and Python)

Introduction to Binary Search

Using Large Language Models | Build Your Own LLM Workshop #1

Algorithms in Python: Binary Search

Android 17 sucks. So I put Linux on a phone.

God Says:"MY CHILD, I NEED TO SEE YOU URGENTLY!"/God Message Now/God Message

Unbelievable Smart Worker & Hilarious Fails | Construction Compilation #7 #adamrose #smartworkers

Nobody Breaks Celebrities Like Rowan Atkinson

Ego Bodybuilder HUMILIATED Beyond Belief 🤯 | Anatoly GYM PRANK

ASMR Best Triggers For Sleep Collection (No Talking) 3 Hours of Tapping & Scratching

This AMAZING Trick Can Solve Extreme Sudoku

The Strange Math That Predicts (Almost) Anything

7.2 What is Binary Search | Binary Search Algorithm with example | Data Structures Tutorials

Is This DIY EMP Device Actually Dangerous?

She’s 12. She Sings Aretha Franklin… Until Simon TELLS Her to Do It Acapella! 😳

Binary Search OR Ternary Search

