filename stringlengths 7 140 | content stringlengths 0 76.7M |
|---|---|
code/greedy_algorithms/src/egyptian_fraction/egyptian_fraction.py | # Part of Cosmos by OpenGenus Foundation
import math
import fractions
def fibonacciEgyptian(numerator, denominator, current_fraction=[]):
# Fibonacci's algorithm implementation
inverse = denominator / numerator
first_part = fractions.Fraction(1, math.ceil(inverse))
second_part = fractions.Fraction(
... |
code/greedy_algorithms/src/fractional_knapsack/README.md | # Fractional Knapsack
----
## what is Fractional Knapsack?
>see [Wikipedia](https://en.wikipedia.org/wiki/Continuous_knapsack_problem)
In theoretical computer science, Fractional Knapsack problem is an algorithmic problem in combinatorial optimization in which the goal is to fill a container (the "knapsack") with fra... |
code/greedy_algorithms/src/fractional_knapsack/fractional_knapsack.c | /* Part of Cosmos by OpenGenus Foundation */
#include <stdio.h>
int n = 5; /* The number of objects */
int c[10] = {12, 1, 2, 1, 4}; /* c[i] is the *COST* of the ith object; i.e. what
YOU PAY to take the object */
int v[10] = {4, 2, 2, 1, 10}; /* v[i] is the *VALUE* of the ith object; i.e.
... |
code/greedy_algorithms/src/fractional_knapsack/fractional_knapsack.cpp | /*
* Part of Cosmos by OpenGenus Foundation
*/
#include <iostream>
#include <algorithm>
using namespace std;
// Custom structure for Item to store its weight and value
struct Item
{
int value, weight;
// Constructor to initialize weight and value
Item(int value, int weight) : value(value), weight(weigh... |
code/greedy_algorithms/src/fractional_knapsack/fractional_knapsack.cs | /*
*Part of Cosmos by OpenGenus Foundation
*/
using System;
namespace FractionalKnapsack
{
// Custom object for Item to store its weight and value
public class Item
{
public int Value { get; set; }
public int Weight { get; set; }
public Item(int value,int weight)
{
... |
code/greedy_algorithms/src/fractional_knapsack/fractional_knapsack.go | //Part of Cosmos Project by OpenGenus Foundation
//Implementation of the factional knapsack on golang
//written by Guilherme Lucas (guilhermeslucas)
package main
import (
"fmt"
"sort"
)
type Item struct {
value float32
weight float32
}
func fractional_knapsack(items []Item, maxWeight float32) float32... |
code/greedy_algorithms/src/fractional_knapsack/fractional_knapsack.java | /* Part of Cosmos by OpenGenus Foundation */
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Scanner;
/**
* Added by Vishesh Dembla on October 07, 2017
*/
public class fractional_knapsack {
private double finalValue;
private int remainingWeight;
private ... |
code/greedy_algorithms/src/fractional_knapsack/fractional_knapsack.py | """
Part of Cosmos by OpenGenus Foundation
"""
# Item class with weight and values
class Item:
# intialize weight and values
def __init__(self, weight=0, value=0):
self.weight = weight
self.value = value
return
def fractional_knapsack(items, W):
# Sorting items by value /weig... |
code/greedy_algorithms/src/hillclimber/hillclimber.java | import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class Hillclimber {
private double[][] distances;
private int[] shortestRoute;
private static final int NUMBER_OF_CITIES = 100;
public Hillclimber() {
distances = new double[NUMBE... |
code/greedy_algorithms/src/huffman_coding/README.md | # cosmos
Your personal library of every algorithm and data structure code that you will ever encounter
Collaborative effort by [OpenGenus](https://github.com/opengenus) |
code/greedy_algorithms/src/huffman_coding/huffman_GreedyAlgo.java | import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Comparator;
class HuffmanNode {
int data;
char c;
HuffmanNode left;
HuffmanNode right;
}
class MyComparator implements Comparator<HuffmanNode> {
public int compare(HuffmanNode x, HuffmanNode y)
{
return x.data - y.data;
}
}
public... |
code/greedy_algorithms/src/huffman_coding/huffman_coding.c | #include <stdio.h>
#include <stdlib.h>
#define MAX_TREE_HT 100
struct MinHeapNode {
char data;
int freq;
struct MinHeapNode *left, *right;
};
struct MinHeap {
int size;
int capacity;
struct MinHeapNode** array;
};
struct MinHeapNode*
newNode(char data, int freq)
{
struct MinHeapNode* te... |
code/greedy_algorithms/src/huffman_coding/huffman_coding.cpp | /*
* Huffman Codes
*/
// Part of Cosmos by OpenGenus Foundation
#include <iostream> // std::cout, std::endl
#include <map> // std::map
#include <string> // std::string
#include <queue> // std::priority_queue
struct huff_node
{
float weight;
huff_node *left, *right;
huff_node(float w, huff_node *l, huff_... |
code/greedy_algorithms/src/huffman_coding/huffman_coding.py | import heapq
import os
from functools import total_ordering
"""
Code for Huffman Coding, compression and decompression.
Explanation at http://bhrigu.me/blog/2017/01/17/huffman-coding-python-implementation/
"""
@total_ordering
class HeapNode:
def __init__(self, char, freq):
self.char = char
self.... |
code/greedy_algorithms/src/job_sequencing/README.md | # cosmos
Your personal library of every algorithm and data structure code that you will ever encounter
Collaborative effort by [OpenGenus](https://github.com/opengenus) |
code/greedy_algorithms/src/job_sequencing/job_sequencing.cpp | #include <iostream>
#include <algorithm>
using namespace std;
// Part of Cosmos by OpenGenus Foundation
// A structure to represent a job
struct Job
{
char id; // Job Id
int dead; // Deadline of job
int profit; // Profit if job is over before or on deadline
};
// This function is used for sorting all... |
code/greedy_algorithms/src/job_sequencing/job_sequencing.java | import java.util.Arrays;
import java.util.Comparator;
class Job {
char id;
int deadline, profit;
public Job(char id, int deadline, int profit) {
this.id = id;
this.deadline = deadline;
this.profit = profit;
}
}
public class job_sequencing {
public static void printJobSequ... |
code/greedy_algorithms/src/job_sequencing/job_sequencing.py | # Part of Cosmos by OpenGenus Foundation
class Job:
def __init__(self, name, profit, deadline):
self.name = name
self.profit = profit
self.deadline = deadline
def job_scheduling(jobs):
jobs = sorted(jobs, key=lambda job: job.profit)
max_deadline = max([job.deadline for job in job... |
code/greedy_algorithms/src/k_centers/README.md | # cosmos
Your personal library of every algorithm and data structure code that you will ever encounter
Collaborative effort by [OpenGenus](https://github.com/opengenus) |
code/greedy_algorithms/src/k_centers/k_centers.py | # Part of Cosmos by OpenGenus Foundation
import random
import math
# Euclidean Distance
def euclidean(x, y):
return math.sqrt(sum([(a - b) ** 2 for a, b in zip(x, y)]))
# K-Centers Algorithm
def k_centers(vertices, k, distance=euclidean):
centers = set()
centers.add(random.choice(vertices))
for i in... |
code/greedy_algorithms/src/kruskal_minimum_spanning_tree/README.md | # cosmos
Your personal library of every algorithm and data structure code that you will ever encounter
Collaborative effort by [OpenGenus](https://github.com/opengenus)
Below are the steps for finding MST using Kruskal’s algorithm
```
1. Sort all the edges in non-decreasing order of their weight.
2. Pick the smalle... |
code/greedy_algorithms/src/kruskal_minimum_spanning_tree/kruskal.c | // C++ program for Kruskal's algorithm to find Minimum Spanning Tree
// of a given connected, undirected and weighted graph
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// a structure to represent a weighted edge in graph
struct Edge
{
int src, dest, weight;
};
// a structure to represent a connected, ... |
code/greedy_algorithms/src/kruskal_minimum_spanning_tree/kruskal.cpp | #include <algorithm>
#include <vector>
namespace kruskal_impl {
using namespace std;
template<typename _ForwardIter, typename _ValueType>
pair<_ValueType, _ValueType> edgeFuncPolicy(_ForwardIter it);
template<typename _ValueType>
struct UnionFindPolicy
{
void merge(_ValueType a, _ValueType b);
bool connecte... |
code/greedy_algorithms/src/kruskal_minimum_spanning_tree/kruskal.py | # Part of Cosmos by OpenGenus Foundation
parent = dict()
rank = dict()
def make_set(vertice):
parent[vertice] = vertice
rank[vertice] = 0
def find(vertice):
if parent[vertice] != vertice:
parent[vertice] = find(parent[vertice])
return parent[vertice]
def union(vertice1, vertice2):
root... |
code/greedy_algorithms/src/kruskal_minimum_spanning_tree/kruskal_using_adjacency_matrix.c | #include <stdio.h>
#include <limits.h>
int
delete_min_edge(int *u, int *v, int c[][1024], int n, int *e)
{
int min = INT_MAX;
int i, j;
for (i = 0; i < n; ++i)
for (j = 0; j < n; ++j)
if (c[i][j] < min && c[i][j] != -1) {
min = c[i][j];
*u = i;
*v = j;
}
c[*u][*v] = -1;
*e = *e - 1;
return... |
code/greedy_algorithms/src/min_lateness/README.md | # Scheduling tasks to minimize maximum lateness
Given *n* tasks with their respective starting and finishing time, we would like to schedule the jobs in an order such that the maximum lateness for any task is minimized.
Taking in consideration various possible greedy strategies, we at last decide that choosing jobs w... |
code/greedy_algorithms/src/min_lateness/min_lateness.cpp | #include <bits/stdc++.h>
using namespace std;
class Request
{
public:
int deadline, p_time;
bool operator < (const Request & x) const
{
return deadline < x.deadline;
}
};
int main()
{
int n, i, finish_time, start_time, min_lateness, temp;
cout << "Enter the number of requests: ";
cin >> n; // no.... |
code/greedy_algorithms/src/min_operation_to_make_gcd_k/README.md | # Minimum Number of Operations to Change GCD of given numbers to *k*
GCD refers to the *greatest common factor* of two or more numbers. For ex: GCD of 10, 25 is 5.
We are interested in finding minimum number of operations to change the GCD of given numbers to *k* where an operation could be either an increment or decr... |
code/greedy_algorithms/src/min_operation_to_make_gcd_k/min_operation.cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n; // no. of elements in array
int k; // new GCD
cout << "Enter number of elements in array: ";
cin >> n;
cout << "\nEnter the array: ";
int arr[n]; // array
for(int i = 0 ; i < n ; i++)
cin >... |
code/greedy_algorithms/src/minimum_coins/README.md |
# cosmos
Your personal library of every algorithm and data structure code that you will ever encounter
Collaborative effort by [OpenGenus](https://github.com/opengenus)
## Minimum Coins
The **Minimum Coins** tackles the [Change-making problem](https://en.wikipedia.org/wiki/Change-making_problem).
It takes a value... |
code/greedy_algorithms/src/minimum_coins/minimum_coins.c | #include <stdio.h>
int
main()
{
printf("Enter Number of Denominations \n");
int n, i;
scanf("%d", &n);
int denominations[n], frequency[n];
for(i = 0; i < n; i++)
frequency[i] = 0;
printf("Enter Denominations in descending order \n");
for(i = 0; i < n; i++)
scanf("%d", &denominations[i]);
printf("Enter Bi... |
code/greedy_algorithms/src/minimum_coins/minimum_coins.cpp | /* Part of Cosmos by OpenGenus Foundation */
/* This file uses features only available on C++11.
* Compile using -std=c++11 or -std=gnu++11 flag. */
#include <iostream>
#include <vector>
std::vector<unsigned int> minimum_coins(int value, std::vector<unsigned int> denominations)
{
std::vector<unsigned int> resu... |
code/greedy_algorithms/src/minimum_coins/minimum_coins.go | package main
import (
"fmt"
)
type Scenario struct {
Value int
Denoms []int
Result []int
}
func main() {
scenarios := []Scenario{
Scenario{Value: 100, Denoms: []int{50, 25, 10, 5, 1}, Result: []int{50, 50}},
Scenario{Value: 101, Denoms: []int{50, 25, 10, 5, 1}, Result: []int{50, 50, 1}},
Scenario{Value: ... |
code/greedy_algorithms/src/minimum_coins/minimum_coins.js | /* Part of Cosmos by OpenGenus Foundation */
function minimumCoins(value, denominations) {
var result = [];
// Assuming denominations is sorted in descendig order
for (var i = 0; i < denominations.length; i++) {
var cur_denom = denominations[i];
while (cur_denom <= value) {
result.push(cur_denom);
... |
code/greedy_algorithms/src/minimum_coins/minimum_coins.py | # Part of Cosmos by OpenGenus Foundation
def minimum_coins(value, denominations):
result = []
# Assuming denominations is sorted in descendig order
for cur_denom in denominations:
while cur_denom <= value:
result.append(cur_denom)
value = value - cur_denom
return resul... |
code/greedy_algorithms/src/minimum_coins/minimumcoins.hs | module MinimumCoins where
-- Part of Cosmos by OpenGenus
... |
code/greedy_algorithms/src/minimum_coins/minimumcoins.java | // Part of Cosmos by OpenGenus Foundation
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
public class MinimumCoins {
private static List<Integer> minimumCoins(Integer value, List<Integer> denominations) {
List<Integer> result = new ArrayList<>();
// Assuming list of de... |
code/greedy_algorithms/src/prim_minimum_spanning_tree/README.md | # cosmos
Your personal library of every algorithm and data structure code that you will ever encounter
Collaborative effort by [OpenGenus](https://github.com/opengenus) |
code/greedy_algorithms/src/prim_minimum_spanning_tree/prim_minimum_spanning_tree.c | #include <stdio.h>
#include <limits.h>
int
find_min_edge(int *k, int *l, int n, int c[][1024], int *e)
{
int min = INT_MAX;
int i, j;
for (i = 0; i < n; ++i)
for (j = 0; j < n; ++j)
if (c[i][j] < min) {
min = c[i][j];
*k = i;
*l = j;
}
*e = *e - 1;
return (min);
}
int
find_new_index(int c[]... |
code/greedy_algorithms/src/prim_minimum_spanning_tree/prim_minimum_spanning_tree.cpp | #include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <utility>
// Part of Cosmos by OpenGenus Foundation
using namespace std;
const int MAX = 1e4 + 5;
typedef pair<long long, int> PII;
bool marked[MAX];
vector <PII> adj[MAX];
long long prim(int x)
{
priority_queue<PII, vector<PII>,... |
code/greedy_algorithms/src/prim_minimum_spanning_tree/prim_minimum_spanning_tree.hs | -- Author: Matthew McAlister
-- Title: Prim's Minimum Spanning Tree Algorithm in Haskell
import qualified Data.List as List
type Edge = (Char, Char, Int)
type Graph = [Edge]
-- This is a sample graph that can be used.
-- graph :: Graph
-- graph = [('a','b',4),('a','h',10),('b','a',4),('b','c',8),('b','h',11),('c','b... |
code/greedy_algorithms/src/prim_minimum_spanning_tree/prim_minimum_spanning_tree.py | import sys
from heap import Heap
def primsMSTAlgorithm(adjList):
"""
Prim's Minimum Spanning Tree (MST) Algorithm
It finds a MST of an undirected graph
Args:
adjList: a dictionary, as a realization of an adjacency list, in the form
adjList[vertex1] = [(vertex21,weight1,edgeId1), (vertex22,weight2,edgeI... |
code/greedy_algorithms/src/warshall/warshalls.c | /*
* Compute the transitive closure of a given directed graph
* using Warshall's algorithm.
*/
#include <stdio.h>
#include <math.h>
#define max(a, b) (a > b ? a : b)
void
warshal(int p[10][10], int n)
{
int i, j, k;
for(k = 1; k <= n; k++)
for(i = 1; i <= n; i++)
for(j = 1; j <= n; j++)
p[i][j] = max... |
code/greedy_algorithms/src/water_connection/water_connection_algorithm.cpp | //Part of OpenGenus Cosmos
#include <iostream>
#include <vector>
#include<cstring>
using namespace std;
int houses, pipes;
// this array stores the
// ending vertex of pipe
int rd[1100];
// this array stores the value
// of diameters between two pipes
int wt[1100];
// this array stores the
// starting end of pi... |
code/greedy_algorithms/test/README.md | # cosmos
Your personal library of every algorithm and data structure code that you will ever encounter
|
code/greedy_algorithms/test/kruskal_minimum_spanning_tree/test_kruskal.cpp | #include "../../src/kruskal_minimum_spanning_tree/kruskal.cpp"
#include "../../../data_structures/src/tree/multiway_tree/union_find/union_find_dynamic.cpp"
#include <iostream>
using namespace std;
pair<int, int> edgeFunc(pair<pair<int, int>, int> edge)
{
return edge.first;
}
class HeapCompare
{
public:
bool ... |
code/html/README.md | # HTML (Hyper Text Markup Language)
HTML is the standard markup language for creating web pages.
Current HTML version is HTML5.
Standard Syntax of HTML5 is following:
```html
<!DOCTYPE html>
<html>
<head>
<title> Title for top of address bar </title>
</head>
<body>
<!--HTML Tags and content to display... |
code/html/bootstrap/Readme.MD | Tables are a fundamental part of HTML and CSS is used to format tables nicely. Bootstrap being a CSS framework provides several classes to design HTML tables easily.
Many different types of Bootstrap tables are there. In the 'tables.html' file, few examples are shown.
Learn more about Bootstrap tables in this article... |
code/html/bootstrap/tables.html | <!DOCTYPE html>
<html lang="en">
<head>
<title>bootstrap table</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="https://ajax.googleapis.... |
code/html/css/Hover/src/Hover_effect.html | /* Part of Cosmos by OpenGenus Foundation */
<!DOCTYPE html>
<html>
<head>
<title>HOVER EFFECT</title>
<style>
h1:hover{
color:red;
font-size:50px;
}
</style>
</head>
<body>
<h1>Move the cursor over this text to see t... |
code/html/css/Layout/normalflow.html | <!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Normal Flow</title>
<script>
body {
width: 500px;
margin:15px;
padding:10px;
}
p {
background: green;
border: 2px solid black;
padding: 10px;
margin: 10px;
}
.block{
display: block;
}
.inline{
display... |
code/html/css/Margin/README.md | # CSS Basics: Margins
## Table of contents:
[1. Setting individual side margin](src/Individual.html)
[2. Shorthand property for CSS Margins](src/Shorthand_4.html)
[3. Auto-Keyword](src/Auto_keyword.html)
[4. Margin Inherit](src/Inherit_keyword.html)
[5. Margin Collapse](src/Margin_collapse.html)
CSS Margin prope... |
code/html/css/Margin/src/Auto_keyword.html | <style>
#el
{
width: 250px;
border: 8px double black;
margin: auto;
}
</style>
<h1 id="el"> Generic Heading </h1> |
code/html/css/Margin/src/Individual.html | <style>
#el
{
border: 8px double black;
margin-top: 2%;
margin-right: 300px;
margin-bottom: 0px;
margin-left: 250px;
}
</style>
<h1 id="el"> Generic Heading</h1> |
code/html/css/Margin/src/Inherit_keyword.html | <style>
div
{
border: 8px double black;
margin: 40px;
}
h1
{
border: 4px dotted black;
margin: inherit;
}
</style>
<div>
<h1>
Generic Heading
</h1>
</div> |
code/html/css/Margin/src/Margin.html | <style>
#margin1
{
border: 2px solid black;
text-align:center;
margin: 100px;
}
</style>
<h1 id="margin1"> Generic Heading with defined margin</h1>
<h1> Normal heading </h1> |
code/html/css/Margin/src/Margin_collapse.html | <style>
#upper
{
border: 8px dashed black;
margin-bottom: 80px;
}
#lower
{
border: 12px double yellow;
margin-top: 40px;
}
</style>
<h1 id="upper"> Heading on top element </h1>
<h1 id="lower"> Heading on bottom element </h1> |
code/html/css/Margin/src/Margin_length.html | <style>
#el
{
border: 2px solid black;
margin: 40px 100px 0px 80px;
}
</style>
<h1 id="el"> Generic Heading with margin</h1> |
code/html/css/Margin/src/Margin_value_percentage.html | <style>
#el
{
border: 8px double black;
margin: 2%;
}
</style>
<h1 id="el"> Heading </h1> |
code/html/css/Margin/src/Shorthand_1.html | <style>
#el
{
border: 10px double black;
margin: 200px;
}
</style>
<h1 id="el"> Generic Heading </h1> |
code/html/css/Margin/src/Shorthand_2.html | <style>
#el
{
border: 10px double black;
margin: 10px 100px;
}
</style>
<h1 id="el"> Generic Heading </h1> |
code/html/css/Margin/src/Shorthand_3.html | <style>
#el
{
border: 10px double black;
margin: 10px 400px 0px;
}
</style>
<h1 id="el"> Generic Heading </h1> |
code/html/css/Margin/src/Shorthand_4.html | <style>
#el
{
border: 10px double black;
margin: 10px 100px 0px 400px;
}
</style>
<h1 id="el"> Generic Heading </h1> |
code/html/css/Padding/README.md | # CSS Basics: Padding
## Table of contents
[1. CSS Padding for Individual Sides](src/Individual_sides.html)
[2. Shorthand Property](src/Shorthand_1.html)
[3. Inherit Keyword](src/Inherit.html)
[4. CSS Box Model with Padding](src/BoxModel.html)
CSS Padding property is used to create spacing between content of HTML... |
code/html/css/Padding/src/BoxModel.html | <style>
#box1
{
width: 400px;
padding: 40px;
border: 8px double black;
box-sizing: border-box;
}
#box2
{
width: 400px;
border: 8px double black;
padding: 40px;
}
</style>
<h1 id="box1"> Box with box-sizing defined</h1>
<h1 id="box2"> Generic Box</h1> |
code/html/css/Padding/src/Individual_sides.html | <style>
h1
{
border: 8px double black;
padding-top: 20px;
padding-right: 50px;
padding-bottom: 30px;
padding-left: 100px;
}
</style>
<h1> This is a Heading for checking Padding on Individual sides where top, right, bottom and left padding are 20px, 50px, 30px and 100p... |
code/html/css/Padding/src/Inherit.html | <style>
div
{
border: 8px double black;
padding: 60px;
}
h1
{
border: 2px solid black;
padding: inherit;
}
</style>
<div>
<h1> Generic Heading </h1>
</div> |
code/html/css/Padding/src/Length.html | <style>
h1
{
border: 2px solid black;
padding: 40px;
}
</style>
<h1> Generic Heading with padding of 40px from border. </h1> |
code/html/css/Padding/src/Padding.html | <style>
#el
{
border: 2px solid black;
padding: 40px;
}
</style>
<h1 id="el"> Heading with Padding specified </h1>
<h1 style="border:2px solid black;"> Heading without padding </h1> |
code/html/css/Padding/src/Percentage.html | <style>
h1
{
border: 2px solid black;
padding: 5%;
}
</style>
<h1> Generic Heading </h1> |
code/html/css/Padding/src/Shorthand_1.html | <style>
h1
{
border: 2px solid black;
padding: 40px;
}
</style>
<h1> Generic Heading </h1> |
code/html/css/Padding/src/Shorthand_2.html | <style>
h1
{
border: 2px solid black;
padding: 40px 200px;
}
</style>
<h1> Generic Heading </h1> |
code/html/css/Padding/src/Shorthand_3.html | <style>
h1
{
border: 2px solid black;
padding: 40px 200px 100px;
}
</style>
<h1> Generic Heading </h1> |
code/html/css/Padding/src/Shorthand_4.html | <style>
h1
{
border: 2px solid black;
padding: 40px 200px 100px 500px;
}
</style>
<h1> Generic Heading </h1> |
code/html/css/Padding/src/code.html | <style>
.paragraph{
border:dotted 3px red;
padding: 5%;
}
</style>
<p>Welcome to the code: Without padding</p>
<p class="paragraph">Welcome to the code: With padding</p>
|
code/html/css/Position/README.md | # CSS Position
The CSS **position** property is used to specify the position of HTML element in the webpage.
Once the position property is set to a given value/keyword. The HTML element has a defined location from which it can be shift relatively using the following keywords:
* **top**
* **bottom**
* **left**
* **righ... |
code/html/css/Position/src/Absolute_no_ancestor.html | <style>
h1
{
position: absolute;
top: 100px;
left: 100px;
}
</style>
<h2> Generic Heading </h2>
<h1> Heading with Absolute positioning </h1> |
code/html/css/Position/src/Absoulte_ancestor.html | <style>
div
{
position: relative;
top: 40px;
left: 100px;
}
h1
{
position: absolute;
top: 40px;
left: 50px;
}
</style>
<div>
<h2> Div Generic Element </h2>
<h1> Generic Heading </h1>
</div> |
code/html/css/Position/src/Fixed.html | <style>
img
{
position: fixed;
top: 100px;
left: 100px;
}
</style>
<h1> Generic Heading </h1>
<img src="OpenGenus.jpg" alt="OpenGenus Foundation Logo">
<pre>
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
..... |
code/html/css/Position/src/Position.html | <style>
h1
{
position: absolute;
top: 40px;
left: 100px;
}
</style>
<h1> Generic Heading </h1> |
code/html/css/Position/src/Relative.html | <style>
#head1
{
position: relative;
top: 40px;
bottom: 100px;
right: 30px;
left: 100px;
}
</style>
<h1> Generic Heading </h1>
<h1 id="head1"> Heading with relative positioning </h1> |
code/html/css/Position/src/Static.html | <style>
h1
{
position: static;
top: 100px;
left: 200px;
}
</style>
<h1> Generic Heading </h1> |
code/html/css/README.md | # Cascasding StyleSheets (CSS)
CSS is used to add styling options to webpages written in normal HTML files.
CSS style options are pairs of **property:value**.
There are three ways to add CSS style options in HTML files.
## 1. Inline CSS
Writing CSS style options within HTML tag.
```html
<{HTML_element} style="pro... |
code/html/css/Z_index/README.md | # CSS Position: Z-index property
When HTML elements are positioned explicitly, they may overlap with each other.
The Z-index property is used to specify the **Stack order** of HTML elements.
The higher the value of the HTML element in the stack, the more forward is its position.
HTML elements can have either a positi... |
code/html/css/Z_index/src/inherit.html | <style>
div
{
z-index:-1;
}
img
{
position: absolute;
left: 0px;
top: 0px;
z-index:inherit;
}
h1
{
z-index: 1;
position: absolute;
top: 220px;
}
</style>
<div>
<img src="OpenGenus.jpg" alt="OpenGenus Logo">
</div>
<h1> Inherit Keyword Example for CSS Z... |
code/html/css/Z_index/src/initial.html | <style>
img
{
position: absolute;
left: 0px;
top: 0px;
z-index: -1;
}
h1
{
z-index: 1;
position: absolute;
top: 220px;
}
#b1
{
position:absolute;
top:400px;
}
</style>
<img src="OpenGenus.jpg" alt="OpenGenus Logo" id="img1">
<h1> Generic Heading </... |
code/html/css/Z_index/src/z_index.html | <style>
img
{
position: absolute;
left: 0px;
top: 0px;
z-index: -1;
}
h1
{
z-index: 1;
position: absolute;
top: 220px;
}
</style>
<img src="OpenGenus.jpg" alt="OpenGenus Logo">
<h1> This is overlap Heading over OpenGenus Logo </h1> |
code/html/css/border/README.md | # CSS Basics: Borders
CSS Borders are used to create border around any HTML Tag.
Borders include following feature:
* **Style:** The type of border you want as in solid, dashed etc. It is a compulsory attribute for border.
* **width:** It defines the thickness of the border. It is an optional attribute and has inbuil... |
code/html/css/border/src/Border_color.html | <h1>Defining border color </h1>
<h2>1) Border color with keyword </h2>
<h3 style="border-style:solid;border-color:red;"> Red colored border </h3>
<br><br>
<h2>2) Border color with RGB value </h2>
<h3 style="border-style:solid;border-color:rgb(255,0,0)"> Border with RGB value (255,0,0) ==> Red color </h3>
<br><br>
... |
code/html/css/border/src/Border_style.html | <h1 style="border-style:dotted;text-align:center;"> Dotted Border </h1>
<h1 style="border-style:dashed;text-align:center;"> Dashed Border </h1>
<h1 style="border-style:solid;text-align:center;"> Solid Border </h1>
<h1 style="border-style:double;text-align:center;"> Double Border </h1>
<h1 style="border-style:groove;tex... |
code/html/css/border/src/Border_width.html | <h1> Border width with keywords </h1>
<h2 style="border-style:solid;border-width:thin"> Thin Border </h2>
<h2 style="border-style:solid;border-width:thick"> Thick Border </h2>
<h2 style="border-style:solid;border-width:medium"> Medium Border </h2>
<br>
<br>
<h1> Border width with numerics and units </h1>
<h2 style="bor... |
code/html/css/border/src/Individual_border.html | <style>
#id1
{
border-top-style: solid;
border-top-width: 2px;
border-top-color: black;
border-bottom-style: inset;
border-bottom-width: 8px;
border-bottom-color: red;
border-left-style: outset;
border-left-width: 15px;
border-left-color: green;
border-right-style: dotted... |
code/html/css/border/src/Rounded_Border.html | <style>
#generic
{
border: 8px solid black;
text-align:center;
}
#round1
{
border: 8px solid black;
text-align:center;
border-radius: 4px;
}
#round2
{
border: 8px solid black;
text-align:center;
border-radius: 8px;
}
</style>
<h1 id="generic"> Generic Border </h1>
<h1 id="round1"> Round ... |
code/html/css/border/src/Shorthand_property.html | <style>
#border
{
border: 2px solid black;
}
</style>
<h1 id="border"> Heading </h1>
|
code/languages/Java/2d-array-list-java.java | import java.util.ArrayList;
public class TwoDimensionalArrayLists{
public static void main(String args[]) {
// Creating 2D ArrayList
ArrayList<ArrayList<Integer> > arrLL = new ArrayList<ArrayList<Integer> >();
// Allocating space to 0th row with the help of 'new' keyword
... |
code/languages/Java/2d-array.java | import java.util.Scanner;
public class TwoDimensionalArray{
// Creating a user defined 2-D Array
public static int[][] createarray(){
Scanner s = new Scanner(System.in);
// Taking number of rows and columns in input from user
System.out.println("Enter number of rows");
... |
code/languages/Java/Handlingexceptions/Handlingexp.java | import java.io.*;
public class example
{
public static void main(String[] args)
{
try
{ int n=6;
System.out.print("a");
int val = n / 0;
throw new IOException();
}
catch(EOFException e)
{
System.out.printf("b");
}
catch(ArithmeticException e)
{
System.out.printf("c");
... |
code/languages/Java/Kadane_algo.java | import java.util.Scanner;
class Kadane_Algo{
public static void main (String[] args) {
int[] array = {-2, -3, 4, -1, -2, 1, 5, -3};
int size = array.length;
int maximum_overall = Integer.MIN_VALUE, max_ending_here = 0;
for (int i = 0; i < size; i++) {
max_ending_... |
code/languages/Java/README_Kadane_Algo.md | Kadane's Algorithm is commonly known for **Finding the largest sum of a subarray** in linear time O(N).
A **Subarray** of an n-element array is an array composed from a contiguous block of the original array's elements. For example, if array = [1,2,3] then the subarrays are [1], [2], [3], [1,2], [2,3] and [1,2,3] . S... |
code/languages/Java/README_bubble-sort.md | Bubble sort is an algorithm used to sort an array or a list in a more optimized fashion.
At worst, bubble sort is seen as a 0(n^2) runtime sort algorithm.
Algorithm used:
1) Check and see if the positions next to each other in the array/list are
out of order.
2) If they are, swap them. If not, move on.
3) Do this thro... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.