Arrays - Data Structures & Algorithms Tutorials in Python #3
Vložit
- čas přidán 9. 06. 2024
- Arrays are most commonly used data structure in any programming language. In this video we will cover what arrays are using python code, look at their memory representation and also cover Big O analysis for various operations such as look up using index, lookup using value, array traversal etc. We will also see difference between static and dynamic array. In the end I've an exercise for you to solve. Here is the link for exercise:
Exercise: github.com/codebasics/data-st...
Topics
00:00 Introduction
00:15 Array introduction
03:26 Big O Analysis
08:03 Static vs Dynamic Array
13:02 Exercise
#arrays #pythonarrays #arrayspython #arraysdatastructures #array #arraydatastructure #datastructures #algorithms #python
Do you want to learn technology from me? Check codebasics.io/?... for my affordable video courses.
Next Video: • Linked List - Data Str...
Previous video: • Big O notation - Data ...
Complete playlist: • Data Structures And Al...
🌎 My Website For Video Courses: codebasics.io/?...
Need help building software or data analytics and AI solutions? My company www.atliq.com/ can help. Click on the Contact button on that website.
#️⃣ Social Media #️⃣
🔗 Discord: / discord
📸 Dhaval's Personal Instagram: / dhavalsays
📸 Codebasics Instagram: / codebasicshub
🔊 Facebook: / codebasicshub
📱 Twitter: / codebasicshub
📝 Linkedin (Personal): / dhavalsays
📝 Linkedin (Codebasics): / codebasics
🔗 Patreon: www.patreon.com/codebasics?fa...
Do you want to learn python from me with a lot of interactive quizzes, and exercises? Here is my project-based python learning course: codebasics.io/courses/python-for-beginner-and-intermediate-learners
Another Correction I would like to tell:
When we inserts more elements it's size increase twice only!
Not 3 times as you said....eg. if 5 is initial capacity then it's final Total capacity would be 10 not (5+10)!
Minor correction: At 7:36 the slide should be stock_prices.remove(305) The argument is the actual element that you want to remove and not the index.
At 7:36
It would’ve been better if the syntax was similar to insert with the position and the value or at least the position. This is because, there may be multiple 305 values and we may want to remove the second instance.
@KAMYA SINGHI pop takes no argument right? it simply removes the last element from the list. We can use del stock_prices[1] to remove element from index 1
That's what I thought 😅
Another Correction I would like to tell:
When we inserts more elements it's size increase twice only!
Not 3 times as you said....eg. if 5 is initial capacity then it's final Total capacity would be 10 not (5+10)!
list.remove() uses value rather than index. To delete value by index use pop() or del(). Just a small correction. Great video! Helps a lot.
I am from absolute non-tech background switching my field to tech field(data analytics) and your videos are the greatest help in my learning journey thank s you so so much.
Just finished this one, very solid teaching skills. Blessing 🙏🏽 Thank you for sharing this information so professionally
Really very happy about finding such an obvious and understood funny video series about data structures and algorithms. Everything is 100% clear with deeply explained theories and well-understood practicals. Also, the exercise series with the videos are highly appreciated. Dear sir thank you so much for the fantastic video series. ❤💖
Listening to you makes me feel I can learn everything. You are really blessed with the art of teaching and we are blessed to have someone like you. 😇
Please make more DSA videos.
I have read this many times but never got it , this is so precise and simple. Thanks a lot for providing such good content and that too for free
Dear Dhaval Sir,
Your teaching methodology is very simple, it helps in understanding quickly and it gets registered in Mind permanently
Thanks codebasics. This is perfect tutorial for Data Structures and Algorithms.
Glad, you liked it. 😊
I am Non-CS background and struggling to learn data structures. But I am found it very easy and simple because of this playlist. Thanks a lot for playlist, Sir
Sourabh I am glad it was helpful 😊👍
Ultimate Clarity, Hats off and thank you 👍
such an impressive way of explanation! Thank you for these tutorials
Great sir
Simply you are all-rounder and awesome
Such easy explanations and such awesome content... Thank you ! May God bless you 😇
sir, you explain in very strait forward manner, thanks,
best tutorial ....tired finding some tutorials and I literally cried because of happiness when I found this....🥺 well explained ....no need to study extra interview questions when we are clear with the concept well....😊
Simply perfect: Thank you very much for your great presentation. This helps a lot!!
Thanks for the great teaching! You're amazing!
Great explanation and tutorial. Thank you very much. :)
Glad to hear that. I hope you are doing enough practice for the subject.
thank you very much, sir, I learned a lot in your video. that's my code below.
exp = [2200,2350,2600,2130,2190]
month = ["janaury","February","March","April","may"]
data=dict(zip(month,exp))
print(data)
print("extra dollars spented:", exp[1]-exp [ 0] )
print("total expensise in first quarter:", exp[0]+exp[1]+exp[2])
data["june"]= 1980
print(data)
print("Did i spent 2000 in an Month:", 2000 in data)
exp[3] = exp[3]-200
print("What you get after $200 returned in the month of April:", exp[3])
Amazing work sir. And really liked your idea of giving exercises at the end of the video. That excercise helped me a lot.
Glad it helped
Thank you so much for this playlist
Thank you so much, you're a great teacher.
Great you describe many concept in much simpler way, Thank you so much.
Glad it was helpful!
One of the best tutorial ever....thanks for guiding us...
👍😊
Adding exercise in the last is very helpful..thank you ❤
Great video. Memory management taught is great. Please continue to provide us with awesome content.
Wonderful series of lessons.
Thank you for providing all these contents for free!
Glad you like them!
Very informative sir, thanks a lot for sharing :)
Thank you so much sir for this wonderful class.
Thank you so much sir for this exceptional tutorial playlist.
Glad you liked it
Thankyou very much... very well explained
Thank you for the great tutorial. I tried all exercises and I could write the solution 3 using list comprehension. Not at all a big thing but it is after a very long time that I am writing a programing code. It increased my confidence. Thank you for the exercise.
😊👍
Great way of learning Data Structure .. thanks @codebasics
great
Glad you liked it!
May I know which book u used for understanding these concepts, and if u can tell any book for DSA in "PYTHON".
wow this is so clear.Thank you.
Thank you for the explanation.
Thank you for the great presentation, just one suggestion though the exercise is more amazing if you manipulate data in 2D arrays
Must watch series!!!
This was a pretty good lesson. Thank you.
Edit: Also the practice was great.
This is very useful, thank you!
Glad it was helpful!
wonderful series...can you plz add more tasks? addicted to your channel
Thank You very Much for this video. I foud it very helpful. Next Month i'll start my first class in Data Science Master.
Wish you all the best for your class bechir ☺️👍
Such clear explained
Instructor can I ask u a question? Shouldn't the hexadecimal representation be like 0x00500 and then 0x00520 as 4 bytes is 32 bit and it is represented by a 2 increase and the 2nd from last value
ah man you are beyond great keep going!
Excellent knowledge, but in this 1st exercise can we do with set function especially adding an element, or Q4, 5
I used dictionaries for solving this,
Felt good :) One step a day :)
Thank you
Great job!
Me too
thank you so much, great videos!
I am happy this was helpful to you.
Thank you very much!
Thank you sir.
Your video helps me a lot.
You are most welcome
Excellent Explanation
Tq
Thank you very much sir
Excellent😀
Great work thanks
Sir, at 4:28, what if the list contains different types of data like float, int, and string. Then how is the address calculated? Does it internally call type() on every element in the list and then use the sizeof function accordingly.
Nicely explained
very interesting and nice exercise questions thx sir
Glad it was helpful!
the solutions link to the excercises have been expired
please check sir and update
Thanks a👍lot sir...it will be great if you add more assignments
Once you have solved the assignment go to leetcode and solve more problems related to arrays.
What would the runtime be if instead of using a for loop to find an element we use pythons in? If we want to find value 300 in array, we can use if 300 in arr: ... We can then print that items index with arr.index(300) or print false if item not in array. Would this still be linear time or constant?
Excellent!
Thank you so much
@codebasics sir please continue the series, it's a request i am following your playlist for python DSA it's really helpful. Please also add after recursion that is of dynamic programming and all rest data structure
how much dsa this playlist has already covered?
Hi, I just finished you exercise. But I have some questions. Could you explain the third part of this exercise ? I don't understand the function.
Amazing video, As you explained that a number is stored in 4 different containers during storage on RAM. I had a quick question that how are the numbers stored when they have a negative value? how is the negative sign initialized or defined during storage (I believe that the number is stored as its 2's complement in the RAM, is it right, if yes you could include that too in your video)
For removing the array element it's not the index you might want to correct the video too'... if you want to use the index you might want to go with pop instead. Not nitpicking but I'm a huge fan, sir. what you do is a great inspiration.
Thank you so much, You are a great Teacher.
Till now, I thought that insert operations is O(1) since we are doing one operation that too for specific index, after watching this video only I learnt that whole memory is swaped because of this one opertion.
Thanks you so much.
Good day.
12:20 C/C++ can store unusual data types in one array/list/tree/vector/etc. But of course, it cannot be happening without tricks. For example, you actually can store an array with a structure that contains some [void*] pointer and the element that describes the contents of the pointer (I mean what is this and how can I do [...(struct some_name*) ptr; ...] ). This code/example is normal for the Linux Kernel. But of course, it is really inconvenient. REALLY!!!
But newer, the less - good videos, my friend.
so here in the python case as it has no static array concept, everytime when a new element is added in the existing list[] it may be possible to reallocate entire list in new memory segment if nearby slot is not available ?
@codebasics Can Tuples in Python be called static arrays?
3:36 the address of the 301 and 292, in hexadecimal should be 0x0050C and 0x510, correct? Not 50A and 50F?
I am also non CS. Your videos are of great help. Please suggest good books on data stuctures and algorithms in python. Aspiring to become data analyst.
Sir Please make a series on Algorithms in python
At 5:30, Just in case when we have mixed type data in the list, e.g. list_mixed = [1, 'a', 2, 'b', 3, 'c'], think the lookup complexity is not O(1)? Please correct if I am wrong
In min 3:19 Could you please explain why we assigned location addresses of last two numbers in the list with 0x0050A and 0X0050F? If we give every number four bytes it should be 0X0050C for the first and 0x00510 for the second ? or I did I it wrongly?
You are really good in explanation !!
Glad it was helpful!
@@codebasics You should make a course on udemy or Coursera or EDX!!
Grate work sir
Glad it was helpful!
Can you explain why is insertion at the end of the dynamic array constant time a.k.a 0(1)
Sir in python it is said that we store the address of each value in a contiguous manner and the value will be stored elsewhere when we access it using index we are actually accessing it through address of the value is it true?
very informative playlist
Glad you liked it
Thanks
Great video. Quick check: remove method should remove element by value, not index.
In 2d array we create stock prices of 1year✨
Thanks sir...
Awesome tutorial sir
Thanks and welcome
Sir after the new memory created and the old values are copied to the new memory will the old memory be cleared?
shouldnt the delete part be del stock_prices[1] instead of stock_prices.remove(1) as remove deletes the element by value?
yea
Sir I have question with u in dynmaic array 'x' size of array full then. We insert element it will make '2x' size of array in New memory location then copy x array into 2x size of array after that 'x' array is available in memory or not??? According to my thinking garbage collector remove it . Am I right or wrong reply me?????
yes. after it copies to new location old memory area is freed up
Sir please upload the next videos as soon as possible. Eagerly waiting .
Sure I am uploading on latest by tomorrow.
@@codebasics Thank you sir
Timestamp 6:23 it's a linear search, so big O is O(n). If we have used Binary search then it would be O(log n). But, python list has index() function, so is it O(n) for index() ?? or is it different?
I'm curious what program are you using in 11:50 to diagram the array?
that was very easy problems i was based on python language i thought it would have been data structures
If we insert an element at end of list Is time complexity still O(n) ?
Quick question, to look up an element in array, formula used is [memory location + (index * size of int) ]. As we know in Python we can use list with different object type, if that is the case, how does the above equation will look like to find a specific item using index?
Up on more analysis, python list stores references of int or str or objects not the value itself as you have mentioned in the video.
If array is unsorted then insertion/deletion take O(1) because in unsorted we can't shiftup one by one elements we simple shift the previous value to last and new to that index.
If array is sorted then we couldn't do that insertion / deletion like above scenerio which is O(1) in sorted case complexity become O(N).
sir at @7:52 of this video i am getting an error
intj.remove(1)
ValueError: list.remove(x): x not in list
andthis my code :
intj=[3,5,6,78.8]
intj.remove(1)
print(intj)
at 7:39 in python to remove element by index use pop()...we use remove() to remove particular element
Yes, remove takes the direct value that has to be removed?