Introduction PDF
Introduction PDF
INTRODUCTION
To solve the above-mentioned problems, data structures come to rescue. Data can be
organized in a data structure in such a way that all items may not be required to be
searched, and the required data can be searched almost instantly.
Objective of Course:
To impart the basic concepts of data structures and algorithms
To understand concepts about searching and sorting techniques
To Understand basic concepts about stacks,queues,lists,trees and graphs
To understanding about writing algorithms and step by step approach in solving
problems with the help of fundamental data structures
1
1.2 Software used
*ECLIPSE
The JDK is a key platform component for building Java applications. At its heart is the
Java compiler
The Java Development Kit (JDK) is one of three core technology packages used in Java
programming, along with the JVM (Java Virtual Machine) and the JRE (Java Runtime
Environment). It's important to differentiate between these three technologies, as well
as understanding how they're connected:
Developers new to Java often confuse the Java Development Kit and the Java Runtime
Environment. The distinction is that the JDK is a package of tools for developing Java-
2
based software, whereas the JRE is a package of tools for running Java code.
The JRE can be used as a standalone component to simply run Java programs, but it's
also part of the JDK. The JDK requires a JRE because running Java programs is part of
developing them.
*UDEMY:
It doesn’t matter whether the above will take 1 year, 5 years, 10 years or the entire
life. They’ll love to die on their work-desk working for the goals and metrics
mentioned above.
The way the divide their course it’s also very good for students, and students can get
course according to their own prior knowledge.
I enrolled for the Data Structure and Algorithms: Deep Dive using Java at
Udemy in July 2021 and I loved the course so much. These courses have helped me
3
build my basics of Data Structure and Algorithm. It was only after joining this Course
that I started competitive coding. The study material and class are incredible
❖ PURPOSE
• Are necessary for design of efficient algorithms
• It built our logical mind to solve real world problems
• It will give us more knowledge about how we optimise our code
that it run in minimum time and space complexity
• Most important almost every company in India 80% focus on
DS-Algo
*JAVA:
In my project, I have chosen Java language for developing the code.
About Java
Initially the language was called as “Oak” but it was renamed as “Java” in
1995. The primary motivation of this language was the need for a platform-independent
(i.e., architecture neutral) language that could be used to create software to be
embedded in various consumer electronic devices.
Java has had a profound effect on the Internet. This is because, Java expands
the Universe of objects are transmitted between the Server and the Personal Computer.
4
They are: Passive information and Dynamic active programs. The Dynamic, Self-
executing programs cause serious problems in the areas of Security and probability.
But, Java addresses those concerns and by doing so, has opened the door to an exciting
new form of program called Applet.
And applet is actually a tiny Java program, dynamically downloaded across the
network, just like an image. But the difference is, it is intelligent program, not just a
media file. It can react to the user input and dynamically change.
Features of java
• Security
Every time you that you download a “normal” program; you are risking a viral
infection. Prior to Java, most users did not download executable programs frequently,
and those who did scan them for viruses prior to execution. Most users still worried
about malicious program exists that must be guarded against. This type of program can
gather private information. Such as credit card numbers, bank account balances, and
passwords. Java answers the both of these concerns by providing a “firewall” between
a networked application and your computer.
• Portability
5
create portability. Indeed, Java’s solution to these two problems is both elegant and
efficient.
The key that allows the Java to solve the security and portability problems is
that the output of Java compiler is Byte code. Byte code is a highly optimized set of
instructions designed to be executed by the Java run-time system, which is called the
Java Virtual Machine (JVM). That is, in its standard form, the JVM is an interpreter
for byte code. Translating a java program into byte code helps makes it much easier to
run a program in a wide variety of environments. The reason is, once the run-time
package exists for a given system, any Java program can run on it.
Beyond the language, there is the Java virtual machine. The java virtual
machine is an important element of the java technology. The virtual machine can be
embedded within a web browser or an operating system. Once a piece of Java code is
loaded onto a machine, it is verified. As part of the loading process, a class loader is
invoked and does byte code verification makes sure that the code that’s has been
generated by the compiler will not corrupt the machine that it’s loaded on. Byte code
verification takes place at the end of the compilation process to make sure that is all
accurate and correct. So byte code verification is integral to the compiling and
executing of Java code
6
• Java Architecture
• Compilation of code:
When you compile the code, the Java compiler creates machine code (called
byte code) for a hypothetical machine called Java Virtual Machine (JVM). The JVM
is supposed to execute the byte code. The JVM is created for overcoming the issue of
portability. The code is written and compiled for on machine and interpreted on all
machines. This machine is called Java Virtual Machine.
PC Java
Compiler Interpreter
(PC)
Source Java
Code Byte Code
…………..
………
……………
…….. (Platform
…………… (Independ
…….. Macintosh
ent) Java
Compiler
…………… Interpre
…….. ter
……………. (Macint
SPARC Java
Compil Interpr
er eter
(Sparc)
7
During run-time the Java interpreter tricks the byte code file into thinking that it is
running on a Java Virtual Machine. In reality this could be a Inte3l Pentium Windows
95 or sun SARC station running Solaris or Apple Macintosh running system and all
could receive code from any computer through Internet and run the Applets.
• Simple
Java was designed to be easy for the Professional programmer to learn and to
se effectively. If you are an experienced C++ programmer, learning Java will be even
easier. Because Java inherits the C/C++ syntax and many of the object oriented features
of C++. Most of the confusing concepts from C++ are either left out of Java or
implemented in a cleaner, more approachable manner. In java there are a small number
of clearly defined ways to accomplish a given task.
• Object-Oriented
Java was not designed to be source code compatible with any other language.
This allowed the Java team the freedom to design with a blank slate. One outcome of
this was a clean usable, pragmatic approach to objects. The object model in java is
simple and easy to extend, while simple types, such as integers, are kept as high-
performance non-objects.
• Robust
8
2. PROJECT WORK
• IMPLEMENTATION OF HASHMAP
Objective:-
Hash Map is a Map based collection class that is used
for storing Key & value pairs, it is denoted as Hash Map<Key, Value>
or Hash Map<K, V>. This class makes no guarantees as to the order of
the map. It is similar to the Hash table class except that it is
unsynchronized and permits nulls(null values and null key).
THEORY:-
One object is used as a key (index) to another object (value). It can store different
types: String keys and Integer values, or the same type, like: String keys and String
values.
9
METHOD OF HASHMAP:-
• ADD AN ITEM
• Access an Item
capitalCities.get("England");
• Remove an Item
capitalCities.remove("England");
capitalCities.clear();
10
• HashMap Size
To find out how many items there are, use the size()
method:
capitalCities.size();
// Print keys
for (String i : capitalCities.keySet()) {
System.out.println(i);
}
capitalCities.keySet();
11
• Checking for given key value:
Parameters: The method takes just one parameter key element that refers to the key
whose mapping is supposed to be checked inside a map.
Return Value: The method returns boolean true if the presence of the key is
detected else false .
capitalCities.conatinsKey();
12
3. IMPLEMENTATION
• import java.io.*;
import java.util.*;
public HashMap() {
initbuckets(4);
size = 0;
}
13
private int findBucketIndex( K key ) throws Exception{
int hc = key.hashCode();
if( hc < 0 ){
hc = -hc;
}
int bi = hc % buckets.length;
return bi;
}
if( di == -1 ){
buckets[ bi ].add( new HMNode( key, value ) );
size++;
}else{
HMNode cnode = buckets[ bi ].get( di );
cnode.value = value;
}
// n / N
if( (( size * 1.0 ) / buckets.length) > 2.0 ){
reShuffle();
}
}
if( di == -1 ){
return null;
}else{
HMNode cnode = buckets[ bi ].get( di );
return cnode.value;
}
}
if( di == -1 ){
return null;
}else{
HMNode cnode = buckets[ bi ].remove( di );
size--;
return cnode.value;
}
}
return set;
}
18
Sample Input for Testing:-
19
4. RESULT & DISCUSSION
In an ArrayList what we learn we can add numbers dynamically into a collection and
get it from any index in O(1) time.
Same here in HashMap we can access the element not only by its index number also
with its value in same O(1) time, in ArrayList we can add infinite number of duplicate
values but here in HashMap we cannot add duplicate.
Time Complexity:-
Complexity in searching, removing, addition are much better than ArrayList.
20
5. FUTURE SCOPE AND CONCLUSION:
FUTURESCOPE:-
• There is one clear trend from the multiple surveys on the most widely used
programming language worldwide: Java and JavaScript still rule the
coding world.
CONCLUSIONS:-
Java offers the real possibility that most programs can be written in a type-
safe language. However, for Java to be broadly useful, it needs to have more
expressive power than it does at present. This paper addresses one of the areas where
more power is needed.
21
REFRENCES
Tutorialspoint - https://www.tutorialspoint.com/eclipse/index.htm
Javatpoint - https://www.javatpoint.com/internal-details-of-hello-java-program
Infoworld- https://www.infoworld.com/article/3296360/what-is-the-jdk-introduction-to-
the-java-development-kit.html
W3chools - https://www.w3schools.com/java/java_hashmap.asp
22