Skip to content

Instantly share code, notes, and snippets.

View huzaifaarain's full-sized avatar
🌎
[email protected]://~ workspace

Muhammad Huzaifa huzaifaarain

🌎
[email protected]://~ workspace
View GitHub Profile
@huzaifaarain
huzaifaarain / rod_cutting.md
Created October 15, 2019 22:14
Rod Cutting
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;

void cout_arr(int a[],int n){
    for(int i=0;i<n;i++){
        cout<<a[i]<<" ";
        if(i==n-1){
            cout<<endl;
@huzaifaarain
huzaifaarain / Rod Cutting Part 2.md
Last active June 24, 2023 11:11
Rod Cutting Using Dynamic Programming Part 2

Rod Cutting Using Dynamic Programming Part 2

Serling Enterprises buys long steel rods and cuts them into shorter rods, which it then sells. Each cut is free. The management of Serling Enterprises wants to know the best way to cut up the rods.

Part 1

Rod Cutting Using Dynamic Programming Part 1

We will now discuss how to convert CUT-ROD into an efficient algorithm, using dynamic programming.

The dynamic-programming method works as follows. Having observed that a naive recursive solution ( we discussed in part 1) is inefficient because it solves the same subproblems repeatedly, we arrange for each subproblem to be solved only once, saving its solution. If we need to refer to this subproblem’s solution again later, we can just look it up, rather than recompute it.

@huzaifaarain
huzaifaarain / Docker-LAMP.md
Last active February 20, 2023 10:59
Minimal Docker Setup for PHP, MySQL & PhpMyAdmin

Minimal Docker Setup PHP, MySQL & phpmyadmin

Install docker

sudo apt install docker docker-compose

Navigate to your desire directory and Clone the repository

@huzaifaarain
huzaifaarain / Chomsky Normal Form (CNF).md
Created October 23, 2019 10:13
Chomsky Normal Form (CNF) Definition 1

Chomsky Normal Form

We introduce Chomsky Normal Form, which is used to answer questions about context-free languages.

Chomsky Normal Form

Chomsky Normal Form. A grammar where every production is either of the form A → BC or A → c (where A, B, C are arbitrary variables and c an arbitrary symbol). Example:

S → AS | a
A → SA | b
@huzaifaarain
huzaifaarain / Chomsky Normal Form (CNF) 2.md
Created October 23, 2019 10:57
Chomsky Normal Form (CNF) Definition 2

CSE 322 - Introduction to Formal Methods in Computer Science

Chomsky Normal Form

Dave Bacon
Department of Computer Science & Engineering, University of Washington

A useful form for dealing with context free grammars is the Chomksy normal form. This is a particular form of writing a CFG which is useful for understanding CFGs and for proving things about them. It also makes the parse

@huzaifaarain
huzaifaarain / main.cpp
Last active October 28, 2019 20:15
THIS GIST IS IN DEVELOPMENT MODE, FORK AT YOUR OWN RISK
#include <bits/stdc++.h>
using namespace std;
class Matrix
{
private:
string name;
int rows;
int columns;
int **data;
@huzaifaarain
huzaifaarain / problem_1.cpp
Last active November 3, 2019 20:32
DAA Homework 2 Section C
#include <bits/stdc++.h>
using namespace std;
/**
* Reference Links
* https://www.geeksforgeeks.org/tiling-problem/
**/
long long int MattingTheFloor(int n,long long int dp[]){
if(dp[n] > -1){
return dp[n];
}
name: Problem 1
source code: |-
input: '00#111#000000'
blank: ' '
start state: s1
table:
s1:
0: {R: s2}
'#': {R: s5}
s2:
@huzaifaarain
huzaifaarain / PSR-1.md
Created October 13, 2020 07:51
PHP-FIG PSR Guideline

Basic Coding Standard

This section of the standard comprises what should be considered the standard coding elements that are required to ensure a high level of technical interoperability between shared PHP code.

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119].