Mergesort Algorithm in C

Start from two sorted runs of length 1, merge into a single run of twice the length. Repeat until a single sorted run is left. Mergesort needs N/2 extra buffer. Performance is second place on average, with quite good speed on nearly sorted array. Mergesort is stable in that two elements that are equally ranked in the array will not have their relative positions flipped.

#include <stdlib.h>
#include <stdio.h>


#define uint32 unsigned int

Quicksort Algorithm in C

Partition array into two segments. The first segment all elements are less than or equal to the pivot value. The second segment all elements are greater or equal to the pivot value. Sort the two segments recursively. Quicksort is fastest on average, but sometimes unbalanced partitions can lead to very slow sorting.
 
#include <stdlib.h>
#include <stdio.h>
 
#define INSERTION_SORT_BOUND 16 /* boundary point to use insertion sort */
 
#define uint32 unsigned int

Insertion Sort Algorithm in C

Scan successive elements for out of order item, then insert the item in the proper place. Sort small array fast, big array very slowly.

#include <stdlib.h>
#include <stdio.h>
 
 
#define uint32 unsigned int

Selection Sort Algorithm in C

Find the largest element in the array, and put it in the proper place. Repeat until array is sorted. This is also slow.

#include <stdlib.h>
#include <stdio.h>
 
 
#define uint32 unsigned int

Bubble Sort Algorithm in C

Exchange two adjacent elements if they are out of order. Repeat until array is sorted. This is a slow algorithm.

#include <stdlib.h>
#include <stdio.h>


#define uint32 unsigned int

Double Linked List in php

Below is a non circular double linked list php implementation. I do not frequently encounter linked-list coding in practice, but doing it just for the fun of it feels nice; also helps to brush up on those data structure theories.

Main Code:

Linked List in PHP How to

Data structures are one of the core elements of computer science and they are also fun to program. But being a web developer the opportunity for implementing them in any application is quite rare. But then I thought, What the heck! I can just code for the joy of it, and it will also help me brush up on my DS skills. So here it is, a single linked list implementation in PHP for whoever may care. I will be posting other data structure and algorithm implementations here, so keeping watching. The code is given below.

CODE:

Linked list and Double linked list in C#

Below are two examples of implementing a linked and double linked list in .NET. The framework already has a LinkedList implementation from version 2.0 - it is infact a double linked list and supports a whole lot of features the example below doesn't. I wrote the code below out of curiosity more than anything (some programmers like doing this kind of thing, some don't!). Most degree students or earlier will have learnt about linked lists in their courses, some may have not.

Implements the LinkedList data structure

Here is the sample Code:

using System;

class Node {
  internal Object data;
  internal Node next;

  public Node(Object o, Node n){
    data = o;
    next = n;
  }
}
public class LinkedList {

Linked List on C Sharp

What we going to make is a linked list. Yeah I know there is a class which does the same as a linked list called ArrayList, but we (as a diehard C# programmer) want absolute control and knowledge of what we use.

First what is a linked list?

A linked list is a dynamically sized array. An array has a size and you have to deal with it you cant just resize an array. Unlike an array a linked list has no absolute size. It can hold as many variables as you want it to.