Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Junit for sort stack #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/test"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
29 changes: 29 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Algorithms-and-Data-Structures-in-Java</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
10 changes: 10 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions .settings/org.eclipse.wst.common.project.facet.core.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.8"/>
</faceted-project>
122 changes: 122 additions & 0 deletions bin/com/rampatra/bits/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Bits

## Basic Operators

#### AND:

| x | y | x `&` y |
----|---|:-------:|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |

#### OR:

| x | y | x `\|` y |
|---|---|:--------:|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |

#### XOR:

| x | y | x `^` y |
|---|---|:-------:|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |


## Shifts

_Disclaimer: We are taking `byte` (8 bits) as our datatype to explain the
concepts instead of the usual integer._

#### 1. Left Shift (<<):

1 << 3 = 8

> 00000001 << 3 = 00001000

#### 2. Right Shift:

**Two types:**

**a. Signed Right Shift (>>):**

64 >> 2 = 16

> 001000000 >> 2 = 00010000

-64 >> 2 = -16

> 111000000 >> 2 = 11110000

**b. Unsigned Right Shift (>>>):**

64 >>> 2 = 16

> 001000000 >>> 2 = 00010000

-64 >>> 2 = 56

> 111000000 >>> 2 = 00111000

## Helpful Masks

#### 1. Set the 4th bit from right:

```java
byte mask = 1 << 3;
```

Explanation,

```
00000001 << 3 = 00001000
```

#### 2. Set the first 3 bits from right:

```java
byte mask = (1 << 3) - 1;
```

Explanation,

```
00000001 << 3 = 00001000

00001000 - 00000001 = 00000111
```

#### 3. Mask with alternating 1010...10

```java
byte mask = 0x55;
```

#### 4. Mask with alternating 0101...01

```java
byte mask = 0xaa;
```

#### 5. Unset the 4th bit

```java
byte mask = 1 << 3;

byte num = num & ~mask;
```

Explanation,

```
00000001 << 3 = 00001000

~(00001000) = 11110111
```
76 changes: 76 additions & 0 deletions bin/com/rampatra/database/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Relational Database (WIP)

A __relational database__ is a digital database based on
the [relational model](https://en.wikipedia.org/wiki/Relational_model) of
data. In simple words, it is a collection of data items with pre-defined
relationships between them. These items are organized as a set of tables,
with columns and rows. Each column stores some specific attribute of an object/entity and the
row represents a specific object/entity.

A software system used to maintain relational databases is a __relational
database management system (RDBMS)__, for e.g., MySQL, Oracle DB, PostgreSQL, etc.
Virtually all relational database systems use __SQL (Structured Query Language)__
for querying and maintaining the database.

## Basic Definitions

1. Primary Key

2. Candidate Key

3. Composite Key

4. Prime/Non-prime attribute

## Types of SQL commands

1. DDL
2. DML
3. DCL
4. TCL

| Type | Command List |
|-------|-------------------|
| DDL | CREATE |
| | DROP |
| | ALTER |
| | RENAME |
| | TRUNCATE |
| | |
| DML | SELECT |
| | INSERT |
| | UPDATE |
| | DELETE |
| | |
| DCL | GRANT |
| | REVOKE |
| | |
| TCL | START TRANSACTION |
| | COMMIT |
| | ROLLBACK |

## Types of Joins

1. Inner Join
2. Left Outer Join
3. Right Outer Join
4. Full Join
5. Self Join

## Normalization Forms

1. 1NF
2. 2NF
3. 3NF
4. BCNF
5. 4NF
6. 5NF

#### 1NF

Required conditions:

a. All values should be atomic (non-breakable).
b. There should be a candidate key or a composite key (basically you should be able to uniquely identify all records in the table).


Loading