Sponsored Content
Top Forums Programming The World's Most Advanced Lexicon-Data-Structure Post 302512818 by DGPickett on Monday 11th of April 2011 04:44:23 PM
Old 04-11-2011
Some of the early NAT language packages for C used compression exploiting the null terminated string, finding short strings that were suffixes of other strings, so "1234" might be stored but "234", "34", "4" and "" were just offset pointers into "1234". While not that great for compressing long strings, it was great for sets with many short strings.

I was working on high performance container since a while back, and came up with a byte-tree, where the first byte was a lookup into an array of pointers, or similar structure, to quickly travers an invariant tree one byte of key at a time. Various alternate nodes dealt with compression, like a 'next-n-bytes-must-be' to swallow invariant areas in a key, or a truncated array of less than 256 cells, with a base and size, or a dumb list lookup leveraging strchr(), a string of random key letters, and a like-length array of pointers, or a N-copies-of for duplicates. The advantages: quick insert, sorted access, no rebalancing, quick access. Linear hash is cute, but if you are not sure of the data's key distribution, it is dicey to go all the way to one key per bucket, so how much linear search do you want?
 

8 More Discussions You Might Find Interesting

1. Programming

what data structure for polinomial

Hello, guys Anyone had experiences to express polynomial using c language. I want to output the polynomial formula after I solve the question. Not to count the value of a polynomial. That means I have to output the polynomial formula to screen. such as: f :=... (0 Replies)
Discussion started by: xli3
0 Replies

2. News, Links, Events and Announcements

Mac OS X - Tiger - Meet the world’s most advanced operating system.

Tiger Unleased Advanced UNIX-Based Technology (0 Replies)
Discussion started by: Neo
0 Replies

3. Filesystems, Disks and Memory

inode data structure

the superblock has the offset for inode table. My question is 1) whether it starts relative to the start of the first cylinder group or is it relative to the start of filesystem??? 2)and also which entry corresponds to the root(/) inode?? is it second or third entry??? My questions are... (4 Replies)
Discussion started by: anwerreyaz
4 Replies

4. Shell Programming and Scripting

tree structure of the data

Hello, I have a file of the following information ( first field parent item, second field child item) PM01 PM02 PM01 PM1A PM02 PM03 PM03 PM04 PM03 PM05 PM03 PM06 PM05 PM10 PM1A PM2A PM2A PM3B PM2A PM3C The output should be like this : PM01 PM02 PM03 PM04 ... (2 Replies)
Discussion started by: ThobiasVakayil
2 Replies

5. Programming

Conpressed, Direct Child Info, Word Tracking, Lexicon Data Structure, ADTDAWG?

Hello, Back in late August 2009, I decided to start working on a modification of the traditional Directed Acyclic Word Graph data structure. End Of Word Nodes did not match up with single words, and Child Information had to be discovered through list scrolling. These were a heavy price to... (0 Replies)
Discussion started by: HeavyJ
0 Replies

6. Shell Programming and Scripting

perl data structure

Hi All, I want to create a data structure like this $VAR1 = { 'testsuite' => { 'DHCP' => { 'failures' => '0', 'errors' => '0', 'time' =>... (3 Replies)
Discussion started by: Damon_Qu
3 Replies

7. Shell Programming and Scripting

Do you recognize this data structure?

I am working with an undocumented feature of a software product (BladeLogic). It is returning the below string in response to a query. It is enclosed with square brackets, "records" are separated with commas and "fields" separated with semicolons. My thought was that this might be some basic... (1 Reply)
Discussion started by: dshcs
1 Replies

8. Shell Programming and Scripting

Help with reformat data structure

Input file: bv|111259484|pir||T49736_real_data bv|159484|pir||T9736_data_figure bv|113584|prf|T4736|truth bv|113584|pir||T4736_truth Desired output: bv|111259484|pir|T49736|real_data bv|159484|pir|T9736|data_figure bv|113584|prf|T4736|truth bv|113584|pir|T4736|truth Once the... (8 Replies)
Discussion started by: perl_beginner
8 Replies
bsearch(3C)															       bsearch(3C)

NAME
bsearch() - binary search a sorted table SYNOPSIS
DESCRIPTION
is a binary search routine generalized from Knuth (6.2.1) Algorithm B. It returns a pointer into a table indicating where a datum may be found. The table must be previously sorted in increasing order according to a provided comparison function. key points to a datum instance to be sought in the table. base points to the element at the base of the table. nel is the number of elements in the table. size is the size of each element in the table. compar is the name of the comparison function, which is called with two arguments that point to the elements being compared. The function must return an integer less than, equal to, or greater than zero indicating that the first argument (the key) is to be considered less than, equal to, or greater than the second argument (the array element). NOTES
The pointers to the key and the element at the base of the table should be of type pointer-to-element, and cast to type pointer-to-void. The comparison function need not compare every byte, so arbitrary data can be contained in the elements in addition to the values being compared. Although declared as type pointer-to-void, the value returned should be cast into type pointer-to-element. RETURN VALUE
A NULL pointer is returned if the key cannot be found in the table. EXAMPLES
The example below searches a table containing pointers to nodes consisting of a string and its length. The table is ordered alphabetically on the string in the node pointed to by each entry. This code fragment reads in strings and either finds the corresponding node and prints out the string and its length, or prints an error message. #include <stdio.h> #include <stdlib.h> #include <string.h> #define TABSIZE 1000 struct node { /* these are stored in the table */ char *string; int length; }; struct node table[TABSIZE]; /* table to be searched */ . . . { struct node *node_ptr, node; /* routine to compare 2 nodes */ int node_compare(const void *, const void *); char str_space[20]; /* space to read string into */ . . . node.string = str_space; while (scanf("%s", node.string) != EOF) { node_ptr = (struct node *)bsearch((void *)(&node), (void *)table, TABSIZE, sizeof(struct node), node_compare); if (node_ptr != NULL) { (void)printf("string = %20s, length = %d ", node_ptr->string, node_ptr->length); } else { (void)printf("not found: %s ", node.string); } } } /* This routine compares two nodes based on an alphabetical ordering of the string field. */ int node_compare(const void *node1, const void *node2) struct node *node1, *node2; { return strcoll(((const struct node *)node1)->string, ((const struct node *)node2)->string); } WARNINGS
If the table being searched contains two or more entries that match the selection criteria, a random entry is returned by as determined by the search algorithm. SEE ALSO
hsearch(3C), lsearch(3C), qsort(3C), tsearch(3C), thread_safety(5). STANDARDS CONFORMANCE
bsearch(3C)
All times are GMT -4. The time now is 12:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy