8. Binary Heaps

  Рет қаралды 58,322

MIT OpenCourseWare

MIT OpenCourseWare

Күн бұрын

Пікірлер: 24
@zacontraption
@zacontraption 3 жыл бұрын
When I was an undergrad 7 years ago (not MIT), I watched Erik's MIT OCW lectures to supplement my in-person CS courses. The quality of the education in these lectures is tremendous.
@aeroartz4080
@aeroartz4080 2 жыл бұрын
is it useful to know data structures and algorithms? how has knowing this stuff been helpful so far
@fran150695
@fran150695 2 жыл бұрын
​@@aeroartz4080 I am 2 months late, but I think this answer might be useful to some other people that might see it later. As a person who has been working in the industry for a couple of years. I can say that knowing Data structures and algorithms has been really useful to me. Why? I believe that this is a 2 part answer. 1. Knowing the different kinds of data structures and what makes them better for specific tasks will allow you to know what to choose for what job. Many times I have found that If I just relegated to use the standard "array" I would need to spend a much larger time coding my solutions to the tasks, because the Array is not optimized to the problem to solve. (This would also mean a significant slow on the speed of the code, but that is usually not a problem) 2. The whole "algorithms" part has a very very useful yet obscure usage on the industry. 99% of the time you will never be implementing the algorithms yourself. You can just call a library and they do it for you, but what you learn in these areas is to understand the code and know what is happening. This really helps to both know what libraries to use as well as to make your code efficient and have a much easier time when you need to implement your own algorithms.
@makelearningeasy111
@makelearningeasy111 2 жыл бұрын
Indeed
@SpeaksYourWord
@SpeaksYourWord 11 ай бұрын
@@fran150695 Thank you. This eases the pain a bit 😆
@ParthPatel-vj2zv
@ParthPatel-vj2zv 3 жыл бұрын
0:00 intro, priority queue interface 3:08 set AVL data-structure 08:18 priority queue sort 10:10 comparing priority queue sorting algos based on set AVL, array & sorted array 14:24 complete binary tree 19:47 implicit data structure 24:49 binary heap Q 31:00 insert(x), max_heapify_up(i) 37:10 delete_max(), max_heapify_down(i) 44:25 in-place, O(n) build time
@fgfanta
@fgfanta 2 жыл бұрын
Quite amazing how the teachers manage to improve over the lectures uploaded in 2013, that were gold already.
@thanirmalai
@thanirmalai Жыл бұрын
The best lecturer i have ever seen in my life
@ArunKumar-ut4rq
@ArunKumar-ut4rq 7 ай бұрын
personal rewatch reference - 12:00 (rewatch why selection sort for unsorted dynamic array and insertion sort for sorted dynamic array)
@manguy2011
@manguy2011 Жыл бұрын
This literally made the whole picture easier. I was being lazy at learning binary heaps and heap sort because they seemed daunting. But this lecture made everything make sense. Wish me luck with interviews :P
@MehbubulHasanAlQuvi
@MehbubulHasanAlQuvi 3 жыл бұрын
OMG OMG OMG! Much Anticipated! Gold!
@djn138
@djn138 Жыл бұрын
Word, I didn’t realize the completeness of the tree was what allows us to store it in an array. 18:48
@rocketman3770
@rocketman3770 3 жыл бұрын
this was an amazing lecture; I learned a lot thank you.
@shymaaarafat1342
@shymaaarafat1342 3 жыл бұрын
For the implicit array presentation, would there be any problem if I made it 2D array with var size raws(one raw for each tree level, like a 90 angle triangle)? -It's the same storage -easier to visualize under any traversal -if the tree is not complete, it would be easier to make it more dynamic (less shifts) -I don't care about the heap property, I mean in the specific problem I'm thinking of internal nodes (non leaves) are just a function from real data at the leaves -I also don't care very much about the time as long as the path length keeps logarithmic and doesn't increase with it -So, even if the tree is not complete I'm still adding an extra space < 2N pointers for X leaves 2^i < X < 2^(i+1) .....[1] If I had to reserve an extra space to reach full tree (I don't think I do, unless I went down to the memory blocks level to make the whole array in adjacent blocks) -Anyways, if I had to reserve 2^(i+2) {2^(i+1) for leaves and 2^(i+1) for internal nodes, upper rows in my design} Then extra space is 2^(i+2)-2X ....[2] While extra space, assuming both fields have the same size, for pointer case is 2X -And we have from [1] : 2^(i+1)
@shymaaarafat1342
@shymaaarafat1342 3 жыл бұрын
Likes are not welcomed, only answers
@shymaaarafat1342
@shymaaarafat1342 2 жыл бұрын
@Andriy Dmytriyev And you wake up after 4 months to reply to such an old comment?! . No a 2d array of previously known size doesn't involve any pointers thank you for your polite words
@shymaaarafat1342
@shymaaarafat1342 2 жыл бұрын
That was a very rude person, a deliberately malicious reply . What I meant is that I just used the features of some Programming languages that makes you able to address a 2d array to make the index formula more easier to calculate, but the main idea is exactly as it is explained here a contiguous array in memory that is eventually will be indexed as a vector or 1D array
@anonymitynone6957
@anonymitynone6957 2 жыл бұрын
I think you mean for a 2d array A,len(A[0])=1,len(A[1])=2...len(A[i])=2^i at first as "like a 90 angle triangle" describes,(I can't clearly understand what your design means),but why it would be easier to make it more dynamic if the tree is not complete
@zchelseal
@zchelseal Жыл бұрын
Is my understanding correct of why we prefer to use an array over the pointers approach? Since our implementation of insert, delete (and by extension, build) all comes down to insert_last or delete_last (with a bunch of value-swapping), each of which an array can support in constant time, it makes the pointer implementation less desirable because at each node we would need to store both a value and a pointer, which would effectively make our memory allocation double that of an array. (are there any other benefits that I missed?)
@paulluckner411
@paulluckner411 9 ай бұрын
You need to know that CPUs are more efficient at working with contiguous memory compared to distinct small heap allocated chunks. You might want to do some online searches on cache lines, cache-friendliness, pointer chasing. This is also the reason why std::vector is recommended to be the default data structure in C++.
@SalesforceUSA
@SalesforceUSA 3 жыл бұрын
I don't know why KZbin recommended this to me, but I stayed for the whole lecture.,
@NavinY5
@NavinY5 Жыл бұрын
Day 12 present
@jurgenblick5491
@jurgenblick5491 3 жыл бұрын
I like this
9. Breadth-First Search
52:53
MIT OpenCourseWare
Рет қаралды 54 М.
6. Binary Trees, Part 1
50:59
MIT OpenCourseWare
Рет қаралды 162 М.
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 140 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 59 МЛН
2.6.3 Heap - Heap Sort - Heapify - Priority Queues
51:08
Abdul Bari
Рет қаралды 2,2 МЛН
7. Binary Trees, Part 2: AVL
54:09
MIT OpenCourseWare
Рет қаралды 74 М.
The $2 Billion AI Startup That Could Replace Coders
20:59
Forbes
Рет қаралды 44 М.
3. Sets and Sorting
52:56
MIT OpenCourseWare
Рет қаралды 173 М.
Every Sorting Algorithm Explained in 120 minutes (full series)
1:57:33
Kuvina Saydaki
Рет қаралды 76 М.
Understanding B-Trees: The Data Structure Behind Modern Databases
12:39
3 Types of Algorithms Every Programmer Needs to Know
13:12
ForrestKnight
Рет қаралды 508 М.
The hidden beauty of the A* algorithm
19:22
Polylog
Рет қаралды 908 М.