SQL Tutorial: Introduction to recursion

DataCamp · Beginner ·⚡ Algorithms & Data Structures ·6y ago

Key Takeaways

Introduces recursion using SQL

Full Transcript

in the second video you will learn what you cash means and how you could use it for many problems the first question we want to answer is what recursion is in general as you can see in the picture it is something that is always repeated accordingly recursion is the use of a procedure subroutine function or eggwin that calls itself one or more times until a specific condition is met therefore a recursion could simplify a complex problem by sharing the problem in smaller poems performed repeatedly one really important fact about recursion is that you need the termination condition if you have no termination condition the call of the small problem repeats all the time as you can see in the shown picture and we world example everyone knows it's the family tree everyone has a father and your father as a father for example to find all father's for the last five generations you can use your question you have to reduce the problem to smaller problems of the same type whole problem is to find all generations and the small problem is to find your father in the first step find your father and in the second step find the father of the father until the termination condition of fife is reached knowing how we crashed works in Genoa we are now somewhere some facts about recursion advantages soft bottoms recursively if the bottom can be reduced to smaller partners of the same type and recursively solve problem is easy to eat and to follow and the termination condition could be used to limit the number of iterations thinking of disadvantages the Oshin time could be slower because the recursion function is called many times knowing what is recursion let's try out a simple macaron problem the problem we want to solve is to calculate the sum of consecutive numbers it can be defined as shown on the slide it is 1 for the first situation and for each following iteration number of the current iteration and the sum of the previous situation is added as an example the result of 5 is 15 is this the sum of 1 plus 2 Plus 3 plus 4 plus 5 now we are going to solve this problem with seeker in general we could solve recursive problems with city's common table expressions therefore you could see the initial query which initializes the field for iteration and the sum of number with one in the recursive part the current iteration number is added with the sum of the previous situation you can see that the termination condition is set to 6 this means this query calculates the sum of numbers until 6 finally the city is elected to get the wanted result you hear a lot about who curses afar

Original Description

Want to learn more? Take the full course at https://learn.datacamp.com/courses/hierarchical-and-recursive-queries-in-sql-server at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work. --- In this second video, you will learn what recursion means and how you could use it for many problems. The first question we want to answer is what recursion is in general. As you can see in the picture, it is something that is always repeated. Accordingly: Recursion is the use of a procedure, subroutine, function or algorithm that calls itself one or more times until a specific condition is met. Therefore, a recursion could simplify a complex problem by sharing the problem in smaller problems performed repeatedly. One really important fact about recursion is that you need a termination condition. If you have no termination condition, the call of the small problems repeats all the time. As you can see in the shown picture. An real world example everyone knows is the family tree. Everyone has a father and your father has a father. For example, to find all fathers for the last 5 generations, you can use recursion. You have to reduce the problem to smaller problems of the same type. The whole problem is to find all generations and the small problem is to find your father. In the first step, find your father and in the second step, find the father of the father until the termination condition of 5 is reached. Knowing how recursion works in general, we are now summarizing facts about recursion. There are several advantages: you can solve problems recursively, if the problem can be reduced to the smaller problems of the same type. A recursively solved problem is easy to read and to follow and a termination condition could be used to limited the number of iterations. Thinking of disadvantages, the execution time could slower because the recursive function is called many times. Knowing what is recursion, let's try out a simple recur
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from DataCamp · DataCamp · 0 of 60

