Merge Sort has several advantages on performance. This technique divides the whole data as like divided and conquer method but until two elements in a group. Then solves the divided parts and conquers them. The resulting efficiency of this method is that the division of problem is much less then the previous method, so the recursive call is also less. As a result we have less comparison and less computational time. Merge sort can be implemented in C to sort the file.
Introduction:
Merging is the process of combining two or more sorted files into a third sorted file. In most implementations it preserves the input order of equal elements in the sorted output. It is an example of the divide and conquer algorithmic paradigm. It is also called Divide and Conquer where we divide the problem into a number of sub-problems and then we conquer the sub-problems by solving them recursively. Merge sort can be implemented in C to sort the file. Divide the file into n subfiles of size 1 and merge adjacent pairs of files. We then have approximately n/2 files of size 2. Repeat this process until there is only one file remaining of size n.
Working Mechanism:
Theoretically, a merge sort works as follows:
If the list is of length 0 or 1, then it is already sorted. Otherwise:
Divide the unsorted list into two sublists of about half the size.
Sort each sub list recursively by re-applying merge sort.
Merge the two sublists back into one sorted list.
To sort A [p…r] Divide by splitting into two subarray A [p…q] and A [q+1…r], where q is the half way point of A[p…r].
Conquer by recursively sorting the two subarrays, A [p…q] and A [q+1…r].
Combine by merging the two sorted subarrays A [p…q] and A [q+1…r] to produce a simple sorted array A [p…r].
Example:
Original file:
5
2
4
7
1
3
2
6
Pass 1:↓↓↓↓
2
5
4
7
1
3
2
6
Pass 2:↓↓
2
4
5
7
1
2
3
6
Pass 3:↓
1
2
2
3
4
5
6
7
Sorted file:
1
2
2
3
4
5
6
7
Pseudocode:
Merge (A, p, q, r)
n1 ← q – p + 1
n2 ← r – q
Create arrays, L[1…n1+1] and R[1…n2+1]
for i ← 1 to n1,
do L[i] ← A[p+i-1]
for j ← 1 to n2,
do R[j] ← A[q+j]
L[n1+1] ← ∞
R[n2+1] ← ∞
i ← 1
j ← 1
for k ← p to r
do if L[i] ≤ R[j]
then A[k] ← L[i]
i ← i+1
else
A[k] ← R[j]
j ← j+1
Note: We constructed two auxiliary arrays namely L and R.
Implementation of the algorithm in C:
/* An example of routine that accepts two sorted arrays a and b of n1 and n2 elements, respectively, and merges them into a third array c containing n3 elements. */
void mergearr(int a[], int b[], int c[], int n1, int n2, int n3)
{
int appoint, bpoint, cpoint;
int alimit, blimit, climit;
Merge sort is more efficient than other sort for some types of lists if the data to be sorted can only be efficiently accessed sequentially, merge sort is a stable sort as long as the merge operation is implemented properly. In sorting n items, merge sort has an average and worst-case performance of(n log n). If the running time of merge sort for a list of length n is T(n), then the recurrence T(n) = 2T(n/2) + n follows from the definition of the algorithm .
In the worst case, merge sort does approximately (n ⌈lg n⌉ - 2⌈lg n⌉ + 1) comparisons, which is between (n lg n - n + 1) and (n lg n + n + O (lg n)). In the worst case, merge sort does about 39% fewer comparisons than quick sort does in the average case; merge sort always makes fewer comparisons than quick sort, except in extremely rare cases, when they tie, where merge sort’s worst case is found simultaneously with quick sort’s best case.
Types of analysis:
Worst case:
T(n)=maximum time of algorithm of any input size of n.
Average case:
T(n)=expected time of algorithms overall inputs of size n.
Need assumptions of statistical distribution of inputs.
Best case:
Cheat with a slowly algorithm that works fast on some input.
Conclusions:
It is always O(nlogn), it is a very good alternative if the extra memory requirement is not a problem. Array elements with fast comparisons and slow copying seem to slightly penalize merge sort.
O(nlgn) grows more slowly than O(n2).
Therefore merge sort asymptotically beats insertion sort in the worst case.
In practice, merge sort beats insertion sort for n>30 or so.
ADT is the basic mathematical concept that defines the data type and stands for Abstract Data Type. Formally, ADT can be defined as a set of data values and the associated operations that are precisely specified, independent of any particular implementation.
Value Definition:
The Value definition defines the collection of values from the ADT and consists of two parts: A definition Clause (compulsory) and A Condition Clause (optional).
Operator Definition:
The operator definition consists of three parts: Header, Precondition and Post Condition.
An example of ADT.
abstract typedef <> STRING;
abstract length (s)
STRING s;
postcondition length = = len(s);
Contrary to popular belief, computers are not clever. Left to itself, a computer doesn’t do anything at all – it won’t show the time, or display what you type on the screen, let alone play a video game. The reason that computers are such useful tools, and give the appearance of cleverness, is that they follow instructions, very accurately, very repetitively, and very quickly. For example, when a computer displays a clock, it does so because it has instructions for how to draw every color and tick mark in the clock face, and every line in the clock’s rotating hands, onto the computer screen.
Programming is the act of giving instructions to a computer so that it knows how to perform an action. Fundamentally, these instructions are a series of numbers – to a computer, everything is numbers – in a kind of code where different numbers represent different instructions. The good news is that programmers don’t have to learn all these numbers (the ‘machine code’), because they can write their instructions in a more intuitive form, and then have the computer convert these instructions into machine code.
The intuitive or human-readable form of instructions is called a computer language. Like languages in the real world, there are dozens of computer languages. Some are for specialized tasks and others are more general-purpose. What all programming languages have in common is that they enable programmers to create instructions for a computer without having to learn the computer’s numeric machine code.
Matthew Applegate, aka Pixelh8, is a leading light of the "chiptune" scene - music made using vintage home computers. Now he is embarking on his most ambitious project to date, holding two concerts consisting of music made on some of the oldest and rarest computers in the world at the UK's National Museum of Computing at Bletchley Park, the second world war code-breaking centre. Sumit Paul-Choudhury talked to him ahead of the performances of his show, called Obsolete?.
I was in an REM covers band in the late 1990s, and the Amiga 500 I used to do our orchestration was fairly limited - it came out sounding like chiptunes. By comparison, modern PCs using samples have always sounded to me like they were trying too hard. They just didn't sound right.
When I realised that you could emulate old machines on a PC and learn what was going on inside them, I went back to the older sounds. I've designed instruments for pop stars. I reprogrammed Game Boys for UK artist Damon Albarn, for example, turning them into real musical instruments.
I grew out of the home computers and started to use scientific machines. With Obsolete? I've gone right back to the beginning of what computers can do in terms of sound. It's not just about sound chips, but the electromechanical sounds they make: the fans, the tape readers, the teleprinters - crunchy sounds.
What kind of music is it?
I usually do my own weird version of pop music in one-off songs, but this is a lot more elaborate. It's a concert work - a complete study of Bletchley Park, its history and its people, and of mathematics and code-breaking.
There are hidden codes and themes of encryption within the music. For example, I created a rhythm on the Colossus [the world's first programmable electronic computer]. The Colossus was used to break wartime codes: the Nazis enciphered Morse code messages by adding a second layer of Morse on top. I think of Morse codes as rhythms, so the piece has multiple rhythms overlaid.
There is also one piece of music where I'm going to put the date of the concert into a hand-wound adding machine and turn the handle. As it turns it will make a rhythm for that particular night. But it's not going to come out as some sort of strict mathematical, avant-garde modern music. It does have all these things in it, but it's still music.
How do you turn primitive computer sounds into music?
I make chiptune music and I do circuit-bending, too. Chiptunes are about reprogramming old computers and using their sound chips to make new music. I've had to learn all the relevant computer languages from the 1970s to 1994. In fact, the best chiptune musicians are programmers.
Circuit-bending is taking an electronic device and short-circuiting it to create completely different outcomes to whatever it would originally have done.
I think the people at Bletchley Park were expecting me to just make pop music using the sounds of the machines, but that would trivialise it. The museum curators initially took a little persuading because some of the machines are worth, say, £4 million, and I have blown up machines in the past. But I promised to be sensible with them. I'm using samples in the performances, because there's no way I could use all the machines - they wouldn't let me move them. But some of them will be live.
Who are your musical inspirations?
I don't actually listen to chiptune music. My inspiration is really people like Marvin Gaye. For this piece, though, I've gone to 20th-century composers such as Schönberg, Bartok and Cage, to see how they explore themes.
What's next?
There are a few individual machines I'd like to work with. One is the Whirlwind from 1951, arguably the first computer to produce sound. I'd also like to do more projects like Obsolete?, but in different areas, such as using machines that have a specific function - in astronomy, say. I got everybody scared when I said I'd like to work on strategic nuclear defence machines.
I got everybody scared when I said I'd like to work on strategic nuclear defence machines
22 Feb 2009 मा FOSS (Free and Open Source Software) Nepal तथा HLCIT (High Level Commission of Information Technology) ले संयुक्त रुपमा Digital Freedom For a Free Society भन्ने नाराका साथ आयोजना गरेको "Workshop on Free and Open Source Software for Media Persons", विषयक एकदिने कार्यक्रम मा मैले एक ब्लगरको हैसियत ले सहभागिता जनाएको थिँए । FOSS Nepal को रेगुलर कार्यक्रम अन्तर्गत उक्त कार्यक्रम, मिडिया मा काम गर्ने व्यक्तिहरुलाई Free and Open Source Software बारे बुझाउन HLCIT को सेमिनारहल सिंहदरबार मा गरिएको थियो ।
विवेक पौडेल ले सञ्चालन गर्नुभएको कार्यक्रमलाई Opening Session, Orientation Session, Technical Session: Demo and Hands-on र Refreshment गरेर ४ वटा भागमा बाँडिएको थियो । ठिक १० बजे भनिएपनि १५-२० मिनेट ढिलो सुरु भएको कार्यक्रम मा अतिथिका रुपमा नेपाली टाइम्सका प्रकाशक-सम्पादक वरिष्ठ पत्रकार कुन्द दिक्षित, वातावरण विज्ञान तथा प्रविधि मन्त्रालयका सहसचिव अर्जुन कार्की, HLCIT का सेक्रेटरी डा. मदन परियार, HLCIT का VC तथा ईन्जिनियर सरोज देवकोटा, HLCIT का आजिवन सदस्य मनोहर भट्टराई आदि हुनुहुन्थ्यो ।
कार्यक्रमको सुरुवात सँगै FOSS Nepal का सुविर प्रधानांगले FOSS बारे जानकारी र यसको उपयोगिता बारे बोल्दै, FOSS र Media का सम्बन्धमा प्रिजेन्टेसन दिनुभएको थियो । उहाँले प्रोप्राइटरी सफ्टवेयर को सट्टा मा कुन कुन फ्रि एन्ड ओपन सोर्स सफ्टवयर प्रयोग गर्न सकिन्छ बताउनुभएको थियो । त्यस्तै FOSS Nepal ले २००७ र २००८ मा Global Software Freedom Day Best Event Award जित्न सफल भएको कुरा पनि स्मरण गराउनुभएको थियो ।
यसै क्रम मा कुन्द दिक्षित ले Democracy in Cyberia बारे प्रिजेन्टेसन दिनुहुँदै, अनलाइन मिडियाको फाइदा र वेफाइदा को बारेमा बोल्नुभएको थियो । नेपालमा करिब १ प्रतिशत जनता इन्टरनेटको पहुँचमा रहेका र त्यसमध्ये ६५ प्रतिशत काठमाडौँ भित्र रहेको तितो यथार्थ प्रस्तुत गर्दै उहाँले प्रविधि मा पहुँच बढाउनु पर्ने कुरा व्यक्त गर्नुभएको थियो । साथै, Corporate Ownership and Control का कारण FOSS तिर लाग्नुपर्ने आज को आवश्यकता रहेको उहाँले बताउनुभएको थियो । अनलाइन मिडिया राज्यको पाचौँ अंग हो भन्दै उहाँले अनलाइन जर्नालिजम तथा सिटिजन जर्नालिजम आजको आवश्यकता रहेको र निकट भविष्यमै अनलाइन मिडिया Main Stream Media हुने कुरा बताउनुभएको थियो ।
वक्ताको बोल्ने क्रममा आउनुभएका HLCIT का मदन परियारले आइटिको प्रयोग सहर भित्र मात्र सिमित रहेको र यसलाई देशव्यापी बनाउन HLCIT ले पहल गरिरहेकेको कुरा व्यक्त गर्नुभएको थियो । साथै, प्रविधि सस्तो र सुलभ भएमात्र सबैको पहुँचमा पुग्ने बताउँदै FOSS एउटा राम्रो अल्टरनेटिभको रुपमा रहेको बताउनुभएको थियो ।
त्यस्तै वातावरण,विज्ञान तथा प्रविधि मन्त्रालयका सहसचिव अर्जुन कार्कीले आफूले FOSS को बारेमा पहिलोपटक सुनेको बताउँदै, FOSS ले गर्ने कार्यक्रमहरुमा आफूहरुजस्तोलाई पनि निरन्तरजसो बोलाइए, सरकारी स्तरबाट नै पनि यसबारे पहल गर्न सजिलो हुने कुरा बताउनुभएको थियो ।
HLCIT VC तथा ईन्जिनियर सरोज देवकोटाले इन्टरनेट प्रयोगकर्ताहरु सहरमा मात्र सिमित भएको बताउँदै, सुचना प्रविधिको विकास का लागि सरकारव्दारा पहल गरिनुपर्ने बताउनुभएको थियो । खानेपानी, बाटोघाटो र सुचना प्रविधि फरक कुरा हुन्, तर यहाँ, खानेपानी, बाटोघाटो छैन के को सुचना प्रविधि भन्ने गरिएको तितो यथार्थ प्रस्तुत गर्नुभयो । यसर्थ पनि सस्तो र सुलभ FOSS तिर बढ्नुपर्ने स्थिति रहेको उहाँले बताउनुभएको थियो । त्यसपछि को क्रममा बोल्दै, मनोहर भट्टराईले सबैलाई धन्यवाद ज्ञापन गर्दै FOSS र Media बारे आफ्ना केहीकुरा राख्नुभएको थियो ।
त्यसपछि को Orientation Session मा दैनिकीडटकम का उपसम्पादक गुणराज लुँइटेल ले आफ्नो अनलाइन जर्नालिजम को अनुभव सुनाउँदै Importance of Digital Media and Experiences of Doing Online Journalism बारे प्रिजेन्टेसन दिनुभएको थियो ।
त्यस्तै पत्रकार केदार शर्माले FOSS Freedom and Media बारे बोल्दै, राजनितिक आन्दोलन जस्तै, FOSS को आन्दोलन मा पनि सबैलाई लाग्न आग्रह गर्नुभएको थियो ।
Digital Media will be the mainstream Media भन्दै कार्यक्रम सञ्चालक विवेक पौडेल ले Showcasing FOSS for Media बारेमा प्रिजेन्टेसन दिनुहँदै Twitter, Facebook आदिजस्ता साइटबाट micro blogging को अवधारणा भित्रिसकेको कुरा बताउनुभएको थियो । त्यसैक्रम मा अंकुर शर्मा व्दारा लिनक्स इन्सटलेसन तथा निर्भिकल्प सफ्टवेयर को प्रयोग बारे डेमो देखाउनुभएको थियो ।
Hobby and Profession: Online Reporting को बारेमा नेपाली भोइसका ब्लगर उज्जल आचार्यले ब्लग र ब्लगिङ बारे जानकारी दिनुभएको थियो भने रिसर्चर विपिन गौतम ले Privacy र Anonymity को बारेमा प्रिजेन्टेसन दिनुभएको थियो । त्यस्तै वसन्तकृष्ण श्रेष्ठले नेपालीयुनिकोड बारे जानकारी दिनुभएको थियो । यसपछि को क्रम मा अंकुर शर्माले फायरफक्सका लागि १० वटा महत्वपुर्ण Add-ons को बारेमा जानकारी दिनुभएको थियो ।
Kathmandu University का विद्यार्थी तथा FOSS Nepal का अभिषेक सिंह ले Wiki and Media: Media wiki को बारेमा प्रिजेन्टेसन दिनुभएको थियो । यसक्रम मा विकी क्रिएट गर्ने, ईडिट गर्ने आदि तरिकाहरु सिकाउनुभएको थियो भने अन्त्यमा जुम्ला नामक सिएमएस इन्सटल गर्ने विधि बताउनुभएको थियो ।
त्यसपछि को क्रममा हेमपाल श्रेष्ठ ले Licensing, Open Content and Copyright issues in Cyberspace बारेमा बोल्नुभएको थियो । त्यसपछि आकाश दिप शाक्य ले कार्यक्रम को समराइज गर्नुभएको थियो । कार्यक्रम को अन्त्यमा सहभागिहरुलाई HLCIT का सेक्रेटरी डा. मदन परियार ले सर्टिफिकेट वितरण गर्नुभएको थियो । कार्यक्रम को समापनमा बोल्दै डा. मदन परियार ले, मिडिया मा काम गर्ने साथिहरुको लागि कार्यक्रम फलदायी भएको आशा व्यक्त गर्दै FOSS Nepal लाई पनि यस्तो कार्यक्रम आयोजना गरेकामा धन्यवाद ज्ञापन गर्नुभएको थियो ।
-- Posted By आकार to Aakar at 2/23/2009 05:45:00 PM
Edward Richardson, 41, was convicted of killing 26-year-old Sarah Richardson in a "frenzied and brutal attack" at her parents' home in Biddulph, Staffordshire, on May 12 last year.
Richardson, of Mayfield Road, Biddulph, was given a minimum term of 18 years in jail by a judge at Stafford Crown Court after a jury found him guilty of murder.
Fiona Cortese, from the Crown Prosecution Service, Staffordshire, said Richardson went to his in-laws' home, where his wife had been living since their separation in April 2008, after she failed to reply to his text messages following her change in status on social networking website Facebook.
She said: "Richardson became enraged when Sarah changed her marital status on Facebook to single and decided to go and see her as she was not responding to his messages.
"He gained entry by breaking the front door window and made his way into the property.
"Once inside he found Sarah in her bedroom and subjected her to a frenzied and brutal attack with a knife and then attempted to take his own life."
Mrs Richardson's parents, Beryl and Alan Boote, said their daughter's death had "devastated" the family.
In a statement released by police following Thursday's verdict, they said: "There simply aren't the words to describe how Sarah's death, and the awful way in which she died, has affected us. We all miss her so much.
"We're devastated and our lives will never be the way they were.
"It is important that we get justice for the taking of Sarah's life and we hope that Richardson will be an old man before he's ever allowed out of prison.
"Sarah was the loveliest daughter anyone could wish for. She was honest, loyal and sweet and everyone loved her.
"She loved all of her family to bits and to us she will always be precious and special."
Detective Inspector Andy Wall, from Staffordshire Police's Major Investigations Department, said: "She had decided that her marriage to Edward Richardson was over but this was clearly something he could not accept.
"The consequence was that Sarah lost her life in a brutal attack at her husband's hands in her family home.
"The verdict cannot bring Sarah back but we hope that it gives her family some form of comfort."
Poem
-
If you can keep your head when all about you
Are losing theirs and blaming it on you,
If you can trust yourself when all men doubt you
But make allowance for...