S-14 - 0 1 void SortCandidates(void int i Sort the letters by frequency for(i = 0 i< ALPHABET i achByFrequency[i = i qsort(achByFrequency

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* If the pivot letter isn't present, defer this word until later */ *ppwStart = *--ppwEnd; *ppwEnd = pw; continue; } /* If we get here, this means the word fits. */ apwSol[cpwLast++] = pw; if (cchPhraseLength -= pw->cchLength) { /* recurse */ Debug(DumpWords();) /* The recursive call scrambles the tail, so we have to be * pessimistic. */ ppwEnd = &apwCand[0]; ppwEnd += cpwCand; ppwStart, iLetter); } else DumpWords(); /* found one */ cchPhraseLength += pw->cchLength; --cpwLast; ppwStart++; continue; } ; } int Cdecl CompareFrequency(char *pch1, char *pch2) { return auGlobalFrequency[*pch1] < auGlobalFrequency[*pch2] ? -1 : auGlobalFrequency[*pch1] == auGlobalFrequency[*pch2]
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ? 0 : 1; } void SortCandidates(void) { int i; /* Sort the letters by frequency */ for (i = 0; i < ALPHABET; i++) achByFrequency[i] = i; qsort(achByFrequency, ALPHABET, sizeof(char), (int (*)(const void *, const void *))CompareFrequency); fprintf(stdout, "Order of search will be "); for (i = 0; i < ALPHABET; i++) fputc(i2ch(achByFrequency[i]), stdout); fputc('\n', stdout); } int fInteractive; char * GetPhrase(char * pch) { if (fInteractive) printf(">"); fflush(stdout); if (gets(pch) == NULL) { #ifdef PLUS_STATS PrintDerefStats(stdout); PrintHeapSize(stdout); #endif /* PLUS_STATS */ exit(0); }...
View Full Document

This note was uploaded on 12/20/2009 for the course ECE 466 taught by Professor Staff during the Fall '09 term at Clarkson University .

Page1 / 2

S-14 - 0 1 void SortCandidates(void int i Sort the letters by frequency for(i = 0 i< ALPHABET i achByFrequency[i = i qsort(achByFrequency

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online