1 / 8

# Synthesis with the Sketch System - PowerPoint PPT Presentation

Synthesis with the Sketch System. Day 3. Armando Solar- Lezama. In place list reversal. Problem statement. Given a list like this: Produce a list like this :. head. head. Constraints . Your algorithm must be O(n) Your algorithm must use a constant space

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' Synthesis with the Sketch System' - ehren

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Synthesis with the Sketch System

Day 3

Armando Solar-Lezama

• Given a list like this:

• Produce a list like this:

. . .

. . .

• Your algorithm must be O(n)

• Your algorithm must use a constant space

• It can not use arrays or recursion

harness voidmain(int n){

if(n >= MAXN){ n = MAXN-1; }

node[n] nodes = null;

list l = newList();

popList(n, l, nodes);

reverseSK(l);

check(n, l, nodes);

}

voidpopList(int n, list l, refnode[n] nodes){

node tail= null;

for(int i=0; i<n;++i){

node t = newNode();

if(i>0){

tail.next = t;

}else{

}

tail = t;

nodes[i] = t;

}

}

void check(int n, list l, node[n] nodes){

inti=0;

while(cur != null){

assertcur == nodes[n-1-i];

cur = cur.next;

i = i+1;

}

asserti == n;

if(n > 0){

}else{

}

}

voidreverseSK(ref list l){

node tmp1 = null;node tmp2 = null;

while( ){

}

}

{| (tmp1 | tmp2 | l.head)(.next)? |}