100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
DSA notes in Python with student's notes. $8.49   Add to cart

Class notes

DSA notes in Python with student's notes.

 0 view  0 purchase
  • Course
  • Institution

Student can easily understand the language as it is very easy to understand. It also helps reader to easily grasp the knowledge written and implement it logically.

Preview 3 out of 22  pages

  • March 27, 2023
  • 22
  • 2022/2023
  • Class notes
  • Dr. meena thakur
  • Class 11th-12th
avatar-seller
Data Structures and Algorithms


Using Python you can store Apple stock prices and to retrieve the price for a
given day you can use the index like this. Arrays are most commonly used data
structure in any programming language and that's what we 'll be covering
today here is the list of topics so feel free to skip ahead in the end. A simple
Python program can be running a full loop on your values and comparing this
values one by one when you get 301 you return that value or print it. The
complexity of this program is also order of n which means you how to do n
number of iteration to find the value in the array. The Big O complexity of
looking at an array element by index is order of one. The complexity of this
program is order of n because you have to do n number of wraps deleting
element is also similar. In Python the actual memory presentation is little
different because python uses objects and references but I 'm just giving you a
simple presentation so that you understand the concept behind an array in
Python the list that we used is actually a dynamic array.

Dynamic arrays grow there is an overhead of allocating new memory and
copying all the elements so that they can handle the load of new insertions
arrays can store numbers, tags like this they can even store a complex objects.
Python can store multiple types of element and can store integer and text
both in the same array but Java and C++ cannot do it there the type is fixed
once you say integer you cannot insert string. Try to solve this on your on and
then you can compare your answer with my answer by clicking on this solution
link but do not click on solution link directly. Practice is the only way to learn
programming so by just watching my video you're not going to become
expert okay you have to practice these so practice this.

,4. Linked List in Python:

We will be implementing linked list in Python today and will go through
various operations on the linked list and the big o complexity in the end as
usual. We 'll have an interesting exercise for you to solve and here is the list of
topics. We first need to look into array because there are some issues with
arrays that linked list tries to solve, this data structure is called linked list. it has
two main benefits over an array.. insertion operation becomes extremely easy
in this new data structure. When you want to insert element at the beginning.
The complexity is order of 1 because all you are doing is creating a new node
and then modifying those links with doubly linked list, it becomes very easy..
Python is open pycharm and i have created two classes.. The first class is an or
class which represents an. an individual element in the linked list. It has two
class members. One is data.. The second class is a linked list class where you
need a head variable which points to the head..

Iter is equal to Itr.next.

Listen, I trading through element one by one. in each iteration you want to
print a value.. So for printing a value, what I 'm going to do is. I will just create
a linked list string and in that string I will append that data from the string.
click run add it and it runs so you can see that first I inserted five and then in
front of that I inserted 89. Hence, it printed 89 and five. the next method. I
want to implement will take a list of values as an input and it will create a new
fresh linked list.. The next step is to implement a function which can return me
a length of the linked list. the new node, which I am going to create here so
that new node. Here so that new node will be node data and none let 's taste
this method. Python is a simple loop which goes through each of the elements
in your linked list.. Python is it will do garbage collection for you. If you are
using c++ type of language, then you have to explicitly clean up the memory
associated with your head here. in that case, you will say index is equal to 0. It
means remove the element at the beginning of the linked list, which is a head..

, The first function I want to implement is insert add where I provide an index
and the value and it inserts figs. For example, in this case at the location 0,
which is in front of Banana. itr Itr is equal to itr dot next. So this is a simple
loop going through each of the elements. In the linked list the code that I
showed you is available on my Github location.




6. Hash Table:

In this tutorial, we will learn how to handle collisions in a hash
table. In part one of the video, we implemented hash tables in
Python, and now we will enhance it to handle collisions using the
separate chaining method. We will also cover linear probing and
have some exercises for you to solve.


For example, in this picture, we have a hash map where the key is
"Mark 6" and the value is "310." Using a hash function, we find the
appropriate index in our array, and the value gets stored there.
However, if we have a collision where another key, such as "Mark
17," has the same index, we need to handle it differently. We can
use an approach called "separate chaining" to handle this. The big
O complexity analysis here is usually O(1) for average case hash
map search complexity, but it can go up to O(n) if we have a bad
hashing function and all the keys generate the same index.

The Python class we used earlier is not handling collision. It is only
getting a hashing function. When we do `getitem` or `setitem`, it
will go to a particular index in our array and store the value. The
problem is that when two keys try to store their values at the same
location, it will override the previous value. For example, when I try
to store a value for "Mark 6" and "Mark 17," they both have the

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller 19bcs1323. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $8.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

76462 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$8.49
  • (0)
  Add to cart