C Merge Sort
int merge(int arr[],int l,int m,int h)
{
int arr1[10],arr2[10]; // Two temporary arrays to
hold the two arrays to be merged
int n1,n2,i,j,k;
n1=m-l+1;
n2=h-m;
for(i=0; i<n1; i++)
arr1[i]=arr[l+i];
for(j=0; j<n2; j++)
arr2[j]=arr[m+j+1];
arr...
One of the more useful things about const correctness is that it serves as a way of documenting code, providing certain guarantees to the programmer and other users. These guarantees are enforced by the compiler due to constness, with a lack of constness in turn indicating that code doesn't provide...
In a simple case statement, one value or variable is checked against multiple possible answers. The code below is an example of a simple case statement:
SELECT CASE DATEPART(WEEKDAY, GETDATE())
WHEN 1 THEN 'Sunday'
WHEN 2 THEN 'Monday'
WHEN 3 THEN 'Tuesday'
WHEN 4 THEN 'Wednes...
to_upper():
#include <iostream>
#include <string>
#include <boost/algorithm/string.hpp>
using namespace std;
int main()
{
// String to convert characters to uppercase
string str = "ThIS iS SUpPoSEd tO Be UpPeR CAsE.";
// Convert characters i...
// Create the request.
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com"]];
// Specify that it will be a POST request
request.HTTPMethod = @"POST";
// Setting a timeout
request.timeoutInterval = 20.0;
//...
Note
I assume you know
Webcomponent Specifications
Polymer from Google
What if, we could just have one custom element, say
<tool-bar></tool-bar>
and it magically did everything that messy Modal markup could?
Tempting eh!
How do you specify which Modal belongs to which project...
So far, we defined how easy it is to write a custom element that hides the messy html behind it and gives the user, an easy to write and brief markup.
Time to code it!
Our custom element, to display the bar below the hero image should
Accept a Link to be shared
Accept a Link to the Repo to be ...
On whichever page you want to display your product / project portfolio, invoke the custom element like so:
<article id="project-neighbourhood">
<div class="row">
<div class="col-12 hero">
<img src="path-to-hero-image...
Bubble sort is also known as Sinking Sort. It is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order.
Bubble sort example
Implementation of Bubble Sort
I used C# language to implement ...
;;Recursively print the elements of a list
(defun print-list (elements)
(cond
((null elements) '()) ;; Base case: There are no elements that have yet to be printed. Don't do anything and return a null list.
(t
;; Recursive case
;; Print the next elem...
Find div with id="article" and strip out all the inner script tags.
#!/usr/bin/env stack
-- stack --resolver lts-7.1 --install-ghc runghc --package text --package lens --package taggy-lens --package string-class --package classy-prelude
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE O...
01 a PIC 9.
01 b PIC 99.
01 c PIC 999.
01 s PIC X(4).
01 record-group.
05 field-a PIC 9.
05 field-b PIC 99.
05 field-c PIC 999.
01 display-record.
05 field-a PIC Z.
05 field-b PIC ZZ.
05 field-c PIC $Z9.
*> numeric fields are moved left to right
*> a set to...
MULTIPLY 5 BY a
MULTIPLY a BY b
ON SIZE ERROR
PERFORM error-handling
NOT ON SIZE ERROR
PERFORM who-does-that
END-MULTIPLY
MULTIPLY a BY b GIVING x ROUNDED MODE IS PROHIBITED
y ROUNDED MODE IS NEAREST-EVEN
z ROUNDED
...
Any method in Rails model can return boolean value.
simple method-
##this method return ActiveRecord::Relation
def check_if_user_profile_is_complete
User.includes( :profile_pictures,:address,:contact_detail).where("user.id = ?",self)
end
Again simple method returning bool...
Note: at is not installed by default on most of modern distributions.
To execute a job once at some other time than now, in this example 5pm, you can use
echo "somecommand &" | at 5pm
If you want to catch the output, you can do that in the usual way:
echo "somecommand > o...
public class InsertionSort
{
public static void SortInsertion(int[] input, int n)
{
for (int i = 0; i < n; i++)
{
int x = input[i];
int j = i - 1;
while (j >= 0 && input[j] > x)
{
input...