CS112_23_Slides-Editorbuffer

CS112_23_Slides-Editorbuffer - Efficiency and ADTs Yinglin...

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

View Full Document Right Arrow Icon
S112 Fundamentals of Efficiency and ADTs Yinglin Wang CS Dept., SJTU
Background image of page 1

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

View Full DocumentRight Arrow Icon
S112 Fundamentals of Our website moved to 202.120.1.155/wang-yl/index.htm ftp site remains 202.120.7.244
Background image of page 2
S112 Fundamentals of 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)); } }
Background image of page 3

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

View Full DocumentRight Arrow Icon
S112 Fundamentals of 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); }
Background image of page 4
S112 Fundamentals of 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:
Background image of page 5

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

View Full DocumentRight Arrow Icon
S112 Fundamentals of 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.
Background image of page 6
S112 Fundamentals of Buffer.h: see textbook 375-378 Typedef struct bufferCDT *bufferADT bufferADT NewBuffer(void) Void Freebuffer(bufferADT buffer) MoveCursorForward(bufferADT buffer) MoveCursorBackward(bufferADT buffer) MoveCursorToStart(bufferADT buffer) MoveCursorToEnd(bufferADT buffer) void InsertCharacter(bufferADT buffer,char ch) void DeleteCharacter(bufferADT buffer) void DisplayBuffer(bufferADT buffer)
Background image of page 7

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

View Full DocumentRight Arrow Icon
S112 Fundamentals of Array Implementation of Editor Buffer struct bufferCDT { char text[MaxBuffer]; int length; int cursor; }; … … void MoveCursorBackward(bufferADT buffer)
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/06/2010 for the course CS 112 taught by Professor Yinlinwang during the Spring '08 term at Shanghai Jiao Tong University.

Page1 / 31

CS112_23_Slides-Editorbuffer - Efficiency and ADTs Yinglin...

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

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