...and Computer Simulation Clump Sort: A Stable Alternative To Heap Sort For Sorting Medical Data Visvasuresh Victor Govindaswamy Matthew Caudill Jeff Wilson Computer Science Texas A&M University-Texarkana Texarkana, USA lovebat814@yahoo.com Computer Science Texas A&M University-Texarkana Texarkana, USA Computer Science Texas A&M University-Texarkana Texarkana, USA Daniel Brower G. Balasekaran, FACSM Computer Science Texas A&M University-Texarkana Texarkana, USA Medical and Sports Science Nanyang Technology University Singapore Abstract—Sorting data sets are a thoroughly researched field. Several sorting algorithms have been introduced and these include Bubble, Insertion, Selection, Shell, Quick, Merge and Heap. In this paper, we present a novel sorting algorithm, named Clump Sort, to take advantage of ordered segments already present in medical data sets. It succeeds in sorting the medical data considerably better than all the sorts except when using totally non-clumped data. In this test using totally nonclumped data, Heap sort does only slightly better than Clump sort. However, Clump sort has the advantage of being a stable sort as the original order of equal elements is preserved whereas in Heap sort, it is not since it does not guarantee that equal elements will appear in their original order after sorting. As such, Clump Sort will have considerably better data cache performance with both clumped and non-clumped data, outperforming Heap Sort on a modern desktop PC,...
Words: 1753 - Pages: 8
...1. Factorial program in cFactorial program in c: c code to find and print factorial of a number, three methods are given, first one uses for loop, second uses a function to find factorial and third using recursion. Factorial is represented using '!', so five factorial will be written as (5!), n factorial as (n!). Alson! = n*(n-1)*(n-2)*(n-3)...3.2.1 and zero factorial is defined as one i.e. 0! = 1. #include <stdio.h> int main() { int c, n, fact = 1; printf("Enter a number to calculate it's factorial\n"); scanf("%d", &n); for (c = 1; c <= n; c++) fact = fact * c; printf("Factorial of %d = %d\n", n, fact); return 0; } 2. c program to check odd or evenc program to check odd or even: We will determine whether a number is odd or even by using different methods all are provided with a code in c language. As you have study in mathematics that in decimal number system even numbers are divisible by 2 while odd are not so we may use modulus operator(%) which returns remainder, For example 4%3 gives 1 ( remainder when four is divided by three). Even numbers are of the form 2*p and odd are of the form (2*p+1) where p is is an integer. #include<stdio.h> main() { int n; printf("Enter an integer\n"); scanf("%d",&n); if ( n%2 == 0 ) printf("Even\n"); else printf("Odd\n"); return 0; } 3. C program to check whether input alphabet is a vowel or notThis code checks whether an input alphabet is a vowel...
Words: 7510 - Pages: 31
...LIST OF PRACTICALS OF C++ (CLASS XII) 1. WRITE MENU DRIVEN PROGRAM TO SHOW FOLLOWING OPERATIONS IN A 1-D ARRAY (USING USER DEFINED FUNCTION) MENU 1. CREATION OF AN ARRAY 2. SEARCHING ARRAY USING - 3. LINEAR SEARCH METHOD. BINARY SEARCH METHOD. SORTING ARRAY USING - SELECTION SORT - BUBBLE SORT - INSERTION SORT - MERGE SORT 4. INSERTING AN ELEMENT AT iTH POSITION 6. DELETING AN ELEMENT FROM AN ARRAY 7. 2. MERGE TWO ARRAYS OF INTEGERS IN ASCENDING OR DESCENDING ORDER 5. QUIT WRITE MENU DRIVEN PROGRAM TO SHOW FOLLOWING OPERATIONS IN A 2-D ARRAY (USING USER DEFINED FUNCTION) MENU 1. ADDING TWO 2-D ARRAYS 2. SUBSTRACTING TWO 2-D ARRAYS 3. MULTIPLYING TWO 2-D ARRAYS 4. CHECK WHETHER TWO 2-D ARRAYS ARE EQUIVALENT OR NOT 5. DISPLAY UPPER TRIANGULAR MATRIX 6. DISPLAY LOWER TRIANGULAR MATRIX 7. DISPLAY AND FIND SUM OF DIAGONAL ELEMENTS OF A 2-D ARRAY 8. DISPLAY AND FIND THE ROW-WISE SUM OF A 2-D ARRAY 9. DISPLAY AND FIND THE COLUMN-WISE SUM OF A 2-D ARRAY 10. QUIT 3. USING STRUCTURES WRITE A MENU DRIVEN PROGRAM TO ADD, SUBTRACT AND MULTIPLY AND DIVIDE TWO COMPLEX NUMBERS 4. USING STRUCTURES WAP TO CHECK THE VALIDY OF DATE 5. WRITE A PROGRAM TO DEFINE THE CLASS WORKER SHOWN BELOW CLASS WORKER ( PRIVATE : WNAME CHARACTER (20), WNO INTEGER, WGRATE FLOAT, HOURLYWAGERATE FLOAT, TOTWAGE FLOAT, CALCWAGE(HRWG,WGRATE) PUBLIC...
Words: 944 - Pages: 4
...Component 01 - Computing Principles | AS-Level (H046) | A-Level (H446) | 1 The characteristics of contemporary processors, input, output and storage devices | Structure and function of the processor | The Arithmetic and Logic Unit (ALU), Control Unit and registers: Program Counter (PC), Accumulator (ACC), Memory Address Register (MAR), Memory Data Register (MDR), Current Instruction Register (CIR).Buses: data, address and control: How this relates to assembly language programs.The fetch-decode-execute cycle, including its effect on registers.The factors affecting the performance of the CPU, clock speed, number of cores, cache.Von Neumann, Harvard and contemporary processor architecture. | The use of pipelining in a processor to improve efficiency. | Types of processor | The differences between, and uses of, CISC and RISC processors.Multicore and parallel systems. | GPUs and their uses (including those not related to graphics). | Input, output and storage | How different input output and storage devices can be applied as a solution of different problems.The uses of magnetic, flash and optical storage devices.RAM and ROM.Virtual storage. | | 2 Software and software development | Operating systems | The need for, function and purpose of operating systems.Memory management (paging, segmentation and virtual memory).Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle.Scheduling: round robin, first come...
Words: 1302 - Pages: 6
...dronacharya.info, Ashish Gupta Department of Information and technology Dronacharya College of Engineering, Gurgaon-122001, India Email:ashish.16907@ggnindia.dronacharya.info Abstract-Arrays and linked lists are two basic data structures used to store information. We may wish to search, insert or delete records in a database based on a key value. This section examines the performance of these operations on arrays and linked lists. In this research paper we studied about the sorting and types of sorting. This is followed by techniques for implementing dictionaries, structures that allow efficient search, insert, and delete operations. We have also illustrated algorithms that sort data and implement dictionaries for very large files Keywords-insertion sort, quick sort, sort ,binary search tree, skip list. 1. Introduction Arrays and linked lists are two basic data structures used to store information. We may wish to search, insert or delete records in a database based on a key value. This section examines the performance of these operations on arrays and linked lists. 1.1 Arrays Figure 1-1 shows an array, seven elements long, containing numeric values. To search the array sequentially, we may use the algorithm in Figure 1-2. The maximum number of comparisons is 7, and occurs when the key we are searching for is in A[6]. Figure 1-1: An Array int function SequentialSearch(Array A , int Lb, int Ub, int Key ); begin for i= Lbto Ub do ...
Words: 2248 - Pages: 9
...1. Use class Sort.java provided in class, the dual-pivot Quicksort of Java 8 (Arrays.sort), and RadixSort.java provided in class. 2. Do the following for Mergesort, Quicksort, Heapsort and dual-pivot Quicksort: a. Create 100,000 random keys (of type long) and sort them. Repeat this 100 times. b. Compute the average CPU time taken to sort the keys for the four methods. c. Comment on the results and compare them to the average-case complexities discussed in class. As we discussed in the class, all these sorting algorithms I used for testing have the same average-case complexities with O (n log n). But the data I got which shows in the upper diagram illustrate that Quick sort is the most fast sorting method especially when you need to sort a large amount of data. Dual-pivot quicksort is also fast than merge sort and Heap sort. Heap sort can be used when the pending data between 1000-1000, 000, and for Merge sort is the first choice when there are more than 1M data. 3. Do the following for the four sorting methods of #2, and for Radix sort: a. Create 100,000 random strings of length 4 and sort them using the five sorting methods. b. Repeat (a) 10 times Compute the average CPU time taken to sort the keys for the five methods. c. Repeat (a) and (b) with strings of length 6, 8, 10. d. Create a table with the results and compare the times with the average-case and worstcase complexities as studied in class. The length of string is 4: The length of string...
Words: 910 - Pages: 4
...INDUSTRIAL TRAINING FROM TATA CMC, JAMMU ON EMBEDDED SYSTEMS. Submitted in the partial fulfilment of requirement for the award of degree of Bachelor of Engineering In Electronics and Communication Engineering Submitted By Ashish Gupta 258/12 Under the guidance of Ms. Sonika Mahajan IT Guide Department of Electronics & Communication Engineering Mahant Bachittar Singh College of Engineering and Technology, Jammu 2015 CERTIFICATE i DECLARATION I hereby declare that the Seminar Report entitled “EMBEDDED SYSTEMS” is an authentic record of my own work carried out as requirement for the award of degree of B.E. (E&C) of Mahant Bachittar Singh College of Engineering & Technology, Jammu. Date: ................ Ashish Gupta 258/12 Certified that the above statement made by the student is correct to the best of my knowledge and belief. Ms. Sonika Mahajan Ms. Neha Gupta Ms. Shalini Sharma IT Guide ...
Words: 998 - Pages: 4
...INDEX s.no | Name of program | Page no. | Remarks | SORTING PROGRAMS | 1 | program of merge sort | | | 2 | program of quick sort | | | 3 | program of bubble sort | | | 4 | program of insertion sort | | | 5 | program of selection sort | | | SEARCHING PROGRAMS | 6 | program of binary search iterative method | | | 7 | Program of binary search by recursive method | | | MULTIPLICATION PROGRAMS | 8 | program to multiply two matrices using direct method | | | 9 | program to multiply two matrices using recursion | | | 10 | program to multiply two matrices using strassen's method | | | //program of merge sort #include<stdio.h> #include<conio.h> #define MAX 50 void mergeSort(int arr[],int low,int mid,int high); void partition(int arr[],int low,int high); int main() { int merge[MAX],i,n; clrscr(); printf("Enter the total number of elements: "); scanf("%d",&n); printf("Enter the elements which to be sort: "); for(i=0;i<n;i++) { scanf("%d",&merge[i]); } partition(merge,0,n-1); printf("After merge sorting elements are: "); for(i=0;i<n;i++) { printf("%d ",merge[i]); } getch(); } void partition(int arr[],int low,int high) { int mid; if(low<high) { mid=(low+high)/2; partition(arr,low,mid); partition(arr,mid+1,high); mergeSort(arr,low,mid,high); } } void mergeSort(int arr[],int low,int mid,int high) { int i,m,k,l,temp[MAX]; l=low; i=low; m=mid+1; while((l<=mid)&&(m<=high))...
Words: 1948 - Pages: 8
... Quick Sort Implementation Next, recall that our goal is to partition all remaining elements based on whether they are smaller than or greater than the pivot We will find two entries: – One larger than the pivot (staring from the front) – One smaller than the pivot (starting from the back) which are out of order and then correct the ordering – I.e., swap them 1 7.6.5 Quick Sort Implementation Continue doing so until the appropriate entries you find are actually in order The index to the larger entry we found would be the first large entry in the list (as seen from the left) Therefore, we could move this entry into the last entry of the list We can fill this spot with the pivot 2 7.6.5 Quick Sort Quick Sort Example First, we examine the first, middle, and last entries of the full list The span below will indicate which list we are currently sorting 3 7.6.5 Quick Sort Quick Sort Example We select 57 to be our pivot – We move 24 into the first location 4 7.6.5 Quick Sort Quick Sort Example Starting at the 2nd and 2nd-last locations: – we search forward until we find 70 > 57 – we search backward until we find 49 < 57 5 7.6.5 Quick Sort Quick Sort Example We swap 70 and 49, placing them in order with respect to eachother 6 7.6.5 Quick Sort Quick Sort Example We search forward until we find 97 > 57 We search backward until we find 16 < 57 7 7.6.5 Quick Sort Quick Sort Example ...
Words: 1243 - Pages: 5
...Stacks, and Queues 6 Stacks 6 Queues 10 Section 2: Hashing, Heaps and Trees 14 Section 3: Sorting Algorithms 20 Insertion sort 20 Bubble Sort 20 Selection sort 21 Section 4: Searching 22 Array 22 Linked Lists 23 Section 5: Recursion 30 References 33 Executive Summary Phase 1 A list is a collection of items in which the items have a position (Weiss, 2010). A linked list allows data to be input or removed easily because each of the data items in the list is connected to its neighbor by a pointer that can be quickly and easily modified to accommodate new or removed items (CTU M.U.S.E. 2014). The Phase 1 portion of this document will be demonstrating the implementation of Stacks and Queues. Phase 2 Hash tables can be viewed as an array of lists and are used to speed up a search for data by creating a situation that does not require the search to start at the beginning and go through every item. The identifying value is the key and the associated record is the data, thus a hash table is a collection of (key, value) pairs. Phase 3 In order to efficiently use a database, the data must be stored in some sort of order. There are a number of different sorting algorithms; a programmer would choose which one to use depending on the amount and type of data being sorted. Insertion sort, Bubble sort, and Selection sort are described with examples. Phase 4 A binary tree, is a node-based data structure where each node has a comparable key (and...
Words: 3704 - Pages: 15
...A Comparison of Solution Procedures for the Flow Shop Scheduling Problem with Late Work Criterion Jacek Błażewicz *) Erwin Pesch 1) Małgorzata Sterna 2) Frank Werner 3) *) Institute of Computing Science, Poznań University of Technology Piotrowo 3A, 60-965 Poznań, Poland phone: +48 (61) 8790 790 fax: +48 (61) 8771 525 blazewic@sol.put.poznan.pl Institute of Information Systems, FB 5 - Faculty of Economics, University of Siegen Hölderlinstrasse 3, 57068 Siegen, Germany pesch@fb5.uni-siegen.de Institute of Computing Science, Poznań University of Technology Piotrowo 3A, 60-965 Poznań, Poland Malgorzata.Sterna@cs.put.poznan.pl Faculty of Mathematics, Otto-von-Guericke-University PSF 4120, 39016 Magdeburg, Germany Frank.Werner@mathematik.uni-magdeburg.de 1) 2) 3) 1 A Comparison of Solution Procedures for the Flow Shop Scheduling Problem with Late Work Criterion Abstract In this paper, we analyze different solution procedures for the two-machine flow shop scheduling problem with a common due date and the weighted late work criterion, i.e. for problem F2 | dj = d | Yw, which is known to be binary NP-hard. In computational experiments, we compare the practical efficiency of a dynamic programming approach, an enumerative method and a heuristic list scheduling procedure. Test results show that each solution method has its advantages and none of them can be rejected from the consideration a priori. Keywords: flow shop, late work, dynamic programming, enumerative...
Words: 9053 - Pages: 37
...CHAPTER 5 – ARRAYS CASE STUDY SCENARIO Sorting Data A dozen umbrellas lie on the ground just inside the classroom door when Dr. Taylor begins his lecture. “A cold, rainy day like today makes me want to stay in and order pizza for delivery rather than go out myself.” Handing a phone book to a student in the front row, Dr. Taylor says “Gail, please look up the phone number for Domino’s Pizza on Main Street, and if you don’t mind, I will time how long it takes you to find the number.” Gail flips through a few pages while Dr. Taylor looks at his watch. “Here it is . . . 555-8275,” she says. “Seven seconds. Thank you Gail.” Dr. Taylor presses some keys on his cell phone while continuing his conversation. “Now please look up the name of the person with the phone number 555-5982, and again I will time you.” Dr. Taylor’s focus returns to his watch even as he speaks into the phone. Gail slowly flips a couple of pages, then stops just about the same time Dr. Taylor ends his call. “I assure you the number is in there, Gail. We will wait while you look it up.” “You will probably wait a long time,” she says, “because there is no fast way to find a number.” “Why not? It’s the same data.” “But the phone book is sorted by names, so finding a name is easy. Finding a number is very difficult because a phone book is not sorted by numbers.” Dr. Taylor takes the phone book from Gail. “Exactly! The sorting process does not change the data, but it organizes the data in a context...
Words: 5653 - Pages: 23
...solving the sorting problem? Reasonable people may disagree on the answer. Selection Sort or Bubble Sort Brute-Force Sorting Algorithm Selection Sort : Scan the array to find its smallest element and swap it with the first element. Then, starting with the second element, scan the elements to the right of it to find the smallest among them and swap it with the second elements. Generally, on pass i (0 i n-2), find the smallest element in A[i..n-1] and swap it with A[i]: A[0] . . . A[i-1] | A[i], . . . , A[min], . . ., A[n-1] in their final positions Example: 7 3 2 5 Selection Sort : Example 1 ) |89 45 68 90 29 34 17 2 ) 17 | 45 68 90 29 34 89 3 ) 17 29 | 68 90 45 34 89 4 ) 17 29 34 | 90 45 68 89 5 ) 17 29 34 45 | 90 68 89 6 ) 17 29 34 45 68 | 90 89 7 ) 17 29 34 45 68 89 | 90 Analysis of Selection Sort Time efficiency: Space efficiency: Stability: Θ(n^2) Θ(1), so in place yes Bubble Sort Compare adjacent elements of the list and exchange them if they are out of order. By doing this repeatedly, we end up “bubbling up” the largest element to the last position The next pass bubbles up the second largest element and so on. After n-1 pass the list is sorted. A0,….,Aj ↔ Aj+1,…, An-i-1, | An-i ≤ … ≤ An in their final positions Example : 89 45 68 90 29 34 17 Bubble Sort : The Algorithm Algorithm : BubbleSort(A[0..n-1]) //Sort given array...
Words: 1552 - Pages: 7
...4. insert sort #include<stdio.h> #include<string.h> void insert(); main(){ char s[70]; printf("enter a string :"); gets(s); insert(strlen(s),s); printf("tre string after sorted : %s\n ",s); } void insert(int count,char *item){ char temp; int a,b; for (a=1;a<count;++a){ temp=item[a]; b=a-1; while(b>=0 && temp<item[b]){ item[b+1]=item[b]; b--; } item[b+1]=temp; } } ****************************************************************************** 5. bubble sort #include <stdio.h> #include<string.h> void bubble(); main(){ char s[70]; printf("enter a string :"); gets(s); bubble(strlen(s),s); printf("the string after sorted : %s\n",s); } void bubble(int num,char *str){ char temp; int a,b; for (a=1;a<num;++a) for(b=num-1;b>=a;--b){ if (str[b-1]>str[b]){ temp=str[b-1]; str[b-1]=str[b]; str[b]=temp; } } } ****************************************************************************** 6. select sort #include<stdio.h> #include<string.h> void select(); main(){ char s[70]; printf("enter a string :"); gets(s); select(strlen(s),s); printf("tre string after sorted : %s\n ",s); } void select(int count,char *item){ char temp; int a,b,c; for (a=0;a<=count-1;++a){ c=a; temp=item[a]; for (b=a+1;b<count;++b){ if (item[b]<temp){ c=b; temp=item[b]; } } item[c]=item[a]; item[a]=temp; }...
Words: 251 - Pages: 2
...UCCC2063 Analysis Algorithm Assignment Lecturer / Tutor : Mr. Wong Chee Siang Course: CS Name | ID | Cheng Shong Wei | 1103771 | Er Siang Chiang | 1203122 | Ng Yuan Wen | 1201733 | Question 1 : Fibonacci a. Iterative Fibonacci 1. Code: #include <iostream> #include <time.h> using namespace std; int main() { //loop until 80th Fibonacci long long count =10; while (count<=10000000000) { //variables time_t start,end; unsigned long long a = 1, b = 1; //prompt start = clock(); //start timer for(unsigned long long n = 3; n <= count; ++n) //calculated by iterative { unsigned long long fib = a + b; a = b; b = fib; if (n==count) cout<<"Fibonacci Number: "<<fib<<endl; } //end timer show Runtime end=clock(); double diff ((double)(end - start)); double time = diff / CLOCKS_PER_SEC; cout<<"Runtime ("<< count <<"th) : "<< time <<" seconds"<<endl; cout<<"------------------------------------------------------"<<endl; count = count *10; } system ("pause"); return 0; } 2. Analysis: n=3count1=count-3+1 T(n) =count-2 =O(count) =O(n) 3. Table n-th Fibonacci no. | Time 1(sec) | Time 2(sec) | Time 3(sec) | Average(sec) | 10 | 0.001 | 0.001 | 0.001 | 0.001 | 100 | 0.001 | 0.001 | 0.001 | 0.001 | 1’000 | 0.002 | 0.001 | 0.001 | 0.0013 | 10’000 | 0.003 | 0.002 | 0.001 | 0.0020 | 100’000 |...
Words: 4123 - Pages: 17