← Previous Next →
1 SQL Server Tutorial: Date manipulation
SQL Server Tutorial: Date manipulation
DataCamp
2 R Tutorial: Intermediate Interactive Data Visualization with plotly in R
R Tutorial: Intermediate Interactive Data Visualization with plotly in R
DataCamp
3 R Tutorial: Adding aesthetics to represent a variable
R Tutorial: Adding aesthetics to represent a variable
DataCamp
4 R Tutorial: Moving Beyond Simple Interactivity
R Tutorial: Moving Beyond Simple Interactivity
DataCamp
5 Python Tutorial: Why use ML for marketing? Strategies and use cases
Python Tutorial: Why use ML for marketing? Strategies and use cases
DataCamp
6 Python Tutorial: Preparation for modeling
Python Tutorial: Preparation for modeling
DataCamp
7 Python Tutorial: Machine Learning modeling steps
Python Tutorial: Machine Learning modeling steps
DataCamp
8 R Tutorial: The prior model
R Tutorial: The prior model
DataCamp
9 R Tutorial: Data & the likelihood
R Tutorial: Data & the likelihood
DataCamp
10 R Tutorial: The posterior model
R Tutorial: The posterior model
DataCamp
11 R Tutorial: An Introduction to plotly
R Tutorial: An Introduction to plotly
DataCamp
12 R Tutorial: Plotting a single variable
R Tutorial: Plotting a single variable
DataCamp
13 R Tutorial: Bivariate graphics
R Tutorial: Bivariate graphics
DataCamp
14 Python Tutorial: Customer Segmentation in Python
Python Tutorial: Customer Segmentation in Python
DataCamp
15 Python Tutorial: Time cohorts
Python Tutorial: Time cohorts
DataCamp
16 Python Tutorial: Calculate cohort metrics
Python Tutorial: Calculate cohort metrics
DataCamp
17 Python Tutorial: Cohort analysis visualization
Python Tutorial: Cohort analysis visualization
DataCamp
18 R Tutorial: Building Dashboards with flexdashboard
R Tutorial: Building Dashboards with flexdashboard
DataCamp
19 R Tutorial: Anatomy of a flexdashboard
R Tutorial: Anatomy of a flexdashboard
DataCamp
20 R Tutorial: Layout basics
R Tutorial: Layout basics
DataCamp
21 R Tutorial: Advanced layouts
R Tutorial: Advanced layouts
DataCamp
22 Python Tutorial: Time Series Analysis in Python
Python Tutorial: Time Series Analysis in Python
DataCamp
23 Python Tutorial: Correlation of Two Time Series
Python Tutorial: Correlation of Two Time Series
DataCamp
24 Python Tutorial: Simple Linear Regressions
Python Tutorial: Simple Linear Regressions
DataCamp
25 Python Tutorial: Autocorrelation
Python Tutorial: Autocorrelation
DataCamp
26 R Tutorial: The gapminder dataset
R Tutorial: The gapminder dataset
DataCamp
27 R Tutorial: The filter verb
R Tutorial: The filter verb
DataCamp
28 R Tutorial: The arrange verb
R Tutorial: The arrange verb
DataCamp
29 R Tutorial: The mutate verb
R Tutorial: The mutate verb
DataCamp
30 R Tutorial: What is cluster analysis?
R Tutorial: What is cluster analysis?
DataCamp
31 R Tutorial: Distance between two observations
R Tutorial: Distance between two observations
DataCamp
32 R Tutorial: The importance of scale
R Tutorial: The importance of scale
DataCamp
33 R Tutorial: Measuring distance for categorical data
R Tutorial: Measuring distance for categorical data
DataCamp
34 Python Tutorial: Plotting multiple graphs
Python Tutorial: Plotting multiple graphs
DataCamp
35 Python Tutorial: Customizing axes
Python Tutorial: Customizing axes
DataCamp
36 Python Tutorial: Legends, annotations, & styles
Python Tutorial: Legends, annotations, & styles
DataCamp
37 Python Tutorial: Introduction to iterators
Python Tutorial: Introduction to iterators
DataCamp
38 Python Tutorial: Playing with iterators
Python Tutorial: Playing with iterators
DataCamp
39 Python Tutorial: Using iterators to load large files into memory
Python Tutorial: Using iterators to load large files into memory
DataCamp
40 SQL Tutorial: Introduction to Relational Databases in SQL
SQL Tutorial: Introduction to Relational Databases in SQL
DataCamp
41 SQL Tutorial: Tables: At the core of every database
SQL Tutorial: Tables: At the core of every database
DataCamp
42 SQL Tutorial: Update your database as the structure changes
SQL Tutorial: Update your database as the structure changes
DataCamp
43 Python Tutorial: Classification-Tree Learning
Python Tutorial: Classification-Tree Learning
DataCamp
44 Python Tutorial: Decision-Tree for Classification
Python Tutorial: Decision-Tree for Classification
DataCamp
45 Python Tutorial: Decision-Tree for Regression
Python Tutorial: Decision-Tree for Regression
DataCamp
46 Python Tutorial: Census Subject Tables
Python Tutorial: Census Subject Tables
DataCamp
47 Python Tutorial: Census Geography
Python Tutorial: Census Geography
DataCamp
48 Python Tutorial: Using the Census API
Python Tutorial: Using the Census API
DataCamp
49 R Tutorial: A/B Testing in R
R Tutorial: A/B Testing in R
DataCamp
50 R Tutorial: Baseline Conversion Rates
R Tutorial: Baseline Conversion Rates
DataCamp
51 R Tutorial: Designing an Experiment - Power Analysis
R Tutorial: Designing an Experiment - Power Analysis
DataCamp
52 R Tutorial: Introduction to qualitative data
R Tutorial: Introduction to qualitative data
DataCamp
53 R Tutorial: Understanding your qualitative variables
R Tutorial: Understanding your qualitative variables
DataCamp
54 R Tutorial: Making Better Plots
R Tutorial: Making Better Plots
DataCamp
55 SQL Tutorial: OLTP and OLAP
SQL Tutorial: OLTP and OLAP
DataCamp
56 SQL Tutorial: Storing data
SQL Tutorial: Storing data
DataCamp
57 SQL Tutorial: Database design
SQL Tutorial: Database design
DataCamp
58 Python Tutorial: Introduction to spaCy
Python Tutorial: Introduction to spaCy
DataCamp
59 Python Tutorial: Statistical Models
Python Tutorial: Statistical Models
DataCamp
60 Python Tutorial: Rule-based Matching
Python Tutorial: Rule-based Matching
DataCamp

Related AI Lessons

Bloom Filters, Explained Properly
Learn how Bloom filters work and their benefits, including tiny memory and blazing speed, in exchange for potential false positives.
Dev.to · Daksh Gargas
Prefix Sums: The Preprocessing Trick That Makes Range Queries Instant
Learn how prefix sums enable instant range queries in arrays, boosting performance in various applications
Medium · Programming
I Thought I Was Ready for the Interview — Then One Simple Math Question Destroyed Me
A simple math question can destroy a developer's interview, highlighting the importance of being prepared for unexpected questions
Medium · Programming
Week 2(Day 10): LeetCode Two Pointers(slow & fast): Remove Duplicates from Sorted Array (Brute…
Learn to remove duplicates from a sorted array using the two pointers technique, improving from brute force to optimized solutions
Medium · Python
Up next
Stump Grinder Carbide Wheel Grinds Hardwood To Chips
Innoforge Studio
Watch →