Sponsored Content
Top Forums Programming Suitable data structure large number of heterogeneous records Post 302506252 by shamrock on Saturday 19th of March 2011 02:43:56 PM
Old 03-19-2011
Mergesort is preferred for sorting linked lists and if it performs badly it wont get better by switching to quicksort or heapsort...thogh you may want to try them out before picking the best one. Are you using recursion for implementing mergesort?
This User Gave Thanks to shamrock For This Post:
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract data from large file 80+ million records

Hello, I have got one file with more than 120+ million records(35 GB in size). I have to extract some relevant data from file based on some parameter and generate other output file. What will be the besat and fastest way to extract the ne file. sample file format :--... (2 Replies)
Discussion started by: learner16s
2 Replies

2. Shell Programming and Scripting

How to Pick Random records from a large file

Hi, I have a huge file say with 2000000 records. The file has 42 fields. I would like to pick randomly 1000 records from this huge file. Can anyone help me how to do this? (1 Reply)
Discussion started by: ajithshankar@ho
1 Replies

3. Shell Programming and Scripting

Find line number of bad data in large file

Hi Forum. I was trying to search the following scenario on the forum but was not able to. Let's say that I have a very large file that has some bad data in it (for ex: 0.0015 in the 12th column) and I would like to find the line number and remove that particular line. What's the easiest... (3 Replies)
Discussion started by: pchang
3 Replies

4. Shell Programming and Scripting

awk - splitting 1 large file into multiple based on same key records

Hello gurus, I am new to "awk" and trying to break a large file having 4 million records into several output files each having half million but at the same time I want to keep the similar key records in the same output file, not to exist accross the files. e.g. my data is like: Row_Num,... (6 Replies)
Discussion started by: kam66
6 Replies

5. Shell Programming and Scripting

AWK print number of records, divide this number

I would like to print the number of records of 2 files, and divide the two numbers awk '{print NR}' file1 > output1 awk '{print NR}' file2 > output2 paste output1 output2 > output awl '{print $1/$2}' output > output_2 is there a faster way? (8 Replies)
Discussion started by: programmerc
8 Replies

6. Shell Programming and Scripting

Compare two files with different number of records and output only the Extra records from file1

Hi Freinds , I have 2 files . File 1 |nag|HYd|1|Che |esw|Gun|2|hyd |pra|bhe|3|hyd |omu|hei|4|bnsj |uer|oeri|5|uery File 2 |nag|HYd|1|Che |esw|Gun|2|hyd |uer|oi|3|uery output : (9 Replies)
Discussion started by: i150371485
9 Replies

7. Shell Programming and Scripting

Split a large file in n records and skip a particular record

Hello All, I have a large file, more than 50,000 lines, and I want to split it in even 5000 records. Which I can do using sed '1d;$d;' <filename> | awk 'NR%5000==1{x="F"++i;}{print > x}'Now I need to add one more condition that is not to break the file at 5000th record if the 5000th record... (20 Replies)
Discussion started by: ibmtech
20 Replies

8. Shell Programming and Scripting

Quick way to select many records from a large file

I have a file, named records.txt, containing large number of records, around 0.5 million records in format below: 28433005 1 1 3 2 2 2 2 2 2 2 2 2 2 2 28433004 0 2 3 2 2 2 2 2 2 1 2 2 2 2 ... Another file is a key file, named key.txt, which is the list of some numbers in the first column of... (5 Replies)
Discussion started by: zenongz
5 Replies
QSORT(3)						   BSD Library Functions Manual 						  QSORT(3)

NAME
heapsort, mergesort -- sort functions LIBRARY
Utility functions from BSD systems (libbsd, -lbsd) SYNOPSIS
#include <bsd/stdlib.h> int heapsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); int mergesort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); DESCRIPTION
The heapsort() function is a modified selection sort. The mergesort() function is a modified merge sort with exponential search intended for sorting data with pre-existing order. The heapsort() function sorts an array of nmemb objects, the initial member of which is pointed to by base. The size of each object is spec- ified by size. The mergesort() function behaves similarly, but requires that size be greater than ``sizeof(void *) / 2''. The contents of the array base are sorted in ascending order according to a comparison function pointed to by compar, which requires two arguments pointing to the objects being compared. The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respec- tively less than, equal to, or greater than the second. The algorithm implemented by heapsort() is not stable, that is, if two members compare as equal, their order in the sorted array is unde- fined. The mergesort() algorithm is stable. The heapsort() function is an implementation of J.W.J. William's ``heapsort'' algorithm, a variant of selection sorting; in particular, see D.E. Knuth's Algorithm H. Heapsort takes O N lg N worst-case time. Its only advantage over qsort() is that it uses almost no additional memory; while qsort() does not allocate memory, it is implemented using recursion. The function mergesort() requires additional memory of size nmemb * size bytes; it should be used only when space is not at a premium. The mergesort() function is optimized for data with pre-existing order; its worst case time is O N lg N; its best case is O N. Normally, qsort() is faster than mergesort() is faster than heapsort(). Memory availability and pre-existing order in the data can make this untrue. RETURN VALUES
The heapsort() and mergesort() functions return the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. ERRORS
The heapsort() and mergesort() functions succeed unless: [EINVAL] The size argument is zero, or, the size argument to mergesort() is less than ``sizeof(void *) / 2''. [ENOMEM] The heapsort() or mergesort() functions were unable to allocate memory. SEE ALSO
sort(1), radixsort(3) Williams, J.W.J, "Heapsort", Communications of the ACM, 7:1, pp. 347-348, 1964. Knuth, D.E., "Sorting and Searching", The Art of Computer Programming, Vol. 3, pp. 114-123, 145-149, 1968. McIlroy, P.M., "Optimistic Sorting and Information Theoretic Complexity", Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, January 1992. Bentley, J.L. and McIlroy, M.D., "Engineering a Sort Function", Software--Practice and Experience, Vol. 23(11), pp. 1249-1265, November 1993. BSD
September 30, 2003 BSD
All times are GMT -4. The time now is 05:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy