In these notes, we discuss Data Structures and Algorithms using Java Programming. The data structure is a way to store and organize data so that it can be used efficiently. It is a set of concepts that we can use in any programming language to structure the data in the memory. Data structures are w...
DSA in Java
1. Data structures and algorithms act as a oil to programming whether it's
any programming language its application from operating system to compiler design
artificial intelligence to computer graphics and mobile app development. Data
structure helps store and organize data efficiently everywhere being an expert in
different data structures like stack queue link lists trees and graphs would help
crack any interview and write an optimized code that can benefit any organization.
made up of two words data and structure so data is nothing but the information that
you want to store in a computer and structure is how you arrange your data in the
computers depending upon these two factors. Data structures are different from how
you store your data when you talk about linked list in areas you have to always
store data in a contiguous memory applications. All the data is arranged in a
sequential manner and every element has two neighbors. There are always predefined
extremes like if you talk about array there will be a starting index and an ending
index. Linked lists come into picture obviously with eddie you have a fixed fixed
fixed right.
2. If you want to add an element in stack you can not remove any of these
elements unless and until you have removed the top. This has restricted how we
insert and delete our elements right this is the restriction that is there so this
is your stack okay now if you talk about queue it works in a different manner.
Nonlinear data structures allow arrangement of data in a non-sequential manner
there can be n neighbors for a single element. They do not have extremes like we
saw in a linear data structure there were extremes. In case of areas you have fixed
size with linked list you have dynamic size with arrays you have you have to store
contiguous movie locations. All of these data structures are non-linear data
structures so what is an array it is a linear data structure that means elements
will be stored in a linear fashion right linear fashion now if you talk about
memory obviously these addresses will be hexadecimal. All elements that are greater
than 10 that means 11 12 13 14 will be on the right hand side and all those that
are less than 10 will be in the left hand side. Then we have graphs, avl trees and
red directories.
3. Can we store this array in your memory in the memory no because it
needs contiguous memory allocation that means when in you have memory or locations
or memory locations available in a one big chunk of 16 bytes. Can we access
elements randomly yes with the help of indexes so if you talk about this array
right one two three and 4 obviously this there will be a name associated with this
array. The data type or the type of data that you can store in this array will be
homogeneous that means you can only store similar elements in the array. the array
now how can you access the first element so error of zero now it was around 100
plus 0 because there are no bytes right. When you talk about an array there will be
a name associated with the array and then the data type are you going to store
integer values in that area. Only one index will be used or one subscript or one
index that we use and then definitely the size of the edit so this is how you
declare your 1d array.
4. Inside this one nd array you have another 1d array right now this is
known as 2d array. If you want to access the element that is present at this
location what you will do you will run two for loops. internally it is treated as
if they are again in a contiguous memory location but this time around you have a
1d. array. The problem statement is that we have to write a program in which we are
going to create one dimensional array. Then we 'll talk about how to create a two
dimensional integer array and how to store number into it. The search and sort
operation that is will be sorting down in ascending order each element of the one-
dimensional and two-dimensional arrays as well as will implement search on the
given array. Java has so many constructs where we can loop around a given code. One
of the construct is your for loop so we 'll be using for loop here. The next
condition in the for loop is stopping condition like till where this i should
iterate over it is starting from zero and where should it end.
The benefits of buying summaries with Stuvia:
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
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
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 atharvadere. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $9.59. You're not tied to anything after your purchase.