Introduction to Computer Systems Chapter 16

Introduction to - Chapter 16 16.1 int changeToPL(char word int i = 1 char first = word[0 if(first =\0 return-1 while(word[i!=\0 word[i 1 = word[i

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

View Full Document Right Arrow Icon
Chapter 16 16.1 int changeToPL(char * word) { int i = 1; char first = word[0]; if (first = '\0') return -1; while (word[i] != '\0') word[i - 1] = word [i]; word[i] = first; word[i + 1] = 'a'; word[i + 2] = 'y'; word[i + 3] = '\0'; } 16.3 x = 7 16.5 void insertionSort(char* list[]) { int unsorted; int sorted; char *unsortedItem; /* This loop iterates from 1 thru MAX_NUMS */ for(unsorted = 1; unsorted < MAX_NUMS; unsorted++) { unsortedItem = list[unsorted]; /* This loop iterates from unsorted thru 0, unless we hit an element smaller than current item */ for(sorted = unsorted - 1; (sorted >= 0) && (StringCompare(list[sorted], unsortedItem) == 2); sorted--) list[sorted+1] = list[sorted]; list[sorted +1] = unsortedItem; /* Insert Item */ } } 16.7 A snapshot of the run-time stack is shown in the table below. Memory values are shown in the right-most column. 0xEFF8 ind 0xEFFA 0xEFF9 ptr 0xEFFA 0xEFFA apple 125 0xEFFB saved frame pointer 0xEFFC saved return address 0xEFFD return value
Background image of page 1

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

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

This note was uploaded on 03/30/2008 for the course ECE 252 taught by Professor Wood during the Spring '08 term at Wisconsin.

Page1 / 3

Introduction to - Chapter 16 16.1 int changeToPL(char word int i = 1 char first = word[0 if(first =\0 return-1 while(word[i!=\0 word[i 1 = word[i

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

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