{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

23_Slides-Editorbuffer

This preview shows pages 1–9. Sign up to view the full content.

CS112 Fundamentals of  Programming Abstractions Efficiency and ADTs Yinglin Wang CS Dept., SJTU

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

View Full Document
CS112 Fundamentals of  Programming Abstractions Our website moved to 202.120.1.155/wang-yl/index.htm ftp site remains 202.120.7.244
CS112 Fundamentals of  Programming Abstractions Solution to exercise 1 Main() {      stackADT integerStack;      int integer;      integerStack=NewStack();      printf(”enter a list of integers, ending with 0:”);      while(TRUE){           printf(“>”);           scanf(“%d”; &integer);           if(integer!=0) Push(integerStack, integer);           else break;      }          printf(“Those integers in reverse order are:”) ;      while(!StackIsEmpty){           pringtf(“\n %d”, Pop(integerStack));      }      }

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

View Full Document
CS112 Fundamentals of  Programming Abstractions Solution to exercise 2 Main() {      printf(”enter a list of integers, ending with 0:”);      reverseIntegers(); } void reverseIntegers(void){        int integer;          printf(“>”);        scanf(“%d”; &integer);        if(integer==0) { printf(“Those integers in reverse order are:”) ;                  return;            }        else  {reverseIntegers()};        printf(“\n%d”, integer); }
CS112 Fundamentals of  Programming Abstractions Different strategies for  representing data  can have a  significant effect on the efficiency of yr code. linked list  is a useful data structure for insertion and  deletion operations. Main points:

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

View Full Document
CS112 Fundamentals of  Programming Abstractions Today we will discuss the  implementation of an  Editor Buffer, which is the  topic of your next  assignment.  An Editor Buffer is the  data structure that  underlies text editing  programs like Notepad.  The first implementation  we will consider is based  on arrays. The picture  here is the demonstration  of program.